I'm trying to connect to an ESP32-WROOM-32 in AP mode, using the following micropython code:

import network

ssidAP         = 'WiFi_ESP32' #Enter the router name
passwordAP     = '12345678'  #Enter the router password

local_IP       = ''
gateway        = ''
subnet         = ''
dns            = ''

ap_if = network.WLAN(network.AP_IF)

def AP_Setup(ssidAP,passwordAP):
    print("Setting soft-AP  ... ")
    ap_if.config(essid=ssidAP,authmode=network.AUTH_WPA_WPA2_PSK, password=passwordAP)
    print('Success, IP address:', ap_if.ifconfig())
    print("Setup End\n")

    print("Failed, please disconnect the power and restart the operation.")

This code is a direct copy from the FreeNove ESP32 tutorial.

The device shows up on my phone as a WiFi AP, but when I try to connect, my phone spins for a minute and then reports "Couldn't obtain IP address". I've tried this with two different phones (both Android) and two different boards (the other is an ESP32-WROVER-E), and I've also confirmed that it does work when running the equivalent Arduino (C++) sketch.

What am I doing wrong? I'm running MicroPython v1.19.1 firmware.

  • I’m not sure your need the ifconfig in AP mode. Can you try without? Also is it on purpose that your gateway is different from your local IP? The docs don’t give much indication about the DHCP pool settings…
    – jcaron
    Commented Apr 16, 2023 at 21:50
  • @jcaron I tried without ifconfig and with a loop to wait for completion of activation, and got exactly the same behaviour as described above. Commented Apr 17, 2023 at 6:14
  • I've rolled back to MicroPython v1.17 and got it to work as long as I don't use the ifconfig line. Can anyone confirm this for me? Commented Apr 18, 2023 at 15:02

1 Answer 1


As of MicroPython 1.20.0 (2023-04-26) the above code works correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.