You flash your code, the ESP32 runs for a while, then prints a long block starting with "Guru Meditation Error: Core 1 panic'ed", a string of hex numbers, and reboots. That text is not noise: it is an autopsy report telling you why the chip died and, once decoded, which line of code it died on. This article shows how to read it in order, from quick to deep.
A typical error message
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x400d1a3c PS : 0x00060830 A0 : 0x800d1b10 A1 : 0x3ffb1f60
...
EXCVADDR: 0x00000000 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000000
Backtrace: 0x400d1a3c:0x3ffb1f60 0x400d1b0d:0x3ffb1f80 0x400d2a55:0x3ffb1fb0
ELF file SHA256: 6b5c...
Rebooting...
The four most important pieces:
- The error name in brackets (here
LoadProhibited): the class of failure, which decides where to investigate. - Core: which core faulted (0 or 1). Arduino's
loop()runs on core 1; WiFi and system tasks usually run on core 0. - PC (Program Counter): the address of the instruction running when it died.
- EXCVADDR: the memory address the program tried to access. A value near
0x00000000(such as0x00000000or0x00000010) is almost certainly a NULL pointer access. - Backtrace: the chain of function addresses that led to the fault (each pair is
PC:SP; you only need the first number).
A triage procedure
What the common errors mean
| Message | What it means | Usual causes |
|---|---|---|
LoadProhibited / StoreProhibited | Read or write to an invalid address | NULL or uninitialised pointers (an object whose begin() was never called, malloc returning NULL on out-of-memory), array index out of bounds, using freed memory. |
InstrFetchProhibited | Jumped to an address that is not program code | A bad or NULL function pointer, or a buffer overflow that corrupted a return address. |
IntegerDivideByZero | Integer division by zero | A denominator taken from a sensor or an unassigned variable. |
Unhandled debug exception with "Stack canary watchpoint triggered (task name)" | A task's stack overflowed | Large local arrays or strings, deep recursion, String and printf with big buffers in a small task. Raise the stack size or move the array to a global. |
Task watchdog got triggered ("The following tasks did not reset the watchdog in time") | A task hogged the CPU and never yielded | An infinite while wait, a very long delay, a hung sensor read, heavy computation in loop() or a callback. |
Interrupt wdt timeout on CPU0/1 | An interrupt handler or interrupts-disabled section ran too long | An ISR calling Serial.print, delay, or doing heavy work. An ISR must be short and only set a flag. |
Cache disabled but cached memory region accessed | An ISR called a function stored in flash while flash was busy (NVS write, OTA) | Mark the ISR and every function/variable it uses with IRAM_ATTR. |
Brownout detector was triggered | The supply voltage fell below the threshold | A thin USB cable, a weak supply, or large loads (relay, WiFi, camera, motor) switching on together. See below. |
CORRUPT HEAP / assert failed: ... heap | Heap memory was overwritten | Overrunning a dynamically allocated buffer, double free, using a pointer after freeing it. |
Decoding the backtrace into a source line
The addresses in "Backtrace:" mean nothing by eye. A tool turns them into function names and source lines.
Option 1: PlatformIO (easiest)
Add one line to platformio.ini. On every crash the Serial Monitor prints function names and source lines right below the backtrace:
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
monitor_filters = esp32_exception_decoder
build_type = debug ; keep debug info for more accurate decoding
Option 2: Arduino IDE
Arduino IDE 2.x no longer supports the "ESP Exception Decoder" plugin from 1.8. Use the addr2line tool shipped in the board package, with the .elf file from that exact build:
- Find the
.elf: in Arduino IDE enable File → Preferences → Show verbose output during: compile, or use Sketch → Export Compiled Binary and open the sketch'sbuildfolder. - Run the command (the tool lives under
packages/esp32/tools/xtensa-esp32-elf-gcc/...; ESP32-C3/C6 use theriscv32-esp-elftoolchain):
xtensa-esp32-elf-addr2line -pfiaC -e sketch.ino.elf 0x400d1a3c 0x400d1b0d 0x400d2a55
The output looks like readSensor() at sketch.ino:42 and tells you the faulting function and line. Important: the ELF must match the firmware currently on the chip. Compare the "ELF file SHA256" in the error message with your file; any code change and recompile moves the addresses.
Reading the result
The first line is where it died (PC); the following lines are the chain of callers. Skip system library functions (esp_*, vTask*) and find the first frame that is your code: the cause is usually there, typically a pointer or index you passed down into a library.
Real examples and fixes
NULL pointer: LoadProhibited, EXCVADDR 0x00000000
// Wrong: bme was never created or started
Adafruit_BME280* bme; // = nullptr
void loop() { float t = bme->readTemperature(); }
// Right: create the object and check the result before using it
Adafruit_BME280 bme;
void setup() { if (!bme.begin(0x76)) { Serial.println("BME280 not found"); while (true) delay(1000); } }
Stack overflow
// Wrong: a big local array in a task with a small stack (loopTask defaults to 8 KB)
void handleUpload() { char buf[16384]; /* ... */ }
// Right: move it to static storage/heap, or enlarge the task's stack
static char buf[16384];
xTaskCreatePinnedToCore(worker, "worker", 8192, NULL, 1, NULL, 1); // 8192-byte stack
To see how much stack a task has left, call uxTaskGetStackHighWaterMark(NULL). The closer to 0, the more dangerous (in bytes under ESP-IDF on the ESP32).
Watchdog
// Wrong: waits forever for a sensor that may never answer
while (!sensor.ready()) { }
// Right: bounded wait that yields the CPU
uint32_t t0 = millis();
while (!sensor.ready()) {
if (millis() - t0 > 2000) { Serial.println("Sensor not responding"); break; }
delay(10); // delay() yields to other tasks
}
For work that is genuinely long, move it into its own task. Do not disable the watchdog just to make the error go away: the bug stays, you just stop seeing it.
Brownout: when the power supply is the culprit
The message Brownout detector was triggered is not a code bug. The ESP32 has a voltage monitor; when the supply dips below roughly 2.4–2.7 V (depending on configuration) it resets itself to avoid running incorrectly. During WiFi transmission the ESP32 can pull current bursts of 300–500 mA, so a weak supply sags:
- Try a short, good USB cable and a 5 V / 1 A or better charger instead of a laptop USB port.
- Add a 100–470 µF capacitor across the 3.3 V/5 V rail near the board.
- Heavy loads such as relays, pumps, motors and LED strips need their own supply with a common GND. See the plant watering project and the WS2812 LED light.
- The ESP32-CAM is especially prone to it: see the ESP32-CAM article.
- Avoid disabling the brownout detector (
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0)) unless you have ruled out the supply; the device can corrupt flash writes at low voltage.
More debugging tools
- Reset reason: print
esp_reset_reason()at boot. Values such asESP_RST_PANIC,ESP_RST_TASK_WDT,ESP_RST_BROWNOUTandESP_RST_POWERONtell you why the previous reset happened, which helps when the device is not connected to a computer. - Watch memory: print
ESP.getFreeHeap()andESP.getMinFreeHeap()periodically. A heap that shrinks over time means a leak (often from repeatedly concatenatingStrings). - Raise the log level: choose Tools → Core Debug Level → Verbose (Arduino IDE) or
build_flags = -DCORE_DEBUG_LEVEL=5(PlatformIO), and uselog_e(),log_i()instead ofSerial.printso you can filter by level. - Narrow it down: rerun with a minimal sketch and switch features off one at a time. The feature whose removal makes the crash disappear is the suspect.
- When you need to step through code: ESP32-S3/C3 boards have built-in USB JTAG that works with PlatformIO and OpenOCD for breakpoints.
Bugs worth preventing from the start
- Always check the return value of
begin(),malloc(),WiFiClient.connect()and sensor reads. - Check array bounds and use
snprintfrather thansprintf. - Share variables between ISRs and tasks with
volatile, a mutex or a queue. - Avoid
Stringconcatenation in long-running loops that run for weeks: use fixed-sizechararrays so the heap does not fragment. - Some GPIO pins behave specially at boot; read GPIO pins to avoid before blaming the chip.
- When the device is installed somewhere remote, prepare a way to ship fixes: OTA over WiFi.
Summary
- Read the error name and EXCVADDR first: near 0 means a NULL pointer.
- Decode the backtrace with
esp32_exception_decoder(PlatformIO) oraddr2linewith the matching ELF. - Watchdog means your code is blocking; brownout means a weak supply; stack canary means a stack overflow.
- Print
esp_reset_reason()and track the heap to catch faults that happen when you are not next to the device.