Compare commits

...

2 commits

Author SHA1 Message Date
TrevKnows
7243ed5684 Update code.py 2023-02-10 08:11:39 -05:00
TrevKnows
231dd2a927 Removed redundant secrets reference for wifi communication 2023-02-09 17:04:49 -05:00

View file

@ -13,27 +13,15 @@ from adafruit_io.adafruit_io import IO_MQTT
from adafruit_adxl34x import ADXL345
from adafruit_lc709203f import LC709203F, PackSize
try:
from secrets import secrets
except ImportError:
print("WiFi and Adafruit IO credentials are kept in secrets.py - please add them there!")
print("Adafruit IO credentials are kept in secrets.py - please add them there!")
raise
aio_username = secrets["aio_username"]
aio_key = secrets["aio_key"]
# Wi-Fi
try:
print("Connecting to %s" % secrets["ssid"])
wifi.radio.connect(secrets["ssid"], secrets["password"])
print("Connected to %s!" % secrets["ssid"])
# Wi-Fi connectivity fails with error messages, not specific errors, so this except is broad.
except Exception as e: # pylint: disable=broad-except
print("Failed to connect to WiFi. Error:", e, "\nBoard will hard reset in 5 seconds.")
time.sleep(5)
microcontroller.reset()
# Create a socket pool
pool = socketpool.SocketPool(wifi.radio)
@ -62,7 +50,7 @@ except Exception as e: # pylint: disable=broad-except
time.sleep(30)
microcontroller.reset()
threshold = 25 # set threshold value here
threshold = 20 # set threshold value here
time_interval = 0.5 # set the time interval in seconds
# create the I2C bus object