Every embedded engineer gets this bug eventually. The device runs perfectly on your desk for days. You install it on site, and the serial log fills with this:
Brownout detector was triggered
ets Jul 29 2019 12:21:46
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)The ESP32 has a brownout detector that resets the chip when its supply voltage drops too low. It is doing its job. The question is why the voltage drops on site and not on your desk.
The radio is a current spike machine
When the Wi-Fi radio transmits, especially while connecting or after a reconnect, the chip draws short bursts of current many times its idle draw. Espressif's own guidance is to design the 3.3 V supply for around 500 mA so it can absorb those peaks.
On the bench you probably have a short USB cable from a laptop port and a development board with a decent regulator and capacitors already fitted. In the field you have something else.
What changes between the bench and the site
- Long, thin wires. A few metres of thin cable has enough resistance that a 400 mA spike drops a noticeable fraction of a volt before it reaches the board.
- A different regulator. The popular AMS1117 needs over a volt of headroom. Feed it 4.2 V from a sagging battery and there is very little left for spikes.
- Weak signal. A distant access point means more retries and more time at full transmit power.
- Everything else waking up at once. A servo, relay or LED strip on the same rail, switching while Wi-Fi connects.
- Cold. Batteries deliver less current when cold, so a unit that survives an afternoon may fail before dawn.
First, prove it
Do not guess. Log the reset reason on every boot and keep a counter that survives resets:
#include "esp_system.h"
#include "nvs_flash.h"
#include "nvs.h"
void log_reset_reason(void) {
esp_reset_reason_t r = esp_reset_reason();
if (r == ESP_RST_BROWNOUT) {
nvs_handle_t h;
uint32_t n = 0;
nvs_open("diag", NVS_READWRITE, &h);
nvs_get_u32(h, "brownouts", &n);
nvs_set_u32(h, "brownouts", ++n);
nvs_commit(h);
nvs_close(h);
printf("brownout reset #%u\n", (unsigned)n);
}
}Send that counter with your telemetry. A unit that reports brownouts is telling you exactly where to look. Then put a scope on the 3.3 V pin at the board, trigger on a falling edge, and watch what happens during a Wi-Fi connect.
The fixes, in order of how often they work
- Bulk capacitance close to the chip. A 470–1000 µF low-ESR capacitor across 3.3 V and ground, next to the module, plus the usual 100 nF ceramic. This alone fixes a large share of field resets.
- A regulator with headroom. Use a low-dropout regulator rated well above your peak current, or a small buck converter if you start from 5 V or more.
- Shorter, thicker supply wiring, or regulate at the device end rather than at the power supply end.
- Separate rails for motors and relays, sharing only ground.
- Lower transmit power if the access point is close enough:
// units of 0.25 dBm: 44 = 11 dBm
esp_wifi_set_max_tx_power(44);Disable the brownout detector. The chip will keep running at a voltage where flash writes and radio behaviour are unreliable, and you will trade an obvious reset for corrupted data that is much harder to find.
A field checklist
| Check | What good looks like |
|---|---|
| 3.3 V at the module during Wi-Fi connect | No dip below roughly 3.0 V on the scope |
| Bulk capacitor | Within a couple of centimetres of the module |
| Regulator input | Headroom above its dropout at your lowest battery voltage |
| Brownout counter in telemetry | Zero, and staying zero |
If it only fails in the field, test the power the field gives it, not the power your desk gives it.
