Raspberry Pi "Intelligent" Power Switch

Thread Starter

aac52

Joined Dec 16, 2014
28
So this is probably not the neatest of solutions, but I thought it was an interesting project.

Just like a desktop PC or laptop, I want a single button that turns on, and off, the Raspberry Pi.

The requirements are as follows:
  • When off, a single press should apply power to the Pi, therefore turning it on.
  • When on, a short hold of ~3 seconds should shutdown the Pi correctly, then cut power after a short delay.
The delay in cutting the power is in case of a reboot rather than a shutdown.

Shutting down the Pi correctly will be handled via code running on the Pi, so for this just a 3.3v signal to a GPIO pin needs to be sent when the button is pressed/held.

There are a couple of different solutions you can buy already, but there are a bit expensive and I liked the challenge of trying to come up with a circuit myself.

The two I found are "Pi Supply" and "ATXRaspi". The latter seems to be very minimal, just a microcontroller, MOSFET, and resistors/capacitors. It's very elegant.

Now onto my not so elegant solution...



I'll try to explain my theory of how it works, or at least, how I hope it works.

To start with I'll mention that X1 is a probe that just lights up when the signal is high, this would actually be connected to a GPIO pin on the Raspberry Pi. LED1 and R2 are just there to show when the Pi would be getting 5v, so instead of those two components the Pi would be connected to ground and the relay.

S1 is a physical switch that you press to turn on the Pi, and hold to turn off.

S2 is simulating a GPIO output pin, which is high when the Pi is running, and low when the Pi is off.

When S1 is pressed it charges up C1 and keeps the relay energized so that the Pi receives power, when the Pi is running S2 would be closed (GPIO output high), therefore keeping the relay energized the whole time it is running. When S1 is held down, the code running on the Pi detects the input and gracefully turns the Pi off, once it has shutdown C1 should keep the relay energized for a few seconds, after which power will be disconnected from the Pi. Note that the collector of Q3 cannot be connected to the left side of D2, otherwise it would send the shutdown signal to the Pi.

This circuit is just theory, and I've only tested it using a simulator, but I think it should work.

Either way I think it has been an interesting little project, and hopefully I'll try building it for real shortly.

Does anyone have any thoughts on how it can be improved? Or perhaps I have made a mistake somewhere?
 
Top