ESP32 Random Reset / Reboot
Complete guide to diagnosing and fixing random ESP32 resets, watchdog timeouts, brownout detection, and unexpected reboots.
Last updated: April 22, 2026 | 12 min read
Symptoms
- ESP32 restarts randomly during operation
- Serial Monitor shows "rst:0x10 " or similar error
- "Brownout detector was triggered" message appears
- "Guru Meditation Error" with exception decoder output
- Device works fine for minutes/hours then reboots
- Reboots occur when WiFi connects or relay activates
Common Causes
- Insufficient power supply Voltage drops below 3.0V during high current draw
- Watchdog Timer timeout Task blocked for too long
- Brownout detection Voltage falls below 3.0V or 3.3V threshold
- Memory corruption Heap overflow, stack overflow, or invalid pointer
- Task watchdog trigger CPU stuck in infinite loop without yielding
- Power supply ripple Unstable voltage from cheap USB cable or adapter
ESP32 Reset Reason Codes
| Reset Code | Meaning | Solution |
|---|---|---|
| rst:0x1 | Power-on reset | Normal on boot ignore if not frequent |
| rst:0x3 | Software reset | Check for ESP.restart() in code |
| rst:0x7 | Deep sleep wake | Normal check wake cause |
| rst:0x8 | SDIO reset | Hardware issue check connections |
| rst:0x9 | Timer Group Watchdog | Add delay() or vTaskDelay() in loops |
| rst:0xa | Interrupt Watchdog | Check ISR keep interrupts short |
| rst:0xb | Task Watchdog | Add vTaskDelay in loops |
| rst:0x10 | RTC Watchdog | Power issue or deep sleep problem |
| Brownout detector | Voltage below 3.0V | Upgrade power supply, add capacitor |
Guru Meditation Errors
| Error | Cause | Solution |
|---|---|---|
| LoadProhibited | Null pointer access | Check pointers before dereferencing |
| StoreProhibited | Writing to invalid memory | Check array bounds |
| InstrFetchProhibited | Jumping to invalid address | Check function pointers |
| IllegalInstruction | Corrupted code execution | Re-flash firmware |
Step-by-Step Fixes
1. Fix Power Supply Issues
The most common cause of random resets is inadequate power. WiFi peaks at ~200mA.
- Use 5V 2A power supply
- Use quality USB cable
- Add 470-1000F capacitor between 5V and GND
- Measure voltage at 3.3V pin must stay above 3.0V
2. Fix Watchdog Timer Issues
Add delays in long loops to prevent task watchdog reset.
void loop() {
// Your code here
delay; // Allow watchdog to reset
// OR for FreeRTOS tasks:
vTaskDelay;
}
3. Add Reset Reason Detection
Add this code to understand why your ESP32 reset:
#include <esp_system.h>
void setup() {
Serial.begin;
esp_reset_reason_t reason = esp_reset_reason();
switch {
case ESP_RST_POWERON: Serial.println; break;
case ESP_RST_BROWNOUT: Serial.println; break;
case ESP_RST_TASK_WDT: Serial.println; break;
case ESP_RST_INT_WDT: Serial.println; break;
case ESP_RST_DEEPSLEEP: Serial.println; break;
default: Serial.printf;
}
}
4. Disable Brownout Detector
Only for testing not recommended for production.
// In setup() before anything else
#include "soc/soc.h"
#include "soc/rtc_cntl_reg.h"
WRITE_PERI_REG; // Disable brownout
5. Increase Watchdog Timeout
For long operations, increase watchdog timeout.
#include "esp_task_wdt.h"
void setup() {
esp_task_wdt_init; // 10 second timeout
esp_task_wdt_add;
}
6. Check for Memory Leaks
Monitor heap memory to detect leaks.
void loop() {
Serial.printf);
// If heap decreases continuously, you have a leak
delay;
}
Diagnostic Commands
- Monitor reset reason: Add
esp_reset_reason()to setup() - Check free heap:
Serial.println); - Check free stack:
Serial.println); - Enable exception decoder: Tools Core Debug Level "Verbose" in Arduino IDE
- Decode backtrace: Use
addr2linewith .elf file
Prevention Tips
- Always use
delay()orvTaskDelay()in long loops - Use a 5V 2A power supply with 470-1000F capacitor
- Avoid blocking operations in interrupts
- Monitor free heap memory regularly
- Enable Core Debug Level "Error" to see reset reasons
- Use
ESP.getFreeHeap()to detect memory leaks
Related Issues
Frequently Asked Questions
Q: What does "Brownout detector was triggered" mean?
A: The ESP32's voltage dropped below 3.0V . Usually caused by inadequate power supply or poor USB cable. Add a 470-1000F capacitor.
Q: How do I read the reset reason after reboot?
A: Add esp_reset_reason() in setup() and print to Serial Monitor. The ESP32 stores this in RTC memory across resets.
Q: What is Task Watchdog Timer ?
A: A hardware timer that resets the ESP32 if a task doesn't yield for too long . Add delay or vTaskDelay in loops.
Q: My ESP32 resets when I turn on a relay. Why?
A: Relay coils draw high current . Power supply may dip below 3.0V. Use external 5V for relays and add a large capacitor.
Still having random resets? Contact Support or return to the Troubleshooting Hub.