Watchdog Timer for UPS Hat – How does it work?


I have a few questions regarding the UPS Hat watchdog timer functionality. Is there a way to make it initiate a soft shutdown after the timer expires? I’m concerned about having it do a hard shut down on a product that will deployed in the field which could corrupt the SD card of the Raspberry Pi. Any further documentation on the watchdog timer and how to configure it would be very helpful.


Watchdog is a power software dependent function. If the power_agent service shuts down or freezes in any way, it restarts the Raspberry Pi at the end of the watchdog interval value set. You can configure it on or python API.

Thanks for the response @ensar. So the watchdog signal is sent periodically by the power_agent service to the Power HAT’s microcontroller (that is, when the watchdog timer is enabled)?

What I’m trying to achieve is this. I want to run a python program continuously in the field, and ensure that it will automatically restart in the event of an error. Occasionally, I’m encountering a bug in one of the libraries that causes a segmentation fault, which requires that I restart the Raspberry Pi to avoid further issues. I wanted my python script to be responsible for sending the watchdog signal so that if the program crashes (and cannot be restarted by systemctl for whatever reason) that the watchdog timer would expire and reboot the Pi.

I’ve used SixfabPower class in the power_api to change the watchdog settings, per the API documentation, which appears to work. Can I just disable the power_agent service and have my script handle sending the watchdog signal?

Also, reiterating my question in the OP, is there any way to have the watchdog timer perform a soft reboot, or is only a hard power reset?

Yes, you can. After disabling the agent service, you can use it by sending the watchdog_signal command. If the signal is not sent to the MCU within the watchdog_interval time, it does hard_reboot. Also, get_watchdog_status should return 1 when active and the watchdog_interval can be set using set_watchdog_interval function.


1 Like

Do I have to install the power_agent first to be able to set the intervals, etc?

The API works fine for getting sensor data and setting most of the options. However, I’m getting errors when trying to set or get the watchdog_interval:

Traceback (most recent call last):
File “”, line 24, in
File “/home/asher/.local/lib/python3.7/site-packages/power_api/”, line 1864, in set_watchdog_interval
TypeError: ‘NoneType’ object is not subscriptable