Like all PCs the Raspberry Pi is likley to hang up during operation due to unexpected events not being catered for in the code. In an unattended application where the program automatically starts this can be a problem as there is no one around to restart the RPi. If there is no keyboard or HDMI monitor this is by power cycling. The Raspberry Pis internal watchdog timer has a poor reputaion - there are many comments about it being unreliable. This post presents a simple external watchdog timer.


Although there are dedicated power supply monitoring chips this solution uses components that are likley to be in most electronic hobbyists kit - based around the popular 555 timer.


Raspberry pi watchdog timer


The programme has to supply a Hi going pulse every few seconds. If there is no pulse for more than about 60 seconds the 555 output on Pin 3 will go low. This is coupled through to the on-board reset pin of the Raspberry Pi through a capacitor to issue a low going pulse which resets the Pi.


A capcitor is used here so that only a pulse going from Hi to Low will reset the raspberry Pi. A constant Lo voltage which is present while the raspberry Pi is starting up will have no effect.


If a shorter time is required then either reduce the value of R1 (1Mohm) or reduce the value of C1 (100 uF).


The LED pulses every time a Hi Pulse is issued to provide a visual indication to the user that everything is fine. The 555 timer does not easily provide a retriggerable monostable function that is required for a watchdog timer. Diode D1 is used to discharge the capacitor every time a pulse is received.


The reason the delay before a reset is set at more than 60 seconds is that the Raspberry Pi takes more than 30 seconds to start up.


Click here for a guide to setting the Raspberry Pi to autostart.


RPi reset pin


The image above shows the connection to the Reset pin of the Raspberry Pi.




Althogh the Raspberry Pi has an in-built watchdog timer, this has a poor reputaion. This watchdog timer is a reliable way of resetting the Raspberry Pi in remote applications where there is a risk of it hanging up due to the code not handling unexpected events correctly.