The first line of the ESP32 boot log tells you why the chip restarted. Read the rst: value before you change code.
What the message means
The ROM prints a reset reason code at every start. It separates a normal power-up from a crash or a power problem.
Fix it in this order
- rst:0x1 (POWERON_RESET) is a normal power-up or the reset button.
- rst:0x5 (DEEPSLEEP_RESET) means it woke from deep sleep.
- rst:0xc (SW_CPU_RESET) is a software restart, such as ESP.restart() or a panic.
- rst:0x7 or 0x8 (TG0WDT or TG1WDT) are watchdog resets. Look for loops that never yield.
- rst:0xf (RTCWDT_BROWN_OUT_RESET) points to a supply that sags.
- A repeating reset loop means the cause comes back on every start. Fix the cause shown before it.
Why it happens
Each time the ESP32 starts, its ROM bootloader prints a reset reason code before the sketch runs. The code records what brought the chip out of its previous state, such as a power-up, a software restart, a deep-sleep wake or a watchdog timeout. Reading that code tells you whether the device restarted normally or because something failed, which narrows the search.
A watchdog reset means a task held the processor too long without yielding, so the timer fired. A brownout reset means the supply voltage dipped below the chip’s threshold, often when Wi-Fi draws a burst of current. A repeating reset loop usually repeats the cause printed just above the reset line, so the crash message before it is the place to look.
If you see this, do this
| You see | Do this |
|---|---|
| Resets right after Wi-Fi starts | Weak power supply. |
| Resets after the same function | Look at the crash message above the reset line. |
Confirm the fix
- Press reset with the serial monitor open. The first boot lines show a reset reason code you can match against the chip’s documentation.
- Print millis() every second. If the counter drops back to zero, the chip restarted, and the timing shows when it happened.
- Measure the 3.3 V rail with a multimeter while Wi-Fi connects. A sag toward the brownout threshold, with a reset following, confirms a supply problem.
Common mistake: Most readers assume that any reset means the code crashed, when a power-on or deep-sleep wake reason is normal and only watchdog or brownout codes point to a fault.
Related
brownout, task watchdog, Guru Meditation.
Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.
Why this happens
The ESP32 ROM records why the chip came out of reset, and prints it as the rst: code at the start of the boot log. A power-on reset means the supply came up. A deep-sleep reset means a timer or pin woke it. A software reset means the program, or the panic handler after a crash, asked for a restart. Watchdog and brownout codes mean the hardware forced the restart.
The code to look at depends on the first-line number. A panic prints a crash report, then shows a software CPU reset (0xc) in the next boot log. A brownout detector trips when the supply drops below its threshold, and Wi-Fi start-up and motor starts are common causes. The reset code narrows the search before you read any code.
How to confirm the cause
- Copy the first lines of the boot log for each restart, and the lines just before them. The cause is often printed just above the reset.
- Match the code: 0x1 power-on, 0x5 deep sleep, 0xc software CPU reset, 0x7 and 0x8 watchdog, 0xf brownout.
- Print the reason from your own sketch with esp_reset_reason(). It names panics and task watchdog resets separately, which the ROM code does not.
- Print uptime. A reset at a fixed interval suggests a watchdog or a timer. A reset at an irregular time suggests power.
- Measure the 3.3 V rail while the problem happens.
Worked example
This sketch prints the reason at the start of every boot using the ESP-IDF function available in the Arduino core.
#include <esp_system.h>
void setup() {
Serial.begin(115200);
esp_reset_reason_t r = esp_reset_reason();
Serial.printf("reset reason code: %d\n", (int)r);
if (r == ESP_RST_BROWNOUT) Serial.println("brownout: check supply");
else if (r == ESP_RST_PANIC) Serial.println("panic: read the crash dump");
else if (r == ESP_RST_TASK_WDT) Serial.println("task watchdog: loop blocked");
else if (r == ESP_RST_POWERON) Serial.println("normal power-up");
}
void loop() {}If the sketch reports a panic, the answer is in the backtrace above the reset. If it reports a brownout, work on the supply, not the code.
Common mistakes
- Treating every restart as a software crash.
- Reading only the rst: line and ignoring the lines above it.
- Assuming a software reset is always a bug, when ESP.restart() causes it on purpose.
- Fixing code for a brownout that a better cable would solve.
If this did not fix it
- Repeated brownout: use a shorter cable, a better supply and a capacitor near the module.
- Watchdog: look for loops that never return or very long delay() calls.
- Strange boot lines after a reset: check the strapping pins.