Created
May 25, 2021 08:07
-
-
Save MarcScott/005da5dc30952da30c4ac29c8f119be1 to your computer and use it in GitHub Desktop.
pir activated birdbox camera
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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