Dec 212012
 

Recipe for auto-reset Pi.

Take one Rev 2 Raspberry Pi, a few carefully selected slices of fresh Python, one GPIO port (’25 vintage, preferably), one relay (a twin pack is OK, but not AA), one Darlington array (leave the spikes on), a sprinkling of mixed wires and arrange it all carefully with a breadboard. It should end up looking something like this…

Circuit photo – self-resetting Raspberry Pi

I decided to take the P6 reset header one step sillier further. Just for fun. ;) The idea here is to use one of the Pi’s own GPIO ports to switch a relay (via Darlington array), which, instead of powering some mighty and powerful device, merely shorts two wires, which happen to coincide at the P6 reset header on the same Raspberry Pi. Thus instead of merely typing sudo reboot we can get a hardware level reset by going to a lot more trouble.

And since Dom, Alex and the crew have been working so hard to make this sort of thing possible, it would have been simply rude and ungrateful not to have tried it. ;)

Python Walkthrough

I tried to post the Python script, but WordPress mangled the indents. So here’s a screen grab from the video that shows what it should look like…

If you want the script, you can download it here but you might want to rename it from reset.py_.txt to reset.py.

If you want to learn about how the script works, I do a full walk-through in the video. :)

Possible Application

You could also use this idea to reset one Pi using another one, or even a different device. So if you imagine a scenario where you are away from your Pi and it crashes, you could use another one sitting next to it to perform a remote hardware reset. It might be useful for someone.

  13 Responses to “The Self-resetting Raspberry Pi”

  1. I don’t think all that extra hardware is necessary?
    http://elinux.org/RPi_Low-level_peripherals#P6_header
    You just need to connect P6-01 to ground to reset the Pi – if P6-01 is connected to 3.3V (which it is internally on the PCB) then the Pi won’t do anything (i.e. you should be able to just connect P6-01 to an inverted GPIO signal (whether you need the inversion or not depends if the GPIO signal is grounded during bootup)).

    Of course if you were doing this with 2 separate Pis then you would want to use the relay, to keep the 3.3V supplies from the two Pis isolated from each other.

    • I was just being silly with this one really Andrew. None of it’s necessary – just having fun doing a bit of “pure research” :)

  2. What would make a cool project would be a watchdog circuit.
    In our context, a watchdog would reset the Pi if it has become unresponsive
    To do that we cannot use the Pi to initiate the reset command, as when it has become unresponsive, it is…. unresponsive
    So, we could build a hardware circuit that would reboot the Pi, say every 5 minutes, but then we would have the Pi Reset the timer of the hardware circuit, say every 4 minutes.
    If the Pi goes belly-up, then it would not be able to reset the timer in the external circuit and by the latest 5 minutes later it would be reset by it.
    For this, typically a NE555 timer is used
    Keep up the good work with Rasp.ti. It is much appreciated ! :-)
    (ps: this is my first post; I don’t even own a Raspberry Pi (yet) )
    chris

  3. Hi Alex,

    Can you confirm if the P6 header is a hard or soft reset?

    I.e. Will it work even if the Pi OS is completely frozen with no response on software side?

    • It should do yes, because it resets at the BCM SoC level.

      When I did a pre-Uni year at IBM back in 1987-1988 the DP guys that kept the systems running used to call hitting the reset switch a soft reboot and hitting the on-off switch a hard reboot. That’s where my usage of those terms comes from.

      As far as the file system is concerned, I believe it is pretty much the same as pulling the plug. I find it more useful to bring the Pi back up from sleep than as a reset, but I rarely use it for either.

    • Will it work even if the Pi OS is completely frozen with no response on software side?

      If you think about it, that’s exactly what it does when you use P6 to ‘wakeup’ the Pi from the halt state ;-)

  4. Thanks. I was looking for a solution to reset my Orange Pi Zero I hosting Domoticz for my countryside home.
    The OPI zero hangs sometimes after a few weeks of months of constant use and I neede a way to reset it remotly.
    On the other hand, the OPI could be wired to reset the RPI too adding redundancy to the system.

Leave a Reply