Having some devices in a remote location is pretty cool. You can monitor stuff away from home, you can set up different VPN endpoints, you can collect data, an enormous amount of things. But theres one problem: What would happen if the device crashes and there’s no one there to troubleshoot or reboot?

This is where watchdog timers is useful! Watchdog is a small electronics that combined with software, they can be used to monitor and limit software execution time. And by using it wisely, you can leverage Watchdog timers to signal when something is malfunctioning or stuck and recover from it. This has been widely used on several applications, for example, Watchdog Timers were critical to help recover the Mars Rover a few years ago.

So, for this article, lets set up Watchdog to monitor a Raspberry pi device that is sitting few thounsand miles away and force a reboot when a fail is detected. Cool right? lets get to it!

Table of Contents

Activating Watchdog hardware on Pi

All Raspberry Pi devices come with a Watchdog Timer, but it is usually sat there unused. To activate it, you’ll need to open the following file:

sudo nano /boot/firmware/config.txt

and add the following lines to the end of the file

# Watchdog - On/Off
dtparam=watchdog=on

After that, reboot your Raspberry Pi and lets test if Watchdog has been detected

Installing Watchdog Software

Lets check if the devices are active and available to use:

ls -al /dev/watchdog*

You should see two devices

$ ls -al /dev/watchdog*
crw------- 1 root root  10, 130 Mar 17 11:42 /dev/watchdog
crw------- 1 root root 248,   0 Mar 17 11:42 /dev/watchdog0
$

You’ll notice that even though the rpi has only 1 hardware, you see two devices. This is just how this is implemented on Linux:

Watchdog0 (Hardware): Usually the hardware watchdog driver (bcm2835_wdt on RPi), which directly interfaces with the BCM2835 SoC to reset the system if it hangs. Watchdog1 (Software/Systemd): Often a software-based watchdog, sometimes managed by systemd or the watchdog daemon, used to monitor system load or network, rather than a hard freeze.

Ok, moving on, lets now install the sofware needed:

sudo apt install watchdog

After the installation is done, a few services will be added to your systemd.

$ ls -l /lib/systemd/system/ | grep -e 'watch' -e 'wd'
-rw-r--r-- 1 root root  834 Sep  3  2025 systemd-hwdb-update.service
-rw-r--r-- 1 root root  498 Apr 24  2020 watchdog.service
-rw-r--r-- 1 root root  593 Apr 24  2020 wd_keepalive.service

Lets configure it!

To stitch it all together, lets edit the watchdog configuration file:

sudo nano /etc/watchdog.conf

and uncomment the following lines:

max-load-1 = 24
min-memory = 4096
watchdog-timeout = 15
watchdog-device = /dev/watchdog
log-dir = /var/log/watchdog

A quick explanation for each of the settings: max-load-1 = 24 monitors the 1-minute load average. If the load goes above 24, the watchdog assumes the system is overloaded/hung

min-memory = 4096 monitors the minimum free RAM (in pages) required. If available memory drops below 1, watchdog triggers.

watchdog-timeout = 15 monitors if the OS or watchdog daemon freezes for 15 seconds

Starting and Enabling at boot

To start watchdog:

sudo systemctl status watchdog

And to automatically start at boot, just edit this file

sudo nano /lib/systemd/system/watchdog.service

Make sure this line exists:

[Install]
WantedBy=multi-user.target

And just install it:

sudo systemctl enable watchdog

Thats all!