A connection that drops after it was working usually needs reconnect code, a steadier supply or a stronger signal. Do not assume WiFi.begin() once at start-up is enough.
What the message means
The ESP32 can lose the access point for many reasons: weak signal, a router that drops idle clients, a supply dip during radio bursts, or a long blocking loop. The board does not always reconnect on its own unless you ask it to.
Fix it in this order
- Call WiFi.setAutoReconnect(true) and also check WiFi.status() in loop(). If it is not connected, call WiFi.reconnect().
- Turn off Wi-Fi power saving with WiFi.setSleep(false) while you debug. It can reduce dropped connections at the cost of more current.
- Check the supply. Radio bursts draw current peaks, and a weak USB port or thin wire causes dropouts and resets.
- Move closer to the router or fix the antenna. A weak signal looks like random disconnects.
- Avoid long delay() calls and blocking loops. Keep loop() short so the Wi-Fi tasks get time.
- Check the router: too many clients, a short DHCP lease or a channel crowded with neighbours can drop devices. Try a fixed channel.
- Print the disconnect reason from the Wi-Fi event handler. It tells you if the access point kicked the board or the signal was lost.
Why it happens
Wi-Fi drops on an ESP32 usually come from a weak supply, a poor signal, the radio power-save mode, or code that never reconnects. The radio draws short, large current bursts, so a weak USB cable or port can cause brown-outs that look like disconnects.
Use a good supply with a capacitor near the board, move closer to the router, and add a reconnect step in code.
void loop() {
if (WiFi.status() != WL_CONNECTED) {
WiFi.disconnect();
WiFi.reconnect();
delay(5000);
}
}
// WiFi.setSleep(false); in setup() turns off power-save if drops continueExample sketch: change pins and values for your own wiring. It has not been bench-tested on your hardware.
If you see this, do this
| You see | Do this |
|---|---|
| Drops every few minutes | Router lease or power-saving settings. |
| Drops when the motors run | Supply dip. Separate the motor supply. |
| Drops far from the router | Signal strength. |
Related
ESP32 will not connect to Wi-Fi, ESP32 brownout, Wi-Fi controlled robot with ESP32.
Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.