ESP32 WiFi Network

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
PabloASua
Posts: 1
Joined: Fri Dec 22, 2017 4:43 pm

ESP32 WiFi Network

Post by PabloASua » Fri Dec 22, 2017 8:52 pm

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!

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: ESP32 WiFi Network

Post by pythoncoder » Sat Dec 23, 2017 8:34 am

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.
Peter Hinch
Index to my micropython libraries.

Post Reply