ESP32-S2 network disconnect

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Shaunsail
 
Posts: 14
Joined: Tue Sep 07, 2021 11:14 am

ESP32-S2 network disconnect

Post by Shaunsail »

[split off from previous topic -- danhalbert]

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
Attachments
IMG_3560.jpg
IMG_3560.jpg (144.07 KiB) Viewed 61 times

User avatar
bidrohini
 
Posts: 202
Joined: Thu Oct 20, 2022 10:03 am

Re: ESP32-S2 network disconnect

Post by bidrohini »

This error message typically indicates that the device you are trying to connect to the network with is unable to find a network with the specified SSID (network name). This could be due to a number of reasons, such as the network not being in range, the network not being broadcasted, or the network's SSID being spelt incorrectly.

Try to ensure the wifi is on and nearby, check if the SSID is correctly spelt, also try to forget the network and reconnect to it.
If the problem persists, try to restart the device and check your router setting.
You can check this thread too: https://github.com/adafruit/circuitpython/issues/4093

User avatar
danhalbert
 
Posts: 4649
Joined: Tue Aug 08, 2017 12:37 pm

Re: ESP32-S2 network disconnect

Post by danhalbert »

@Shaunsail: PortalBase does its own attempt at connection. You need to catch the ConnectionError exception inside a try-catch so the program doesn't stop because of an uncaught exception.

If you upload your whole program we can take a look.

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”