GauVeldt
Posts: 24
Joined: Thu Mar 14, 2013 4:46 pm
Contact: Website

Use RPi to control power on/off PC (ATX)

Tue Sep 08, 2015 6:45 am

I am hoping the needed circuitry is not too dificult:

The problem is as follows. I have a firewall/routing PC that also provides the wifi AP using a USB wifi long-range wifi antenna. The problem is the antenna goes down a lot. Simply unplugging it at the usb and replugging does not fix the problem since wlanap will not recover and restore wifi access after such a switch. Further just issuing a soft reboot instruction also doesn't fix the antenna since it never loses power (USB stays on) long enough to reset and the antenna is still down following the soft reboot.

Thus it looks as if the only solution here is to cause a full powerdown of the PC to make the antenna lose power then restart the PC after a short delay.

The most direct way to achieve this is to somehow wire a circuit allowing the Pi's GPIO ports to initiate the momentary contact power switch signal in the same manner that a (sometimes absent for a week or two) human finger might via the case's power button. While I'm at it I would also like to have the PC generate a signal to the Pi indicating it's powered (the Pi can then trigger the power switch momentarily if the PC's when it shouldn't be such as after a power outage).

Note: this PC has a Mobo for which I have no documentation for setting auto-on mode hence the need for the Pi to know when the PC is on or not on.

So there's two parts to the problem:

1. remotely control the momentary power switch of the PC using the Pi's GPIO
2. detect the on/off state of the PC at the Pi (also over GPIO)

PS: Unplugging the antenna's USB cable is impractical anyways since it cannot be performed when a human isn't around to perform the procedure :P

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

Re: Use RPi to control power on/off PC (ATX)

Tue Sep 08, 2015 8:20 am

Rather than negativity think outside the box !

Asus ChromeBox 3 Celeron is my other computer.

GauVeldt
Posts: 24
Joined: Thu Mar 14, 2013 4:46 pm
Contact: Website

Re: Use RPi to control power on/off PC (ATX)

Tue Sep 08, 2015 4:17 pm

fruitoftheloom wrote::?: viewtopic.php?f=44&t=51660
That post is attempting to use a power supply directly, not to control a PC's power via the mainboard's power pushbutton connections.

They aren't the same. The power supply itself uses a continuous switch, whereas the mainboard itself uses a momentary switch.

pestes
Posts: 1
Joined: Tue Sep 08, 2015 8:10 pm

Re: Use RPi to control power on/off PC (ATX)

Tue Sep 08, 2015 8:19 pm

The power switch on the PC is just a momentary switch -- you could easily interface a GPIO from the Pi to control a relay (many examples abound) to close that contact as if you were pressing the switch.

As far as detecting power from the PC, the ATX power supply standard has a pin called PWR_OK which goes to 5V when the power supply is in an on and ready, stable state. You should be able to use this pin to detect when the PC is on. Alternately -- is there an IP address on the PC that you could simply ping to determine if it is there, ie the wifi is working? If so, you could use that as an indicator to reset the PC, and then after some time, as an indicator to indicate that it is back online.

User avatar
DougieLawson
Posts: 38451
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Use RPi to control power on/off PC (ATX)

Wed Sep 09, 2015 9:03 am

Can you get a ssh session to the PC?

If you can then a shutdown -h now, halt, poweroff (if linux) or shutdown /t 0 /s (if Windows) will get it to a powered but dormant state.

If the ethernet LAN card supports WoL and is connected to your router then you can get it running again by firing a Wake-on-LAN packet at its MAC address.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

I'll do your homework for you for a suitable fee.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
r3d4
Posts: 978
Joined: Sat Jul 30, 2011 8:21 am
Location: ./

Re: Use RPi to control power on/off PC (ATX)

Wed Sep 09, 2015 10:04 am

GauVeldt wrote: The problem is the antenna goes down a lot.
I wander why :?:
And what make model this usb antenna , what OS it is running on ..
What the system reports when this happens.

