gwesseling
Posts: 5
Joined: Wed Apr 12, 2017 5:03 pm

Turn on and off your PC with a raspberrypi

Wed Apr 12, 2017 5:26 pm

Hello everyone,

(Before I start talking about this subject, I'm not sure if this is the right section to post this).

I would like to know if it's possible to startup and turn off my PC by using the raspberry pi wireless. I did a little bit of research and I saw some people do it through the power suplly. But that doesn't seem like a good idea (my opinion of course). If it's possible I like to do this through my motherboard (without destroying it). I want to do it like the power button on most of the pc only wirelless through an application. I will be really thankfull if you guys could help me out with the hardware part (include the raspberry pi) and which programming langauge I should use to program the application. And if you guys could tell me the risks that are coming with this idea, that would be great!

Thanks in advance,

~ Gwesseling

tpylkko
Posts: 383
Joined: Tue Oct 14, 2014 5:21 pm

Re: Turn on and off your PC with a raspberrypi

Wed Apr 12, 2017 7:10 pm

why would you ever want to do this? why would you not just 1) turn of the pc from the switch, or 2) have it turn itself off or 3) serve a web page form the pc that allows you to turn it off?

User avatar
SapphireSmith9
Posts: 6
Joined: Wed Apr 12, 2017 7:28 pm
Location: Australia

Re: Turn on and off your PC with a raspberrypi

Wed Apr 12, 2017 8:04 pm

Yes! It is indeed possible to do this without tampering with the dangerous power supply and it won't hurt the motherboard either!

Before you do anything, turn on your computer, then grab a timer and press and hold the power button on your computer and time how long it takes for it to force shut down. Write this time down somewhere for later.

Next, you'll want to take off the front panel and find the wires that connect to the power button. Either de-solder them, or simply give them the snip (or better yet; do the following in parallel). Then, connect one wire to the collector, and the other wire to the emitter (doesn't matter which wires). then connect the base of the transistor to the pin of your choice on your pi.

In whatever code you're using, simply apply a positive voltage to the pin you connected it up to! Here's where the stopwatch comes in. You may already know this; but every computer (apart from apple computers) has an emergency/force shutdown function that cuts all power from the motherboard. You'll want to have whatever application or program to, in the event you need the computer to force shutdown, apply a positive voltage for as long as it took you to hold the power button, plus an extra second or two to be safe.

Et Voila! Whatever you plan to do with this, it SHOULD work.

Note: I am not experienced with the PI itself, and only have a rough idea of how it works, but I am very familiar with computer hardware. If you have any problems, or want to clarify a few things, please don't hesitate to message me!
=====
Sapphire Smith

User avatar
SapphireSmith9
Posts: 6
Joined: Wed Apr 12, 2017 7:28 pm
Location: Australia

Re: Turn on and off your PC with a raspberrypi

Wed Apr 12, 2017 8:28 pm

tpylkko wrote:why would you ever want to do this? why would you not just 1) turn of the pc from the switch, or 2) have it turn itself off or 3) serve a web page form the pc that allows you to turn it off?
Who cares how practical it is? What does it matter? If it's an excuse to use the raspberry pi to hack something, why WOULDN'T you do it?

I'm still very new to the Raspberry Pi community, but (excuse my language) I believe dicking around with technology like this is the best way to learn. I got about half of all my hardware and software experience from messing around with computers and taking them apart, finding out what happens if I do this or that. Now, of course, I know much more thanks to online videos and such, but at the age of 10, I was able to use a computer even better than my dad's executive. All because I messed around with stuff like this.
=====
Sapphire Smith

tpylkko
Posts: 383
Joined: Tue Oct 14, 2014 5:21 pm

Re: Turn on and off your PC with a raspberrypi

Thu Apr 13, 2017 5:32 am

If you don't say why you want to do this, it is harder to answer your question. There are a million ways it could be done.

For example, let's say you want the pi to do it because you can automate the pi and keep it on 24/7 due to its low power usage. Then you could have a .timer on the RPI and have that log into a dekstop or laptop computer and command it to poweroff. But perhaps you just don't like the hardware switch on your desktop (maybe it hurts your finger or something) and want to connect a pi to it so that you can connect a keyboard to it and command it to switch the hardware switch for you. In that case the above solution would be useless.

User avatar
SapphireSmith9
Posts: 6
Joined: Wed Apr 12, 2017 7:28 pm
Location: Australia

Re: Turn on and off your PC with a raspberrypi

Thu Apr 13, 2017 7:27 am

tpylkko wrote:If you don't say why you want to do this, it is harder to answer your question. There are a million ways it could be done.

