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
- A busy loop that never blocks: waiting for a flag or a pin with
while (!ready) {}. Wait on a semaphore, a queue or an event group, or at leastvTaskDelay(1)inside the loop. - Long work in one go: parsing a large file, a big computation, writing a lot to flash. Split it, and yield between parts.
- A high-priority task that never waits, so lower-priority tasks and the idle task never get the CPU.
- Arduino: a task you created on core 0 with an endless loop and no
delay(); or a request handler in ESPAsyncWebServer that blocks, which trips the watchdog on theasync_tcptask. Keep handlers short and do the slow part elsewhere.
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
- Remote access to an ESP32 without TLS: what it measured and what it costs
- Reaching an ESP32 web server from outside its network
- Updating ESP32 firmware over the internet, with rollback
- Guru Meditation Error: decoding the backtrace, and crashes from the field
- Remote logging: ESP_LOG without a serial cable
- Heap and stack monitoring in the field
- An ESP32 behind CGNAT, 4G or Starlink
- TLS memory usage on the ESP32, and how to reduce it
- Sharing an ESP32 sensor page with anyone, without port forwarding
- ArduinoOTA over the internet, with a rollback
- ESP32 remote access compared: port forwarding, ngrok, Cloudflare Tunnel, Tailscale
- esp_http_server slow? The 250 ms delay and the fix
- Before the first ESP32 ships: a field support checklist
- ESP32 exception decoder: a Guru Meditation backtrace to lines, in the browser