diff --git a/examples/micropython.py b/examples/micropython.py index 2ca99f3..2d05a50 100644 --- a/examples/micropython.py +++ b/examples/micropython.py @@ -87,8 +87,11 @@ def wifi_connect(): wlan = network.WLAN(network.STA_IF) wlan.active(True) - wlan.connect(WIFI_SSID, WIFI_PASS) - while (not wlan.isconnected()): + while not wlan.isconnected(): + try: + wlan.connect(WIFI_SSID, WIFI_PASS) + except Exception as e: + logging.error(f"Failed to connect to WiFi: {e}.") logging.info("Trying to connect. Note this may take a while...") time.sleep_ms(500) logging.info("WiFi Connected ", wlan.ifconfig())