For example, let's say you want the pi to do it because you can automate the pi and keep it on 24/7 due to its low power usage. Then you could have a .timer on the RPI and have that log into a dekstop or laptop computer and command it to poweroff. But perhaps you just don't like the hardware switch on your desktop (maybe it hurts your finger or something) and want to connect a pi to it so that you can connect a keyboard to it and command it to switch the hardware switch for you. In that case the above solution would be useless.
I can only acknowledge your point there. I guess I felt you weren't helping at all and was ridiculing him/her. Gwesseling probably should have clarified, but I still think one should always go right ahead when trying anything new.
=====
Sapphire Smith

IanS
Posts: 234
Joined: Wed Jun 20, 2012 2:51 pm
Location: Southampton, England

Re: Turn on and off your PC with a raspberrypi

Thu Apr 13, 2017 9:11 am

Turning it on can probably be done over the network, unless you have a very old PC. Look at 'wakeonlan'. I have an always-on RPi providing a VPN tunnel into my home network and keep a list of MAC addresses for various other machines on that. Having connected to that I can then power on any of the more power-hungry machines which I do not leave always on.
Unfortunately there is no industry standard 'sleeponlan', although there are various applications for different platforms that provide this kind of functionality. Or you can do what I do, having started the PC and used remote desktop to access it, just shut it down through the remote desktop link. Shutdown is often missing/disabled from the standard GUI when using remote desktop, depending on the version of Windows, but you can still open up a command line window and use the shutdown command.

User avatar
RaTTuS
Posts: 10506
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Turn on and off your PC with a raspberrypi

Thu Apr 13, 2017 9:37 am

most pcs' can be shutdown with a momentary press of the power button
most pcs' can be swiched on via WOL
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

User avatar
bensimmo
Posts: 4187
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Turn on and off your PC with a raspberrypi

Thu Apr 13, 2017 10:21 am

As others have said, yes you should be able to.

A few things
Get your motherboard manual (post make/model up here if you wanted more info that you would like to learn)

Find the reset and off pin location on the board and then use the GPIO to connect to that.
Look to see if your motherboard usb can provide power when shutdown, you can power the Pi off that.
Look at WoL (wake on Lan) you may not need the Pi.
This will not turn it Off-Topic, it will be in a halted sleep type state.
To turn Off-Topic, you'll need to do that before the power supply.

Python on the Pi would do the job, as would others. Maybe with GpioZero python module doing the hard work of a button or say Android App or web App doing it remotely. ( Cayenne should be able to do it and more)

PiGraham
Posts: 3671
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Turn on and off your PC with a raspberrypi

Thu Apr 13, 2017 10:32 am

Another option could be a PiZW in gadget mode could act as a keyboard and issue a shutdown command. Possibly it could wake the PC by sending a key code. Possibly it could also act as a network interface and trigger WakeOnLAN (WoL)

Another option might be to act as a Uninterruptible Power Supply (UPS) controller which can send a shutdown to a PC over serial or USB.

gwesseling
Posts: 5
Joined: Wed Apr 12, 2017 5:03 pm

Re: Turn on and off your PC with a raspberrypi

Thu Apr 13, 2017 11:39 am

Thanks for the replies!

I do have a few question about the previous replies.
(I'm a noob at this, I hope you guys don't mind if I ask some questions)

Does WOL requires my PC to be in sleepmode?
because I don't want my PC to stay "on" in sleepmode all day. Just want it to be turned on and off. not got to sleepmode and wake up.

I do like the response about the power button. but I want to keep the power button. I just want to add a piece of hardware to my motherboard to turn it on and off (wireless). Maybe a wasn't really clear in explaining my idea. So I will put a image in that will explain it a little bit more.

http://prnt.sc/evxnph

So you can see I want to put the PI inside a room somewhere. but not in my PC itself.

I saw someone do this with Amazon's Echo using a computer IR. I know that not the samething as I want to do it.
https://www.youtube.com/watch?v=GCH1aun ... WL&index=1

Thanks in advance!

~ Gwesseling

Martin Frezman
Posts: 1020
Joined: Mon Oct 31, 2016 10:05 am

Re: Turn on and off your PC with a raspberrypi

Thu Apr 13, 2017 12:54 pm

My comments:

1) "Off" should be trivial. All you have to do is run some kind of server process on the PC side (*) and then make the Pi trigger some event that the server process picks up on and then issues the usual "shutdown" command to shut down and power off the PC. I can think of at least a half dozen ways to do this off the top of my head, with some kind of TCPIP server being the most obvious.

