Skip to content

Commit d41a856

Browse files
authored
Merge pull request #2776 from adafruit/dhalbert-patch-12
pyportal_pet_planter: update to settings.toml
2 parents 79fa13d + e96290c commit d41a856

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

  • PyPortal/pyportal_pet_planter

PyPortal/pyportal_pet_planter/code.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#
33
# SPDX-License-Identifier: MIT
44

5+
import os
56
import time
67

78
import board
@@ -51,12 +52,10 @@
5152
# the current working directory (where this file is)
5253
cwd = ("/"+__file__).rsplit('/', 1)[0]
5354

54-
# Get wifi details and more from a secrets.py file
55-
try:
56-
from secrets import secrets
57-
except ImportError:
58-
print("WiFi secrets are kept in secrets.py, please add them there!")
59-
raise
55+
secrets = {
56+
"ssid" : os.getenv("CIRCUITPY_WIFI_SSID"),
57+
"password" : os.getenv("CIRCUITPY_WIFI_PASSWORD"),
58+
}
6059

6160
# Set up i2c bus
6261
i2c_bus = busio.I2C(board.SCL, board.SDA)
@@ -191,8 +190,8 @@
191190

192191
# Initialize a new MQTT Client object
193192
mqtt_client = MQTT.MQTT(broker="io.adafruit.com",
194-
username=secrets["aio_user"],
195-
password=secrets["aio_key"],
193+
username=os.getenv("AIO_USERNAME"),
194+
password=os.getenv("AIO_KEY"),
196195
socket_pool=pool,
197196
ssl_context=ssl_context)
198197

0 commit comments

Comments
 (0)