Skip to content

Instantly share code, notes, and snippets.

@MarcScott
Created May 25, 2021 08:07
Show Gist options
  • Save MarcScott/005da5dc30952da30c4ac29c8f119be1 to your computer and use it in GitHub Desktop.
Save MarcScott/005da5dc30952da30c4ac29c8f119be1 to your computer and use it in GitHub Desktop.
pir activated birdbox camera
from gpiozero import MotionSensor
from picamera import PiCamera
from signal import pause
from datetime import datetime
from time import sleep
pir = MotionSensor(14)
cam = PiCamera()
cam.resolution = (1920, 1080)
cam.rotation = 90
first_motion = False
def cap_bird():
global first_motion
if not first_motion:
##Helps precent false positives on motion
first_motion = True
else:
timestamp = datetime.now().strftime('%A %d %b %Y %H:%M:%S')
cam.capture(f'/home/pi/bird_pics/{timestamp}.jpg')
first_motion = False
pir.when_motion = cap_bird
pause()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment