Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can I use the Raspberry Pi's GPIO pins to make the Rasperry 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?

share|improve this question
If you're PC supports wake-on-lan, I would consider that first. – Jivings Feb 26 '14 at 6: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 6:48
This question sets a new low for this site. Despite the fact that the question is rather vague, and shows little research it attracted a number of answers - which are either irrelevant, contain errors and have the largest collection of poor grammar and spelling I have found on this site. – Milliways Feb 26 '14 at 12:01
@Milliways A large number of answers...And I don't hesitate to agree. However, I think it would be more constructive for us to improve the question and answers rather than complain about them. – Jivings Feb 26 '14 at 18:00
@Milliways: "This question sets a new low for this site" I had exactly the same question. I have very limited knowledge in electronics and would love to build such a switch on a RPi. I expect such a site to provide answers to cross-disciplinary questions like this one. "...the largest collection of poor grammar...". Not everyone is a native speaker and knows that "either" and "and" are not used together in a sentence (speaking about grammar) – WoJ Apr 18 at 15:01
up vote 5 down vote accepted

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.

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer
Did you try Telldus USB? Really nice thing. – Pitto Jan 2 '15 at 12:11

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.


share|improve this answer

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.

share|improve this answer

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:


share|improve this answer

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

share|improve this answer
Thanks for downvoting without commenting! – Pitto Apr 22 '15 at 16:10

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


share|improve this answer
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – RPi Awesomeness Apr 16 '14 at 12:25

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

share|improve this answer

protected by goldilocks Sep 14 '15 at 17:53

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.