battery3.15 VESP32SRAMreset cause.noinitz zWi-FiBOD1void setup() {2 auto r = esp_reset_reason();3 if (r == ESP_RST_BROWNOUT) rest();4 if (r == ESP_RST_PANIC) crashes++;5 else crashes = 0;6 if (crashes >= 3) backOff();7 startWiFi();8}240 mARSTBROWNOUT0x0PANIC+1
Back: the board (battery, voltmeter, brown-out detector, ESP32 with its memory cells, Wi-Fi radio)Front: setup(), the first code after every resetTokens: current, the reset signal, the reset cause, a bad read and crash countsAn ESP32 sensor node on a tired battery: a voltmeter on the supply rail, a brown-out detector, the Wi-Fi radio, and memory cells for SRAM, the reset cause and a crash count, with setup() on a card in front. Wi-Fi draws 240 mA and the rail sags from 3.15 V to 2.39 V, below the 2.43 V detector level, so the chip resets; setup() reads ESP_RST_BROWNOUT and sleeps to let the battery recover. A null pointer read then panics the chip; setup() counts panics in .noinit memory and backs off after 3.

Brown-out

  1. Our ESP32 sensor node runs on a tired battery. Its ESP32-WROOM-32 module holds 3.3 V flash memory, so it needs 3.0 to 3.6 volts. Awake with the radio off it draws about 50 mA, and the meter reads 3.15 V.

Resets

Faults

What happens

;; step 1/10 · rail
module    ESP32-WROOM-32: 3.0 V to 3.6 V
          (its 3.3 V flash sets the 3.0 V floor)
chip      the bare ESP32 alone: 2.3 V to 3.6 V
battery   3.35 V behind 4 ohms (worn cell, thin wires)
idle      50 mA  ->  3.35 - 0.05 x 4 = 3.15 V

The battery is modelled as 3.35 V behind 4 ohms, an assumed value for a worn cell plus thin wires; a real battery's voltage also recovers slowly. The 240 mA and 30-68 mA figures are the ESP32 datasheet's typical values at 3.3 V. The Wi-Fi radio and the brown-out detector are inside the ESP32. The figure draws them as separate blocks so you can see the current and the comparison.