Resolving ESP32 Brownout Reset During WiFi Connection
What causes this
The ESP32 is engineered with a robust power management system, but it's susceptible to brownout conditions, particularly during high power operations like WiFi connectivity. A brownout reset occurs when the voltage supplied to the ESP32 falls below a critical threshold, triggering the brownout detector (BOD). This typically happens due to insufficient power supply capabilities or sudden current demands during WiFi operations. The ESP32's Brownout Detection registers, specifically the RTC_CNTL_BROWN_OUT_REG, monitor the voltage. When voltage drops are detected, the system logs an error and resets. The error code you might see in the serial output is rst:0xc (Brownout). If you're using the ESP-IDF, the rtc_cntl_ll component manages these voltage checks, and an improper configuration can exacerbate sensitivity to voltage dips.
Minimal reproduction
To reproduce the brownout reset, use the following minimal code. This code attempts to connect to WiFi, which may trigger a brownout if the power supply is inadequate:
```cpp
#include
const char* ssid = "your_SSID";
const char* password = "your_PASSWORD";
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected!");
}
void loop() {
// Put your main code here, to run repeatedly:
}
```
Expected serial output when brownout occurs:
```
Connecting to WiFi...
Connecting to WiFi...
Connecting to WiFi...
Brownout detector was triggered
rst:0xc (Brownout) boot:0x13 (SPI_FAST_FLASH_BOOT)
```
The fix
To fix the brownout reset issue, ensure your power supply can deliver adequate current, at least 500mA. Additionally, add capacitors close to the ESP32's power pins to stabilize the voltage during peak demand.
Before
```cpp
// No capacitors and insufficient power supply
```
After
- Use a power supply capable of delivering at least 500mA.
- Add a 10uF capacitor and a 0.1uF decoupling capacitor near the ESP32's power pins.
- [ ] Verify your power supply can provide at least 500mA.
- [ ] Add a 10uF and a 0.1uF capacitor near the ESP32 power input.
- [ ] Include a delay before connecting to WiFi in your code.
- [ ] Use SerialDoctor to analyze and diagnose serial output errors.
- [ ] Ensure your USB cable and connections are of good quality and provide stable voltage.
```cpp
// Circuit schematic with additional capacitors
```
In your code, make sure to include a delay before attempting to connect to WiFi to allow voltage stabilization:
```cpp
void setup() {
Serial.begin(115200);
delay(1000); // Allow power stabilization
WiFi.begin(ssid, password);
// Rest of the code
}
```
How SerialDoctor catches this
SerialDoctor reads the serial output and instantly identifies the brownout reset issue. By parsing the error code rst:0xc (Brownout), it determines that a brownout detector triggered the reset. SerialDoctor provides detailed insights and recommendations on resolving power issues, ensuring your ESP32 remains stable during WiFi operations. Check out more at [serialdoctor.com](http://serialdoctor.com).
Quick checklist
Seeing this crash on your board right now?
Connect it to SerialDoctor and get a root cause + code fix in under 3 seconds.
Try SerialDoctor free →