The Watchdog Timer Module connects to your Arduino or other microcontroller project and watches for activity on an I/O pin. If there is no activity for a predetermined period of time, the module asserts the RESET line on the microcontroller to force it to reboot. This can be a handy way to ensure your project restarts properly if it stops responding.

Your project needs to incorporate some extra code to allow it to periodically tell the watchdog that it's still alive.

Connections

The Watchdog Timer Module has four connections:

  • GND connects to GND on your microcontroller.
  • VCC connects to the operating voltage of your microcontroller, usually 3.3V or 5V.
  • IN connects to a spare I/O pin on your microcontroller. This example uses D2.
  • OUT connects to the RESET pin on your microcontroller.
Connect the module to your Arduino as shown below. You can choose a different I/O pin if D2 is already in use by your project.

    Note: Some older Arduino boards with pre-R3 headers don't have a connection for IOREF. In these cases you can connect VCC to the appropriate supply voltage for your Arduino: if it runs at 3.3V, connect VCC to 3.3V. If it runs at 5V, connect VCC to 5V.

    Example sketch

    The input (IN) connection on the Watchdog Timer Module must be briefly pulled HIGH in order to reset the timer. You can add a simple function to your Arduino sketch which does this for you:

    void resetWatchdog() {
      digitalWrite(2, HIGH);
      delay(20);
      digitalWrite(2, LOW);
    }
    

    Make sure this function is called more frequently than the timeout period of the watchdog. If the function is not called, the watchdog will trigger and your Arduino will reset. Note that the timeout period is approximate, so don't count on resetting the watchdog at exactly 4 minutes 59 seconds! You can reset it as often as you like, so putting a call to the reset function in your main loop is fine.

    Each time the watchdog timer module is reset you will see a green LED pulse on, giving you visual feedback of the activity. Likewise, if the module resets your Arduino it will pulse a red LED.

    Changing watchdog timeout

    The Watchdog Timer Module has two timeout options: 5 minutes (default) or 1 minute. To change the timeout to 1 minute, apply a solder bridge across the pair of pads at the bottom left of the module.