This script uses pin GPIO4(7) to read data from Motion (PIR) Sensor, Any 5v and ground for PIR Sensor
- python3-gpiozero
Can be install via apt
sudo apt install python3-gpiozeroThis will install the script as service and it will run at boot
curl https://raw.githubusercontent.com/fire1ce/raspberry-pi-pir-motion-display-control/main/install.sh | bashcurl https://raw.githubusercontent.com/fire1ce/raspberry-pi-pir-motion-display-control/main/uninstall.sh | bash| Condition | Behavior |
|---|---|
| Motion while display is off | Turns on display for 60 sec |
| Motion while display is on | Resets the timer for another 60 sec |
| No motion > 60 sec | Turns off the display |
File
/usr/local/bin/motion-display-control.pyYou can change Data Pin of the PIR Sensor at gpio_pin value You can change Delay at display_delay value
Line
motion = Motion(gpio_pin=4, display_delay=60, verbose=False)Restart the service to apply changes
sudo systemctl restart power_button.serviceIn order to allow verbose debug change the following
File
/usr/local/bin/motion-display-control.pyLine
Set verbose value to True
motion = Motion(gpio_pin=4, display_delay=60, verbose=True)Restart the service to apply changes
sudo systemctl restart motion-display-control.servicesudo systemctl status motion-display-control.service
Thanks to Boris Berman for the script rewrite from function to classes

