Fix: ESP32 Wi-Fi not connecting (stuck on WL_DISCONNECTED)
WiFi.begin() never connects. Check 2.4 GHz band, SSID/password, router security mode, signal and power, in that order.
Community draft — report a mistake
What you see
Connecting to MyHome-5G
..............................
[ 15200][W][STA.cpp:537] connect(): STA disconnected, reason: 201 (NO_AP_FOUND)
Failed to connect after 15 sConnecting to MyHome-5G .............................. [ 15200][W][STA.cpp:537] connect(): STA disconnected, reason: 201 (NO_AP_FOUND) Failed to connect after 15 s
When an ESP32 refuses to join Wi-Fi, the cause is almost always the network, not the board: a 5 GHz-only SSID, a typo in the password, or a router security mode the core does not support.
Print the disconnect reason — it tells you which of these it is.
Quick fix — try in order
- 1
Use the 2.4 GHz network
ESP32 and ESP8266 radios are 2.4 GHz only (the ESP32-C5 is the exception). If your router has one SSID for both bands, create a separate 2.4 GHz SSID.
- 2
Check SSID and password exactly
They are case-sensitive. Copy them from the router page; watch for trailing spaces.
- 3
Read the disconnect reason
Core 3.x logs it: 201 NO_AP_FOUND = wrong SSID or band; 15 / 202 auth fail = wrong password or security mode.
- 4
Set WPA2 (or WPA2/WPA3 mixed)
Pure WPA3 networks can fail on older cores. Mixed mode works with everything.
- 5
Check signal and power
Weak signal and brownouts during connect look the same. Move closer and use a good supply.
Why it happens
Why does it work on my phone?
Phones support 5 GHz; the ESP32 only sees 2.4 GHz. A 5 GHz-only SSID is invisible to it, giving NO_AP_FOUND.
Hidden SSID or MAC filtering
Hidden networks need the exact name; MAC filtering blocks unknown devices — add the ESP32’s MAC (WiFi.macAddress()).
Power dips during connect
Wi-Fi calibration draws current peaks. If the board resets while connecting, see brownout detector.
ADC2 pins and Wi-Fi
Unrelated to connecting, but analogRead on ADC2 pins stops working once Wi-Fi is on — see ADC2 with Wi-Fi.
Board-specific notes
ESP8266: Same 2.4 GHz rule. WiFi.status() returning WL_NO_SSID_AVAIL means the SSID was not found.
Did this fix it?
Thanks — that helps us keep this page right.