Trying to connect HUZZAH32 ESP32 Feather to WIFI

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
burtb45
Posts: 1
Joined: Thu Apr 08, 2021 9:39 pm

Trying to connect HUZZAH32 ESP32 Feather to WIFI

Post by burtb45 » Thu Apr 08, 2021 10:55 pm

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.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Trying to connect HUZZAH32 ESP32 Feather to WIFI

Post by Roberthh » Fri Apr 09, 2021 6:47 am

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.

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()


beka
Posts: 8
Joined: Wed Sep 20, 2017 9:29 am

Re: Trying to connect HUZZAH32 ESP32 Feather to WIFI

Post by beka » Fri Apr 09, 2021 8:48 am

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?

Post Reply