Code: Select all
import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(23, GPIO.IN) while True: if GPIO.input(23) == 1: print ("PC is powered on") else: print ("PC is powered off") time.sleep(10)
thagrol wrote: ↑Thu Jun 21, 2018 12:01 pmThe power LED isn't a good choice mostly for the following reasons:
When I had a need to detect the state of a remote PC I did it by a combination of testing if the OS responded to pings and monitoring the state of the PSU's 3.3v line (on the motherboard power connector). You could monitor the 5v line from a drive power connector instead via an optocoupler.
- Get the circuit wrong and you risk damaging the motherboard (expensive in both time and money to fix)
- Some motherboards pulse the power LED when the PC is in a "suspend to RAM" (aka sleep) state this will give confusing results.
- It doesn't tell you anything about the state of the PC's OS. THE LED can be on but the OS might have crashed or the BIOS/UEFI might be running, the boot might have failed, etc.
3.3v line on, no ping reply = PSU on but OS down
3.3v line on, ping reply = PSU on OS OK.
3.3v line off, no ping reply = PSU (and therefore PC off)
If you want details of that project, see here: https://github.com/thagrol/fakewake
Users browsing this forum: No registered users and 14 guests