Baguda
Posts: 7
Joined: Tue Sep 15, 2015 3:43 pm

Pi Power Controller Project (safe reboot anytime)

Wed Jun 29, 2016 11:06 pm

Hello Pi community!

Anyone who has had their OS freeze up on them knows the woes of cutting the power or grounding the run header. I recently started using a SSH to safely reboot the pi, even when frozen, and it got me thinking. Would it be possible to setup a peripheral circuit that uses the GPIO header interfaced with a controller to create a safe hard-reset button?

More specifically, can I setup the pi to mimic a SSH command (sudo reboot) when a physical button is pushed that is connected to a GPIO?

I figure that in the most complicated arrangement, I could use another raspberry pi (slave) that does nothing else but open a SSH with the main pi (master), and waits for a GPIO condition that will cause it to execute the reboot command to the master over the SSH.

Obviously I would prefer to not use an entire pi for this, and instead I would like to use a simple micro-controller circuit. Furthermore, it would be really cool if I could do it without an internet connection.

I am still very new to programming the pi, but I have a very extensive background in electronics. If anyone has any useful input or links to aid me in this venture then please feel free to share. I will try to develop this as described above, but I would love some help on simplifying it.
If we can come up with a simple and cheap circuit, then it can be added to any pi to make a safe way to force a reboot!

rzusman
Posts: 346
Joined: Fri Jan 01, 2016 10:27 pm

Re: Pi Power Controller Project (safe reboot anytime)

Wed Jun 29, 2016 11:58 pm

There are a million topics on this.
Search for Pi and UPS.

The typical way people shut the Pi down when the UPS activates due to a power failure is to monitor a port pin and issue a "sudo shutdown -h now" command.

I'm using supercaps and a microcontroller, but there are a lot of battery-based UPS circuits out there.

Baguda
Posts: 7
Joined: Tue Sep 15, 2015 3:43 pm

Re: Pi Power Controller Project (safe reboot anytime)

Fri Jul 08, 2016 3:00 am

Thank you for the reply. I never thought of ups issuing a shutdown command, I just thought they acted as an emergency backup battery.

I am not particularly interested in the back up aspect, but rather just in the I2C reboot/shutdown commands. Interestingly enough, this is also the part of UPS's that seems to be the least transparent.

I have seen dozens of simple battery back-up DIY UPS's online, but no instructions on how to incorporate a microcontroller to issue the I2C commands to the pi.

Any advice for this?

rzusman
Posts: 346
Joined: Fri Jan 01, 2016 10:27 pm

Re: Pi Power Controller Project (safe reboot anytime)

Fri Jul 08, 2016 3:26 am

You need to write a small program that listens on a port pin (or I2C, although that sounds way more complicated than necessary) for the correct shutdown signal, and then issues the shutdown command.

I use a 250mS square wave on a port pin to indicate that the power has failed. Then, my program does some cleanup, then issues the shutdown command.

mosespi
Posts: 508
Joined: Mon May 12, 2014 3:35 pm
Location: 34,-118
Contact: Website

Re: Pi Power Controller Project (safe reboot anytime)

Fri Jul 08, 2016 9:35 pm

The communications with the Pi is fairly easy.. I2C, UART, pulsing GPIO pins... lots of options there and has been done many times over.

You can use a micro-controller or discrete components, but for a complete solution you will have to 'reset' (or power down) the Pi somehow.. by actually controlling power to it, or the run header. I myself use a micro-controller and set it up so I can control power to the Pi.. this makes both an ATX type switch and hardware watchdog possible.

Regards,
-Moses
Power problems? MoPower UPS for the Pi
http://www.allspectrum.com/mopower/

paulv
Posts: 558
Joined: Tue Jan 15, 2013 12:10 pm
Location: Netherlands

Re: Pi Power Controller Project (safe reboot anytime)

Tue Jul 12, 2016 7:35 pm

Have a look here : viewtopic.php?f=37&t=145954&p

Or here, depending on your application : viewtopic.php?f=37&t=150358&p

Enjoy!

Return to “HATs and other add-ons”