Trying to connect several Feathers to the wifi and be able to communicate with them. I'm using esp32-idf4-20210202-v1.14.bin and have macOS
>>> import network
>>> wlan = network.WLAN(network.STA_IF)
>>> wlan.active(True)
TRUE
>>> wlan.connect('ssid', 'password')
>>> wlan.ifconfig()
('172.40.3.190', '255.255.224.0', '172.40.1.1', '172.40.1.1')
>>> import webrepl
>>> webrepl.start()
WebREPL daemon started on ws://172.40.3.190:8266
Started webrepl in normal mode
Then I open the webrepl in a firefox or chrome, paste ws://172.40.3.190:8266 in the box provided but it just says Disconnected. The device doesn't show up in the list of wifi options, (except for one time briefly), and when I try to ping the address it doesn't work. Help would be appreciated.
Trying to connect HUZZAH32 ESP32 Feather to WIFI
Re: Trying to connect HUZZAH32 ESP32 Feather to WIFI
after 'wlan.connect('ssid', 'password')' the connection does not happen immediately. You have to wait until the device is connected, checking with wlan.isconnected(). You can set the ip address before calling wlan.connect(). Then that one is used right from the start.
P.S.: That's the script I use as example.
P.S.: That's the script I use as example.
Code: Select all
def do_connect():
import network
import time
wlan = network.WLAN(network.STA_IF) # create station interface
wlan.active(True) # activate the interface
if not wlan.isconnected(): # check if the station is connected to an AP
wlan.ifconfig((WIFI_IP, "255.255.255.0", WIFI_DNS, WIFI_DNS))
wlan.connect(WIFI_SSID, WIFI_PASSWD) # connect to an AP
for _ in range(10):
if wlan.isconnected(): # check if the station is connected to an AP
break
print('.', end='')
time.sleep(1)
else:
print("Connect attempt timed out\n")
return
print('\nnetwork config:', wlan.ifconfig())
do_connect()
Re: Trying to connect HUZZAH32 ESP32 Feather to WIFI
You connected to the network in station mode so it will not show up in the wifi networks list. Can you ping the gateway 172.40.1.1 from your computer?