Userguide

8
PROGRAMING THE WATCHDOG
After the first power up, the watchdog cuts off the power to Raspberry Pi, performs a self-check and
tries to turn on the power. The watchdog monitors the input power, the battery power and the power
supplied to Raspberry Pi. If a hardware error is detected, the watchdog flashes rapidly (5 times per
second) the on-board LED. If no error is detected, the LED flashes 1 time per second and the watchdog
enters the stand-by state, waiting to be activated.
The watchdog is activated when is addressed first time on the I2C interface. The default timeout is set to
120 sec. If the timeout expires, the watchdog will turn off the Raspberry Pi power for 10 seconds, then
turn it on again.
To disable the watchdog while setting it up, set the period to zero:
wdt -p 0
The watchdog can be reset either by writing a reset command from the command line ("wdt -r"), or by
toggling pin 23 (GPIO 11) on the Raspberry Pi. The commands can be issued from a memory resident
script or from cron. The script can have a resolution of 1 second, while cron can have a resolution of 1
minute.
1. RESET THE WATCHDOG FROM A SCRIPT USING THE COMMAND LINE
a. Use your favorite editor to create a script called wdt_reload with the following content:
#!/bin/sh
while :
do
wdt -r
sleep 60
done
b. Make the script executable:
~/wdt-rpi$ chmod +x wdt_reload
c. Launch the script memory resident:
~/wdt-rpi$ wdt_reload&
d. Set the default watchdog timer period to your desired value. In this example we use 120 sec. The
timer period needs to be longer than the "sleep" command in the wdt_reload file.
~/wdt-rpi$ wdt -p 120
2. RESET THE WATCHDOG FROM A SCRIPT USING THE GPIO INTERFACE
Same as above, with the following wdt_reload file content:
#!/bin/sh