Skip to content

ESP32 Watchdog Timer Causes Random Resets

DodaTech Updated 2026-06-26 1 min read

In this tutorial, you'll learn about ESP32 Watchdog Timer Causes Random Resets. We cover key concepts, practical examples, and best practices.

The Problem

ESP32 resets randomly due to the Interrupt Watchdog Timer (IWDT) or Task Watchdog Timer (TWDT).

Quick Fix

Wrong

// Default watchdog enabled. Long operations trigger reset.
ESP32 resets during long Serial.print() or network operations.
void setup() {
  disableCore0WDT();  // Disable WDT on core 0
  disableCore1WDT();  // Disable WDT on core 1
  // OR feed the WDT during long operations:
  for (int i = 0; i < 1000000; i++) {
    feedWatchdog();
    // do work
  }
}
No more random resets. Long operations complete successfully.

Prevention

Feed watchdog during long loops. Use esp_task_wdt_reset() to feed TWDT. Disable ISR watchdog for debug builds. Set longer timeouts for slow operations. Handle WDT in FreeRTOS idle hook.

DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.

FAQ

### What is the difference between IWDT and TWDT?

IWDT (Interrupt WDT) fires if interrupts are masked too long. TWDT (Task WDT) fires if a task doesn't yield within timeout. Both reset the ESP32.

How do I feed the watchdog?

Call esp_task_wdt_reset() in long loops. For Arduino, use yield() or delay(0) to let FreeRTOS feed the task WDT.

Should I disable WDT entirely?

Only for debugging. WDT prevents system hangs in production. Increase timeout instead of disabling.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro