20

Can I use the Raspberry Pi's GPIO pins to make the Raspberry Pi act as a switch?

I would like to shut down, boot up and reboot my computer via hardware remotely. My idea was to take the PS_ON# pin from the front IO header, plug it in on some GPIO pin and then, when I want to activate the switch, pull the pin to low and thus toggle the PC PSU. Unfortunately PS_ON# uses +5V and I don't even know if I can simply pull a random GPIO pin to low.

-> Can I use the Raspberry Pi to short out a power source on a GPIO pin to GND?

techraf
  • 4,319
  • 10
  • 31
  • 42
d3rrial
  • 303
  • 1
  • 2
  • 6
  • 2
    If you're PC supports wake-on-lan, I would consider that first. – Jivings Feb 26 '14 at 06:39
  • Unfortunately this is meant for remote desaster recovery: If the PC crashes / turns off unexpectedly and does not respond to network traffic anymore, this should be a way to ungracefully reset the PC to working order, or boot it from a cold state. – d3rrial Feb 26 '14 at 06:48
  • 1
    @d3rrial: did you manage to finally have it working (the way you described, i.e. using the RST from the front IO header?) – WoJ Apr 18 '16 at 16:49

9 Answers9

9

Basically, yes, you can control other devices using RPI’s GPIO pins, however, there are many limitations which you should consider, especially the voltages and currents involved (you cannot source/sink much current directly from/to GPIO). Generally, I would suggest never to connect RPI to the PC directly, but using an opto-isolator to separate them.

I believe you could be interested in WtRPM: A Web-based (Wt) Suite to Power Up/down Your Computers, which is an article describing exactly the solution you are after, I guess.

Mormegil
  • 207
  • 2
  • 9
4

I'd use a serially controlled relay card to switch the power to the PC. Then, in the PCs BIOS set it so that it will boot whenever power is switched on. That way your power switch/reset circuit is completely independent of the PC, works with 3.3V and can even be used to control multiple computers.

Elmer
  • 161
  • 1
  • 1
  • 5
3

You can buy remote controlled power switches in various places. Like this one. Remote controlled power switches

Open up the remote, connect your Raspberry Pi's GPIOs, and you will have a safe, remotely controlled power-switch.

I am using a solution like this one, and it works quite well.

2

I don't know how does it exactly work for the PS_ON# but if you need to send in 5V / 0V you can do it with a raspi.

As you foresee the GPIO only send 3.3V witch are not enough. but you also have access to the +5V source in the GPIO header and you can user a transistor to toggle it (5V/0V)

Here you have an example on how to make 5V run through a LED with a raspi. You just exchange the LED by your pin.

http://www.raspberrypi-spy.co.uk/2012/06/control-led-using-gpio-output-pin/

javirs
  • 660
  • 1
  • 6
  • 19
0

Exactly what you are trying to achieve is unclear.

Regardless, unless you are running the Pi off the PC power supply, direct connection is very poor engineering practice. Ignore most of these answers. You need some kind of isolation such as a relay, opto-isolator etc.

Milliways
  • 59,890
  • 31
  • 101
  • 209
0

Playing with mains is dangerous - so best to use a kit designed for that purpose. Be careful with units designed in the US - their safety requirements are a bit different from UK and Europe.

Here is one designed with Uk safety features in mind:

http://www.sf-innovations.co.uk/mains-switch-widget.html

If you want to switch the mains ON and OFF remotely (without wires) then here is one http://www.sf-innovations.co.uk/dual-remote-relays.html

seggy
  • 9
  • 2
0

I would recommend simulating the case switch on your PC rather than messing with mains power. Use the R-Pi GPIO pins to switch a CMOS IC switch or transistor switch connected in parallel with your case switch then write a script to "push" the case switch for 1 second when you want to turn on your PC or 5 seconds when you need to hard reset it. You can power the Pi from the standby power wire (+5v) so it's always on

0

Why choosing the hardware path when you can remotely turn on the computer using Wake on LAN and using remote shutdown?

On Raspberry you can achieve this with two programs working from cli...

One from the samba package (sudo aptitude install samba):

net rpc shutdown -S workstation1 -U Administrator -w example.com

And the other is Etherwake (sudo aptitude install etherwake):

etherwake MAC-Address-Here

Pitto
  • 181
  • 1
  • 9
-1

well you can do that using opto couplers via basic transistors driving power relays

here is my homebrew , it is in romanian , not yet translated

http://forum.linux-romania.com/read.php?5,29