Script that connects a PIR Sensor to a webhook.
Clone the repo in a folder, install dependencies and then run in background
# Install requirements
pip install -r requirements.txt
# Run in background
# TODO: Find/Document a better way to do this
TRIGGER_URL="<webhook_url>" python main.py &
Otherwise add TRIGGER_URL = "<webhook_url>"
to an .env
file and the script will pick it up.
The script writes its own PID to pid.txt
so it can be used. Examples:
# Follow output of background process
tail -f /proc/$(cat pid.txt)/fd/1
# Kill process
kill -9 $(cat pid.txt)
The script was inspired by this Raspberry Pi Foundation article and uses their suggested example layout. The sensor needs 5v (Vcc) and Ground (Gnd), so PIN 2 and PIN 6 work well. Connect the sensor's output (Out) to PIN 7 (GPIO 4).