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 = '192.168.1.10'
gateway = '192.168.1.1'
subnet = '255.255.255.0'
dns = '8.8.8.8'
ap_if = network.WLAN(network.AP_IF)
def AP_Setup(ssidAP,passwordAP):
ap_if.ifconfig([local_IP,gateway,subnet,dns])
print("Setting soft-AP ... ")
ap_if.active(True)
ap_if.config(essid=ssidAP,authmode=network.AUTH_WPA_WPA2_PSK, password=passwordAP)
print('Success, IP address:', ap_if.ifconfig())
print("Setup End\n")
try:
AP_Setup(ssidAP,passwordAP)
except:
print("Failed, please disconnect the power and restart the operation.")
ap_if.disconnect()
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.