2) "On", on the other hand, is hard. Given OP's requirement that it be completely off - that is, not drawing a single milliamp of power - it seems like you'd need both a method of supplying power (i.e., turning on the mains) and some kind of robotics to reach out and press the power button once mains power is present.

3) In no case, though, does it seem like any PC motherboard modification would be needed or indicated.

4) As usual, it's hard to be any more specific without knowing what problem OP is actually trying to solve - i.e., what the details of the use case are. I do understand his reluctance to state those details, and I respect (and admire) his right to privacy on the matter.

Footnote: (*) As far as can tell, there's been no indication of what OS the "PC" is running, so I'll assume Windows. Not that it makes much of a difference in the discussion.
If this post appears in the wrong forums category, my apologies.

User avatar
bensimmo
Posts: 4187
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Turn on and off your PC with a raspberrypi

Thu Apr 13, 2017 1:27 pm

There are two off's
Which to you want, the normal PC off, which is not 'sleep' but a shutdown and off (it's still on, think of it as a standby mode). This is the normal PC off nowadays.
It still sits there waiting for the power button (or other things if you set it up like Wake on Lan, USB mice/keyboard movement).

Then there is Off-Off, turned off at the plug.

I still think the Pi in the PC connected to the Off switch is the best idea, have the PC set respond to this as a turn off (simple bios/OS setting).
You can trigger it to turn on as well.

You can still use the normal power switch either wiring that up direct as well (known as in parallel) or to a GPIO on the Pi and trigger the pi to then tell it to turn off/on.

The thing is a lot of this can be done without a Pi and just a few Apps, you motherboard maker may even have such an app (gigabyte for example).

User avatar
bensimmo
Posts: 4187
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Turn on and off your PC with a raspberrypi

Thu Apr 13, 2017 1:29 pm

If you want to do it at the wall, then buy a WiFi plug and use that, it's not pretty cutting power to a modern PC though.

PiGraham
Posts: 3671
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Turn on and off your PC with a raspberrypi

Thu Apr 13, 2017 1:43 pm

The power button oa a PC doesn't switch mains power. It's logic level and you could drive it with a transistor controlled by a Pi. The transistor could wire in parallel with the button contacts so you retain the original manual button.

You could probably run the Pi from 5V STBY off the ATX PSU and mount everything inside the PC case.

You could use software on the PC to safely shutdown and use a 433MHz remote control mains socket to cut power and turn it on again. Many options, lots of info

You can get IoT mains sockets that can be controlled from smartphone / web browser from anywhere with internet access. Something like WeMo Automated Switch Plug Socket.

User avatar
Burngate
Posts: 6101
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Turn on and off your PC with a raspberrypi

Thu Apr 13, 2017 3:55 pm

SapphireSmith9 wrote:Next, you'll want to take off the front panel and find the wires that connect to the power button. Either de-solder them, or simply give them the snip (or better yet; do the following in parallel). Then, connect one wire to the collector, and the other wire to the emitter (doesn't matter which wires). then connect the base of the transistor to the pin of your choice on your pi.
Surely it does matter which wire goes where. Transistors don't like being used inverted.
Also, you don't mention the fact that the Pi's ground has to be connected somewhere.

tpylkko
Posts: 383
Joined: Tue Oct 14, 2014 5:21 pm

Re: Turn on and off your PC with a raspberrypi

Thu Apr 13, 2017 8:00 pm

the pi could also automatically send a shutdown command (to shutdown gracefully) and control a hardware relay to fully unplug the computer and later turn it on.

Martin Frezman
Posts: 1020
Joined: Mon Oct 31, 2016 10:05 am

Re: Turn on and off your PC with a raspberrypi

Thu Apr 13, 2017 8:14 pm

tpylkko wrote:the pi could also automatically send a shutdown command (to shutdown gracefully) and control a hardware relay to fully unplug the computer and later turn it on.
You'd still need:

1) Some kind of server process on the host to execute the "remote shutdown".

2) Something to reach out and press the button to turn it back on (after power is re-supplied).
If this post appears in the wrong forums category, my apologies.

stderr
Posts: 2178
Joined: Sat Dec 01, 2012 11:29 pm

Re: Turn on and off your PC with a raspberrypi

Fri Apr 14, 2017 4:35 am

PiGraham wrote:You could probably run the Pi from 5V STBY off the ATX PSU and mount everything inside the PC case.
You could use software on the PC to safely shutdown and use a 433MHz remote control mains socket to cut power and turn it on again.
If the pi is going to control this and it is powered from the standby on the atx power supply, I don't think you can have both a complete turn off of the atx power supply and somehow having the pi turn it back on.

