ESP32 WiFi disconnects in the field: finding the cause from afar
On the bench the WiFi is fine; at the customer the device drops off every few hours. The ESP32 tells you why each time it disconnects, in a reason code. The trick is getting those codes, and the signal strength, back from a device you cannot plug into.
The reason code is the first clue
ESP-IDF raises WIFI_EVENT_STA_DISCONNECTED with a reason. The ones that show up most in the field:
- 200 BEACON_TIMEOUT: the device stopped hearing the access point. Weak signal, interference, or the AP restarted.
- 201 NO_AP_FOUND: the network was not found on reconnect. The AP moved channel, changed band, or the SSID changed.
- 202 AUTH_FAIL / 15 4WAY_HANDSHAKE_TIMEOUT: the password changed, or the handshake failed, often on a weak link or with WPA3-only networks.
- 8 ASSOC_LEAVE: the device itself disconnected, usually your own code calling
esp_wifi_disconnect()or a restart. - 2 AUTH_EXPIRE, 4 ASSOC_EXPIRE: the AP dropped the device, often for inactivity or load.
See ESP32 error messages explained for the rest.
Then the signal and the power
RSSI below about -75 dBm makes drops likely; below -85 dBm they are certain. A drop that coincides with a brownout reset is a power problem, not a WiFi one: the radio draws its peak current while reconnecting.
Getting the numbers from devices you cannot reach
Logging to serial does not help once the device is installed. Pinscope sends the number of disconnects, the last reason code and the RSSI as metrics from every device, with no code of your own (they are part of the built-in metrics), keeps the device's log lines, and alerts you when a device goes offline. Charted next to each other, they usually tell you within a day whether it is the signal, the access point or the power.
Related: getting an alert when an ESP32 goes offline and remote logging for ESP32.
Try it
Three devices are free, and no card is needed. Create an account, or read the guide for your platform: ESP32, Zephyr, Raspberry Pi Pico, Linux, ESP8266.
More
- Remote access to an ESP32 without TLS: what it measured and what it costs
- Reaching an ESP32 web server from outside its network
- Updating ESP32 firmware over the internet, with rollback
- Guru Meditation Error: decoding the backtrace, and crashes from the field
- Remote logging: ESP_LOG without a serial cable
- Heap and stack monitoring in the field
- An ESP32 behind CGNAT, 4G or Starlink
- TLS memory usage on the ESP32, and how to reduce it
- Sharing an ESP32 sensor page with anyone, without port forwarding
- ArduinoOTA over the internet, with a rollback
- ESP32 remote access compared: port forwarding, ngrok, Cloudflare Tunnel, Tailscale
- esp_http_server slow? The 250 ms delay and the fix
- Before the first ESP32 ships: a field support checklist
- ESP32 exception decoder: a Guru Meditation backtrace to lines, in the browser