Posted on December 13, 2013 at 5:55 pm
This is the PIR (Motion) Sensor Detector to add to your Raspberry Pi:
Create a script named sensor.bash in /root/ directory:
#!/bin/bash #Define the GPIO path GPIO="/usr/local/bin/gpio" #Define raspistill path RASPISTILL="/usr/bin/raspistill" #Define sleep path SLEEP="/bin/sleep" #Set GPIO mode $GPIO mode 0 input while true; do $SLEEP 1 #Wait until a movement is detected while [ `$GPIO read 0` = 1 ]; do #Save images to a folder with a numeric system INT=1 PATH="/root/" while true; do if [ -f "$PATH"image"$INT".jpg ]; then INT=$((INT + 1)) else break fi done echo "DEBUG: Movement detected... Creating image..." $RASPISTILL -v -q 100 -t 500 -o "$PATH"image"$INT".jpg $SLEEP 1 done done |
Set the right permissions:
chmod +x /root/sensor.bash |
Run the script:
cd /root ./sensor.bash |
Now walk in front of the sensor and then check the /root/ directory.
You should see an image file named image1.jpg 🙂
Updated on December 14, 2013 at 6:21 pm
Other Posts
- Route OpenVPN Connections Through Floating IP
- How to Configure a Floating IP in a VPS (Hetzner)
- Set OpenVPN to Listed on a Specific IP Address
- Bash Trim Leading and Trailing Whitespace from a String
- Bash Get Name of Ethernet Network Interface
- VPN Providers with Dedicated Static IP Address
- OpenVPN Iptables Rules
- WireGuard VPN Iptables Rules
Updated Posts
- AMD Chipsets & Graphics Card Drivers for Windows 7, 8, 10
- AMD Radeon 7400 Drivers for Windows 10
- How to pass custom command-line parameters in InnoSetup
- Add Desktop shortcut for all Windows PC users
- Programmatically create desktop icon with InnoSetup
- GeneratePress - a Lightweight WordPress Theme 2021
- InnoSetup disable DesktopIcon via command-line
- Use cURL to authenticate with JWT Bearer tokens