PiGraham
Posts: 3671
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Turn on and off your PC with a raspberrypi

Fri Apr 14, 2017 10:19 am

stderr wrote:
PiGraham wrote:You could probably run the Pi from 5V STBY off the ATX PSU and mount everything inside the PC case.
You could use software on the PC to safely shutdown and use a 433MHz remote control mains socket to cut power and turn it on again.
If the pi is going to control this and it is powered from the standby on the atx power supply, I don't think you can have both a complete turn off of the atx power supply and somehow having the pi turn it back on.

True, but the front panel power button is not complete turn off, else it could not turn the PC on. Complete turn off is a mechanical switch that cannot be electronically turned on again with zero power. The radio controlled mains sockets are probably the lowest power option, but obviously they do draw power for the radio and control.
WOL uses power, WiFi uses power. Every option uses power. If minimum power is the requirement don't use a Pi.

gwesseling
Posts: 5
Joined: Wed Apr 12, 2017 5:03 pm

Re: Turn on and off your PC with a raspberrypi

Fri Apr 14, 2017 5:10 pm

So.. correct me if I'm wrong.

But I can get a 433mhz RF Transmitter and Receiver like this:
https://opencircuit.nl/Product/10020/43 ... -ontvanger

and a PI 3,

Hook the transmitter up to the PI and hook the reciever up to my motherboard. Send a signal from the transmitter to the reciever through the PI. and make the reciever send an electric signal / electric pulse to my motherboard starting up my PC. And for shutting down send a longer electric signal / electric pulse to the motherboard forcing it to shut down.

Thanks in advance!

~ Gwesseling

fruitoftheloom
Posts: 21104
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: Turn on and off your PC with a raspberrypi

Fri Apr 14, 2017 5:28 pm

gwesseling wrote:So.. correct me if I'm wrong.

But I can get a 433mhz RF Transmitter and Receiver like this:
https://opencircuit.nl/Product/10020/43 ... -ontvanger

and a PI 3,

Hook the transmitter up to the PI and hook the reciever up to my motherboard. Send a signal from the transmitter to the reciever through the PI. and make the reciever send an electric signal / electric pulse to my motherboard starting up my PC. And for shutting down send a longer electric signal / electric pulse to the motherboard forcing it to shut down.

Thanks in advance!

~ Gwesseling
The only way to fully shutdown a Computer is to disconnect from the Mains :shock:
Retired disgracefully.....
This at present is my daily "computer" https://www.asus.com/us/Chrome-Devices/Chromebit-CS10/

PiGraham
Posts: 3671
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Turn on and off your PC with a raspberrypi

Fri Apr 14, 2017 6:26 pm

fruitoftheloom wrote:
gwesseling wrote:So.. correct me if I'm wrong.

But I can get a 433mhz RF Transmitter and Receiver like this:
https://opencircuit.nl/Product/10020/43 ... -ontvanger

and a PI 3,

Hook the transmitter up to the PI and hook the reciever up to my motherboard. Send a signal from the transmitter to the reciever through the PI. and make the reciever send an electric signal / electric pulse to my motherboard starting up my PC. And for shutting down send a longer electric signal / electric pulse to the motherboard forcing it to shut down.

Thanks in advance!

~ Gwesseling
The only way to fully shutdown a Computer is to disconnect from the Mains :shock:
Bu if you do that how do you turn it on again? Not by remote control.

fruitoftheloom
Posts: 21104
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: Turn on and off your PC with a raspberrypi

Fri Apr 14, 2017 6:41 pm

PiGraham wrote:
fruitoftheloom wrote:
The only way to fully shutdown a Computer is to disconnect from the Mains :shock:
Bu if you do that how do you turn it on again? Not by remote control.

http://www.maplin.co.uk/p/remote-contro ... ngle-n78ka


The OP is not clear how "off" he wants his PC !!
Retired disgracefully.....
This at present is my daily "computer" https://www.asus.com/us/Chrome-Devices/Chromebit-CS10/

PiGraham
Posts: 3671
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Turn on and off your PC with a raspberrypi

Fri Apr 14, 2017 6:52 pm

fruitoftheloom wrote:
PiGraham wrote:
fruitoftheloom wrote:
The only way to fully shutdown a Computer is to disconnect from the Mains :shock:
Bu if you do that how do you turn it on again? Not by remote control.

http://www.maplin.co.uk/p/remote-contro ... ngle-n78ka


The OP is not clear how "off" he wants his PC !!
But that's not zero power. For remote control on you can't disconnect from the mains. Something has to be on standby power of some sort.

Return to “Other projects”