While the code runs, and data uploads.. it's not at all reliable.. and every so many data transmissions I have my board bomb out and reset (that is, the code hits the exception block) below:
I know the problem isn't in the setup code / wifi, because that always connects reliably. When it bombs, I get "Error:" ... but nothing after error... totally blank.
No errors are showing up on the monitor in adafruit IO either (https://io.adafruit.com/BANNED/monitor).
Suggestions ? I tried increasing / decreasing the time.sleep(1) in the example code below... I noted that removing it entirely seems to cause the board to crash more.. but increasing it past (1) doesn't seem to do anything.
Code: Select all
while True:
try:
# when the clock runs out..
if clock > 300:
# read sensor
data = [aht20.temperature, aht20.relative_humidity]
# send sensor data to respective feeds
for z in range(2):
io.send_data(feed_names[z]["key"], data[z])
print("sent %0.1f" % data[z])
time.sleep(1)
# print sensor data to the REPL
print("\nTemperature: %0.1f C" % aht20.temperature)
print("Humidity: %0.1f %%" % aht20.relative_humidity)
print()
time.sleep(1)
# reset clock
clock = 0
else:
clock += 1
# pylint: disable=broad-except
# any errors, reset Pico W
except Exception as e:
print("Error:\n", str(e))
print("Resetting microcontroller in 10 seconds")
time.sleep(10)
microcontroller.reset()
# delay
time.sleep(1)
print(clock)