Any way sound like you are all ready working towards some sort of unconventional sloution !

GauVeldt
Posts: 24
Joined: Thu Mar 14, 2013 4:46 pm
Contact: Website

Re: Use RPi to control power on/off PC (ATX)

Wed Sep 09, 2015 2:04 pm

r3d4 wrote:
GauVeldt wrote: The problem is the antenna goes down a lot.
I wander why :?:
And what make model this usb antenna , what OS it is running on ..
What the system reports when this happens.

Any way sound like you are all ready working towards some sort of unconventional sloution !
just quits. lsusb no longer can see the device. my guess is the onboard controller is flakey and crash.
nothing short of cutting power to it gets it working again.
warmboot does not fix the antenna still won't show in devices
pull the usb cord then reboot could fix but that needs a human present.

what I want to duplicate with the Pi is this procedure that always works:
1. hold power button in for 3 sec. (shuts off PC)
2. release.
3. wait 10 sec.
4. push power button momentarily. (turns on PC)
5. release.

Steps 1,2,4,5 involve some way of duplicating in circuitry interfaced to the GPIO the function of the PC power pushbutton.
A relay could do it but maybe a transistor or two can do the same job solid state?

If I connect one of the non-standby 5V lines off the PC to act as a signal (it could be optocoupled to a 3.3VCC line and then fed to a GPIO line as input) I can also add as an additional feature the ability for the Pi to detect if the PC is on and catch something like a power outage having turned the PC off (old mobo with no manual on how to enable autostart) and perfrom steps 4+5 to turn the PC back on.

Edit: My thoughts on unconventional would be duct taping or epoxying the usb plug onto a solendoid/spring to plug and unplug it with the Pi then issue a reboot command to the PC but of course that requires opening a 24/7/365 SSH hole in IPFire

User avatar
r3d4
Posts: 978
Joined: Sat Jul 30, 2011 8:21 am
Location: ./

Re: Use RPi to control power on/off PC (ATX)

Wed Sep 09, 2015 8:59 pm

GauVeldt wrote: lsusb
OK :!: So your running linux *hands in the air* :)

>>Nothing short of cutting power to it gets it working again.

I guess this means you have tried with modprobe removing/reloading the wifi module/driver?...

GauVeldt
Posts: 24
Joined: Thu Mar 14, 2013 4:46 pm
Contact: Website

Re: Use RPi to control power on/off PC (ATX)

Wed Sep 09, 2015 11:56 pm

r3d4 wrote:
GauVeldt wrote: lsusb
OK :!: So your running linux *hands in the air* :)

>>Nothing short of cutting power to it gets it working again.

I guess this means you have tried with modprobe removing/reloading the wifi module/driver?...
FYI: it's a signal king (made in china) USB long range wifi antenna connected to a PC running IPFire running as an AP via wlanap

a warmboot and hard reset results in a similar reloading of the drivers and doesn't fix the problem.
when the system comes back up still no antenna showing up in lsusb.
the crash happens internally in the antenna hardware and the only way to reset it is cut the antenna's power
only two things do that: unplugging the usb cable or powering down the PC

User avatar
r3d4
Posts: 978
Joined: Sat Jul 30, 2011 8:21 am
Location: ./

Re: Use RPi to control power on/off PC (ATX)

Thu Sep 10, 2015 3:15 pm

GauVeldt wrote: the crash happens internally in the antenna hardware and the only way to reset it is cut the antenna's power
only two things do that: unplugging the usb cable or powering down the PC
hmm

I cant say i have any in-depth or tbh any real understanding beyond 'changeing the "state" of a switch' but still perhaps the link below is some use
/proper-usage-of-a-mosfet-to-control-usb :?: it appears to be a different alternative method to the spring ect

http://pintant.cat/2012/05/12/power-off-usb-device/ - i guess this is the sort of like the spring method you mentioned ?


**

Return to “Interfacing (DSI, CSI, I2C, etc.)”