TL;DR: I am looking for options that will allow me to detect whether an app of the pi and/or the pi itself has been crashed or frozen; And if so, reboot the pi.

The setup:

I'm working on a hobby project where my goal is to automate the watering of my garden. The water tubing is connected to 12v magnet valves; who then are connected to some relays that i can trigger via the GPIO ports of the raspberry pi. So basically sending a signal on a given time; the relay will power the 12v valve to allow the flow of water.

I wrote a proof of concept program so far in Python that checks every 60 seconds if there is a task in the daily schedule it should execute. The task is basically only a ON statement on a given time, and an OFF statement somewhere later in time (to power GPIO ON/OFF). Additionally im running a small Flask web-server in case i want to sent some manual overwrite commands via my mobile phone. So this is basically the whole concept.

But now it came to mind: what would happen if 1 or more GPIO's are ON and then my program or even the whole Pi would freeze up or crash. In that case the valve would stay open until i would manually reboot the pi. Most likely i would notice once my garden has been turned into some wetlands after some hours... not to think how it will look after some holidays.

So this is where i am thinking what are my options to somehow monitor/detect if the program or the whole Pi has been crashed/frozen, and how could i then force it to reboot.

2 options that i thought of:

A. Get an second device and run the power of the pi trough this device. This device would "ask" to the pi once per hour "are you still alive?" and then the pi should send a response. when there is no response it would kill power for like a minute or so and this way force the pi to reboot. i assume something like this could be done by simply sending a request to the flask webservice im running, but i would need to buy and setup a second device.

B. get a cheap programmable power plug and just switch off power every night at like 00:00 and switch back on at 00:01

So far i am thinking of option B as it is very easy and cheap to setup. But this also brings me here on this page: Are there any other options someone can advice i should consider that i might not be aware off ? I couldn't think of any other myself, but i am hoping someone here may know another option to take into account ?

2 Answers 2


If you're running your Pi from an SD Card it's likely to die after a number of unplanned reboots (SD Card corrupted, often beyond repair) so in my experience running/booting from an SSD is much more reliable. At the end of the GPIO near the USB ports there are a couple of holes and above it says 'RUN'. If you're handy at soldering you can install header pins and can reboot the pi by shorting the run pins. You could easily add something external to do this for you but be aware this is a hard reset same as powering off and on.


First: Give your best effort to making the hardware fail-safe. For example, magnet valves and relays should be wired such that the water does not flow unless there is a positive signal from the controller (your RPi).

Second: Get a reliable watchdog timer that will give you the ability to either reboot or power down your system in the event your program, or your RPi, malfunctions/freezes/crashes.

Some details re the watchdog timer:

  • The RPi actually has a built-in watchdog timer (WDT), but it is said by some to be unreliable. I won't render an opinion on these statements - you can read the reviews and comments to decide for yourself.

  • If you do elect to give the built-in RPi WDT a try, this is a reasonable guide for setting it up.

  • If you find the RPi's built-in WDT falls short, there are several third-party WDTs available. Google will help you find them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.