Soft Power Button/Switch?


15 posts
by HylianSavior » Thu Jan 10, 2013 3:13 am
I would like to have my Raspberry Pi permanently connected to a power source. What is the best way to create a 'soft' power switch, so that I can shutdown from within command line, but start up from hardware?

Thanks.
Posts: 3
Joined: Thu Jan 10, 2013 3:03 am
by ++bahjatk++ » Thu Jan 10, 2013 10:07 am
Not possible. A reset switch is possible though.
you can use any simple on-off switch from old gadgets - which just connects or disconnects wires from the power source to the Pi,.
Posts: 36
Joined: Sun Dec 30, 2012 10:02 am
by Joe Schmoe » Thu Jan 10, 2013 10:17 am
++bahjatk++ wrote:Not possible. A reset switch is possible though.
you can use any simple on-off switch from old gadgets - which just connects or disconnects wires from the power source to the Pi,.


Best/easiest is just to leave it on all the time. It uses virtually no power.

But (seriously, folks...), on the latest boards, you can rig up a switch at P6 - such that pressing the switch will reboot the Pi. So, you could follow this sequence (I think - see below for caveat):

1) To shut down: init 0 (or whatever you prefer)
2) To turn on: Press button

Note: I think this will work, but I am not sure (having not gotten around to testing) that the reset button will bring it back from the power off state.
Never answer the question you are asked. Rather, answer the question you wish you had been asked.

- Robert S. McNamara - quoted in "Fog of War" -
Posts: 2250
Joined: Sun Jan 15, 2012 1:11 pm
by HylianSavior » Thu Jan 10, 2013 10:56 am
++bahjatk++ wrote:Not possible. A reset switch is possible though.
you can use any simple on-off switch from old gadgets - which just connects or disconnects wires from the power source to the Pi,.


Hmm, alright. Do you know if it sufficient to cut off power to the linear 3V3 regulator to cut power to the entire device? I plan on replacing the v_reg with a switching regulator, and I could put a switch in between.
Posts: 3
Joined: Thu Jan 10, 2013 3:03 am
by rurwin » Thu Jan 10, 2013 10:58 am
No it isn't. 5V is used by the USB/LAN chip and also of course by any USB devices.

See also: Wake from halt
User avatar
Moderator
Moderator
Posts: 2888
Joined: Mon Jan 09, 2012 3:16 pm
by jpow1985 » Thu Jan 10, 2013 2:29 pm
Hi,

Just been reading through this post.

I don't know if this is possible but sounds reasonable of the top of my head.

Can yo not just develop a script that includes "sudo Halt" parameters. This script is invoked when a closed circuit is detected on one of the GPIO.

I haven't used these pins yet so not entirely sure if this would work.

But sounds plausible.
Posts: 12
Joined: Mon Dec 31, 2012 12:13 am
by Joe Schmoe » Thu Jan 10, 2013 2:58 pm
The OP's requirement was to shutdown in software (literally: From the command line) and to reboot from hardware (button push).

The first part is easy. The second part should be possible either via Dom's method (see the link posted a response or two back) or via the new "Rev B" method (P6).

The middle part (step 1.5) is to power the board off (turn the red light off). That's the hardest part (but note that it makes part 2 moot, since then, when power is re-applied, the board will reboot)
Never answer the question you are asked. Rather, answer the question you wish you had been asked.

- Robert S. McNamara - quoted in "Fog of War" -
Posts: 2250
Joined: Sun Jan 15, 2012 1:11 pm
by rurwin » Thu Jan 10, 2013 3:06 pm
It is perfectly possible, it's just that nobody has actually done it yet.

I looked into this months ago, and found that the Halt process is scripted in bash, so changing it would be trivial. Similarly a task that cycles round every second or so checking the GPIO inputs and starting a Halt if the right conditions obtain, is well understood and not at all difficult. And the circuit is simple as well. See: http://soronlin.wikidot.com/power-switch
User avatar
Moderator
Moderator
Posts: 2888
Joined: Mon Jan 09, 2012 3:16 pm
by jpow1985 » Thu Jan 10, 2013 3:13 pm
Ahhh I Seee!

Yeah know I see the problem as my method would just stop the board at software level but not completely power off the board.
Posts: 12
Joined: Mon Dec 31, 2012 12:13 am
by poing » Thu Jan 10, 2013 3:38 pm
rurwin wrote:It is perfectly possible, it's just that nobody has actually done it yet.

I looked into this months ago, and found that the Halt process is scripted in bash, so changing it would be trivial. Similarly a task that cycles round every second or so checking the GPIO inputs and starting a Halt if the right conditions obtain, is well understood and not at all difficult. And the circuit is simple as well. See: http://soronlin.wikidot.com/power-switch


I'm working on it, and it's working (although I didn't update the post yet) :D http://www.raspberrypi.org/phpBB3/viewtopic.php?f=37&t=27911. I'm going to combine it with this: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=37&t=27911.
Posts: 1090
Joined: Thu Mar 08, 2012 3:32 pm
by piglet » Thu Jan 10, 2013 3:46 pm
User avatar
Posts: 531
Joined: Sat Aug 27, 2011 1:16 pm
by ksangeelee » Thu Jan 10, 2013 8:33 pm
rurwin wrote:It is perfectly possible, it's just that nobody has actually done it yet.


I've got a project on the go here, http://www.susa.net/wordpress/2012/11/r ... ontroller/ - that does this. It's come on a little bit further since I wrote the article, but what with Christmas etc., it's gathered some dust.

It acts as an I2C slave to control the power-state, and the RTC can (or more accurately, will in due course) allow the Pi to be woken at a specific time. The whole thing could be done with a much simpler PIC if the RTC isn't required, but the chip I've chosen offers so many potential features for a couple of quid.
Posts: 193
Joined: Sun Dec 25, 2011 5:25 pm
Location: Edinburgh, UK
by mongrol » Fri Jan 11, 2013 9:53 am
How's about this? I bookmarked this a while ago to integrate into my picade build.

https://github.com/gamaral/rpi-pwrbtn
Posts: 76
Joined: Wed Aug 01, 2012 2:43 am
by shawaj » Fri Mar 08, 2013 12:46 am
Hi,

Check out my Kickstarter...looks like it could be just what you want - http://kck.st/UVBXTE
Support The MagPi by purchasing printed copies from one of our retailers - http://themagpi.com/en/buy

Please share with anyone who is interested!
Posts: 62
Joined: Wed Oct 03, 2012 3:36 am
by RaspberryPaul » Fri Jul 26, 2013 12:23 am
Here's a simple MOSFET circuit for a soft power switch for the RPi. It applies power when you momentarily press a button, with another momentary button press it signals the RPi to shutdown and turn itself off (the RPi needs to read then set one of the GPIO pins), and forces the RPi OFF with a long button press. Raspberry Pi soft power switch
Posts: 12
Joined: Fri Jul 26, 2013 12:01 am