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:

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