Hi there! I have been trying a code to connect the ESP32 to a WiFi network automatically with success, if there is a WiFi network to connect, because if the SSID or Password is incorrect, serverals trying of the network library to connect seems to "hung" the ESP32 module whos stop others thread process.
I don't want to boring you with large codes, but fortunately for this problem, with the next simple code the fail works too:
from network import WLAN
from machine import Pin
TEST_LED = Pin(21,Pin.OUT)
TEST_SW = Pin(17,Pin.IN,pull=Pin.PULL_UP)
ssid = "PabloASua"
password = "48554793"
station = WLAN(0)
station.active(True)
station.connect(ssid, password)
while station.isconnected() == False:
if TEST_SW.value() == False:
TEST_LED.value(True)
else:
TEST_LED(False)
print("Connection successful")
print(station.ifconfig())
In this simple code, like in mine, the TEST_LED work perfectly when I push the button TEST_SW while the ESP32 can't connect to my unplugged WiFi Network, but just for some minutes. In some moment the ESP32 seems to lost the while loop station.isconnected and of course the LED and Switch stop working. At the same time in the repl prompt I receive the STA_DISCONNECTED, reason: 201.
The strange thing here is that when I reconnect the WiFi Network, in the repl prompt, I receive the connected message!
Summarizing: The ESP32 seems to hung in some way before a long time trying to connect to a WiFi Network.
What I'm doing wrong?
By the way, I'm using a ESP-WROOM-32 device.
Thanks for your time to read.
Regards!
ESP32 WiFi Network
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: ESP32 WiFi Network
You might like to read this thread notably the last post.
It's also worth noting that the ESP32 port is still somewhat experimental and issues like this one are as yet unresolved.
It's also worth noting that the ESP32 port is still somewhat experimental and issues like this one are as yet unresolved.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.