ESP32 "Task watchdog got triggered"

The task watchdog says some task ran too long without giving the CPU back. The task it names is the victim, usually the idle task; the culprit is the task listed as currently running.

E (10275) task_wdt: Task watchdog got triggered. The following tasks/users did not reset the watchdog in time:
E (10275) task_wdt:  - IDLE0 (CPU 0)
E (10275) task_wdt: Tasks currently running:
E (10275) task_wdt: CPU 0: sensor
E (10275) task_wdt: CPU 1: IDLE1
E (10275) task_wdt: Print CPU 0 (current core) backtrace

What it means

The task watchdog watches the idle task of each CPU by default (and any task that subscribed itself). The idle task only runs when nothing else wants the CPU, so when IDLE0 did not run for the timeout (5 seconds by default, CONFIG_ESP_TASK_WDT_TIMEOUT_S), some task on CPU 0 kept it busy the whole time. The line under "Tasks currently running" names it, and the backtrace after it shows where it was.

By default it only logs the message; if CONFIG_ESP_TASK_WDT_PANIC is set, it panics and restarts the chip.

The usual causes

Raising the timeout is not the fix

Making CONFIG_ESP_TASK_WDT_TIMEOUT_S longer, or unsubscribing the idle task, only hides a task that starves the rest of the system: WiFi, timers and the network stack wait while it runs. Fix the loop. See Espressif's Watchdogs guide.

When it happens in the field

On your desk the crash prints to the serial monitor. On a device in someone else's building it prints to a port nobody is reading, the chip restarts, and all you hear is that it "sometimes hangs". Pinscope keeps the panic reason and backtrace across the restart, sends them on the next connection and decodes them with the ELF of the build that crashed, so you get the function and line without anyone at the device. Free for three devices. How crash reporting from the field works.

Related errors: Interrupt wdt timeout · Stack overflow · rst:0x… reset reasons · Brownout detector was triggered. All ESP32 errors: the list. Messages and causes from ESP-IDF's panic handler and Espressif's Fatal Errors guide.

More