On/off switch

Have anyone seen or tried to make this?

As I noticed there where pins left over. (26 GPIO cable to 40 connector) I got the Idea to make an on/off switch for battery operated robots that is so small that it could attach to the robot.
This would give the option to have a push button that gracefully shuts down the Pi with a Python scrip and then cuts of the batteries without pulling the plug… …and turn it on with the same button.
It would be convenient as you don’t have to use SSH and then pull the cable

There are quite a lot of 5v on/off buttons on the market but I haven’t found a 9v version with battery connector.
I can’t see any problems doing that as there are small relays that can handle the current.
Here are the operate requirements:

PCB
9 -12V connectors or solder points
Cables to pins
Led to check that it’s down
Button

Iv’e got some pictures to illustrate:

Very nice!!

I’ve never done a switch that could do the power up, but I have done something based on this Instructable http://www.instructables.com/id/Simple-Raspberry-Pi-Shutdown-Button/ for shutdown. It was quite handy to have. I can see this could be quite useful to have.

Hi Cleo!
…but the main thing is that it would cut off the batteries without pulling the plug.
The other thing would be to make it sturdy enough to implement as a integrated part of the robot (aka PCB mount).

Cheers
Sebastian

Hey Zebulon, I think it might be hard to fully cut the power. Cleo’s method of fully shutting down the Pi is probably as good as it gets: the only way to fully shutdown electronic devices is with a mechanical switch.

Hi John! But that is what the relay do isn,t it.

Absolutely. A relay will turn the power completely on and off. But if you’re going to control this with the Raspberry Pi, you have a chicken and egg problem. The Switch turns the Pi off. The Pi turns the switch off. The Switch turns the Pi on. The Pi turns the switch on . . . .

So, which one do you turn off first?

Hi John! Great input. :slight_smile:
A agree on the paradox but… There is a walkaround within the circut.
I agree with you and sometimes simlicity is the best.
I think that I will combine two switches on a PCB. one push for the pi shutdown thowring in a led to show when it is off and then a switch for the batteries.
The main advantage is still two. first: No need to struggle with SSH and cables.
Two: putting it on a PCB for easy attachment to the robot with skrews or hot glue.

Now here is the relay solution:

“Latching relays keep their switched contact postion without power, this makes them very suitable for low power situations such as powering from batteries or where no permanent power is available. The best way to imagine a latching relay is a house light switch, you briefly push it to turn on (it remains that way with no power) until you push it to turn off in the opposite direction. Normal relays require a continuous voltage to keep the contacts closed, bistable versions do not, they “flip flop” between a “set” and “reset””

Now If I understand this correctly in my wicked mind:
Relay in position 1, Button pressed, Script turns down Pi
Circuit indicates that Pi is down or a time delay and changes the relay to position 2, cutting off batteries.
Position 2 has practicly created another circuit. Now button can take power to move the relay to position 1 and board and Pi is powers up.
Where do i go wrong?

Kind Regards
Sebastian