I have a related issue. I have a project running on a Funhouse. My network is not great and the internet drops and or the SSID disappear for a few moments. This is causing my project to crash. I have try to add an error trap to to test the Wifi connection and reset it before sending (once a minute), but after hours or days it crashes.
The error message calls out wifi_esp32s2.py so I don't think my code gets a chance. this is beyond my simple programming skills.
Code: Select all
def reset_wifi():
t_failed = " {:02d}:{:02d}".format(datetime.today().hour, datetime.today().second)
updating_label.text = "Failed to send\n to IO: " + t_failed
# print("Failed to send to IO" + t_failed)
connection_failed = True
while connection_failed is True:
# Turn off WiFi
network.enabled = False
time.sleep(4)
# Turn on WiFi
network.enabled = True
# Connect to WiFi
try:
network.connect()
connection_failed = False
except:
connection_failed = True
t_ok = " {:02d}:{:02d}".format(datetime.today().hour, datetime.today().second)
updating_label.text = "wifi reset: " + t_ok
# print("wifi reset" + t_ok)
return