To use a sleep and wake a computer, and turn on and off its monitors both with based on motion, and remotely.
Easily expanded to include lamps and anything that plugs into a wall!
To create a system to conserve energy, and provide convenience! You can sleep or wake your computer setup anytime, anywhere, great for using your computer as a home server, remote data storage (your own personal cloud), outsourced processing power, or whatever else you can come up with!
Using the PIR motion sensor
Simply put, a passive infrared sensor (PIR sensor) sends an output of high voltage when a heat source moves across its sensed "vision".
A more in depth explanation of how exactly it works, and the lenses involved can be read here with Adafruit.
How to sleep the computerThe Raspberry Pi remotes into the target computer through ssh, and runs the terminal command to sleep the computer.
In this case the target system uses systemctl, and the command "systemctl suspend" is run. Any other command can be subsituted.
How to wake the computerThe Raspberry Pi runs a command that sends a Wake On Lan signal to the target system, who upon receiving, wakes from sleep.
Putting it all togetherThe main script, AutoCompSleep.py forever loops every five seconds, each time checking for motion. If motion is detected, a timer is reset and, if the target system is asleep, it is awoken. If the timer runs down past zero, the target system is slept.
To sleep the target system, it calls computerSleep.sh
To wake the target system it calls computerWake.sh





Comments