Fix “Task watchdog got triggered” on ESP32
A task ran too long without yielding, so the watchdog fired. Usually a blocking while-loop, a long delay-free loop, or waiting on a sensor that never answers.
Community draft — report a mistake
What you see
E (10213) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (10213) task_wdt: - IDLE0 (CPU 0)
E (10213) task_wdt: Tasks currently running:
E (10213) task_wdt: CPU 0: loopTask
E (10213) task_wdt: CPU 1: IDLE1
E (10213) task_wdt: Aborting.
abort() was called at PC 0x400e2c3b on core 0E (10213) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time: E (10213) task_wdt: - IDLE0 (CPU 0) E (10213) task_wdt: Tasks currently running: E (10213) task_wdt: CPU 0: loopTask E (10213) task_wdt: CPU 1: IDLE1 E (10213) task_wdt: Aborting. abort() was called at PC 0x400e2c3b on core 0
The ESP32 runs FreeRTOS. A watchdog timer checks that tasks keep taking turns; when one task hogs a CPU core for too long, the watchdog reports it and resets the chip.
The message lists which task was stuck — usually loopTask, your Arduino loop().
Quick fix — try in order
- 1
Find the endless loop
Look for while (!something) {} loops waiting on a pin, a flag or a sensor. Add a timeout and a delay(1) or yield() inside.
- 2
Never block in a task without yielding
A loop that never calls delay() or vTaskDelay() starves the idle task, which is what feeds the watchdog.
- 3
Move heavy work out of callbacks
Web server handlers, MQTT callbacks and interrupts must return quickly. Set a flag and do the work in loop().
- 4
Check for a stuck sensor read
Libraries that wait forever for a pulse (pulseIn without a timeout, a DS18B20 conversion) can hang if wiring is wrong.
Why it happens
Which watchdog fired?
The Task Watchdog checks that each subscribed task (by default the IDLE tasks) runs regularly. If IDLE0 or IDLE1 did not run for about 5 seconds, something hogged that core.
Why does delay() help?
delay() on ESP32 calls vTaskDelay(), which lets the scheduler run other tasks, including IDLE. A busy loop with no delay never gives it a turn.
Do not just disable the watchdog
Turning it off hides a real hang. Fix the loop so it can time out.
Board-specific notes
ESP32-C3: Single-core chip: any loop that never yields blocks everything, including Wi-Fi.
Did this fix it?
Thanks — that helps us keep this page right.