RaspberryPi Power Management with a PIR Sensor

02Feb 2013

RaspberryPi Power Management with a PIR Sensor

by Craig Mayhew on Sat 2nd Feb 2013 under General
This is a simple guide to setting up a PIR sensor with a raspberryPI to send a wake-on-lan packet to one or more computers. The idea being that as I walk into my office, everything boots up or comes out of hibernation automatically.

SSH into the pi and get the latest python dev code:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python-dev
sudo apt-get install python-rpi.gpio

Install the Wake On Lan command:

sudo apt-get install wakeonlan

Plug in your PIR sensor using the 5 volt power line (pin 2), GPIO 7 for data (pin 26), the ground pin (pin 6). A word of caution, these pins should absolutely not be shorted out, they are also static sensitive.

RaspberryPI with a working PIR sensor:


Create a file called PIR-wake-on-lan.py on the raspberryPI and put this source code into it:
https://github.com/craigmayhew/scratchpad/blob/master/python/PIR-wake-on-lan.py

You will need to edit the file and put in your own mac address in place of "wakeonlan 00:00:00:00:00:00".

Try running the script.
sudo python PIR-wake-on-lan.py

Automation   RaspberryPI   PIR  


© 2005-2024 Craig Mayhew