esp32freertos

Solving FreeRTOS Task Watchdog Timeout on ESP32

3 September 2026

What causes this

The FreeRTOS task watchdog timeout on the ESP32 is a common issue that arises when a task fails to yield the CPU or complete its execution in a timely manner. This condition triggers the watchdog timer, which is designed to reset the system if tasks exceed their time slice. Key indicators of this issue include WDT reset messages and specific register values.

When a task takes too long, the watchdog will log a message similar to:

```

Task watchdog got triggered. The following tasks did not reset the watchdog in time:

- Task_name

E (12345) task_wdt: Task watchdog got triggered.

```

In the ESP32, the relevant registers include TIMG_WDTCONFIG0_REG and TIMG_WDTFEED_REG. The timeout is configured in the TIMG_WDTCONFIG0_REG, where a misconfiguration can lead to premature timeouts.

Within the ESP-IDF, the watchdog is managed through functions like esp_task_wdt_init() and esp_task_wdt_add(). These functions set up the watchdog timer and register tasks that need monitoring. If a registered task does not call esp_task_wdt_reset() within a specified interval, the watchdog is triggered, leading to a system reset.

Minimal reproduction

The following code snippet demonstrates a simple scenario where a FreeRTOS task exceeds its allocated execution time, triggering the watchdog:

```c

#include

#include

#include

void faultyTask(void *pvParameters) {

while (true) {

// Simulate a task that takes too long

vTaskDelay(pdMS_TO_TICKS(10000));

esp_task_wdt_reset();

}

}

void app_main() {

esp_task_wdt_init(5, true); // 5 seconds timeout

xTaskCreate(faultyTask, "Faulty Task", 2048, NULL, 5, NULL);

esp_task_wdt_add(NULL); // Add current task to WDT

}

```

Expected Serial Output:

```

Task watchdog got triggered. The following tasks did not reset the watchdog in time:

- Faulty Task

E (12345) task_wdt: Task watchdog got triggered.

```

The fix

To remedy this, ensure that tasks complete their execution or yield within the allowed time frame. Adjust the watchdog timer configuration or optimize task execution times.

Before Fix:

```c

esp_task_wdt_init(5, true); // 5 seconds timeout

```

After Fix:

```c

esp_task_wdt_init(15, true); // Increased to 15 seconds timeout

```

Alternatively, optimize the task to yield more frequently:

```c

void optimizedTask(void *pvParameters) {

while (true) {

// Perform task work

vTaskDelay(pdMS_TO_TICKS(1000)); // Yield every second

esp_task_wdt_reset();

}

}

```

How SerialDoctor catches this

SerialDoctor reads the serial output from the ESP32 and immediately identifies the watchdog timeout issue, pinpointing which task failed to reset the watchdog in time. By analyzing the logs and backtrace, SerialDoctor provides a clear root cause and suggests optimal timeout settings or task adjustments. Visit [serialdoctor.com](https://serialdoctor.com) to learn more about how it can streamline your debugging process.

Quick checklist

  • [ ] Verify task execution time is within the watchdog timeout limit.
  • [ ] Use esp_task_wdt_reset() appropriately in long-running tasks.
  • [ ] Consider increasing the watchdog timeout if necessary.
  • [ ] Ensure tasks yield the CPU regularly with vTaskDelay().
  • [ ] Regularly review task priorities and configurations for efficiency.

Seeing this crash on your board right now?

Connect it to SerialDoctor and get a root cause + code fix in under 3 seconds.

Try SerialDoctor free →