Skip to content

Commit 52abcb8

Browse files
authored
PyPortal_AWS_IOT_Planter: update to settings.toml
1 parent 76cd05b commit 52abcb8

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

  • PyPortal/PyPortal_AWS_IOT_Planter

PyPortal/PyPortal_AWS_IOT_Planter/code.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
1111
Author: Brent Rubell for Adafruit Industries, 2019
1212
"""
13+
import os
1314
import time
1415
import json
1516
import board
@@ -27,12 +28,10 @@
2728
# Time between polling the STEMMA, in minutes
2829
SENSOR_DELAY = 15
2930

30-
# Get wifi details and more from a secrets.py file
31-
try:
32-
from secrets import secrets
33-
except ImportError:
34-
print("WiFi secrets are kept in secrets.py, please add them there!")
35-
raise
31+
secrets = {
32+
"ssid" : os.getenv("CIRCUITPY_WIFI_SSID"),
33+
"password" : os.getenv("CIRCUITPY_WIFI_PASSWORD"),
34+
}
3635

3736
# Get device certificate
3837
try:
@@ -127,8 +126,8 @@ def message(client, topic, msg):
127126
print("Message from {}: {}".format(topic, msg))
128127

129128
# Set up a new MiniMQTT Client
130-
client = MQTT.MQTT(broker = secrets['broker'],
131-
client_id = secrets['client_id'],
129+
client = MQTT.MQTT(broker = os.getenv("BROKER"),
130+
client_id = os.getenv("CLIENT_ID"),
132131
socket_pool=pool,
133132
ssl_context=ssl_context)
134133

0 commit comments

Comments
 (0)