I have been building a basic trail camera with a spare raspberry pi and my limited knowledge of python programming, I have run into an issue with the python script and I hope someone can help.
I am using a PIR sensor connected to a the Pi and falling or rising edge detection (I don’t remember which) to trigger the recording, which is working well, once I have started recording I am using time.sleep(30) then terminating the recording; however if an animal triggers a second motion event during the time.sleep(30) is there a way I can interrupt the script and reset the timer but keep the original recording going?
essentially, I would like a motion sensitive camera that could capture a cat running past (I end up with a 30 second long video of a blurry cat) or a deer hanging out for 30 minutes eating some grass (I end up with a 30 minute 30 second video of the deer)
I don’t have the actual code I have written with me but the camera recording part looks a lot like this (taken from an online tutorial)
any ideas how I can make the video length more dynamic?
import time import picamera with picamera.PiCamera() as camera: camera.start_preview() camera.start_recording('/home/pi/Desktop/video.h264') time.sleep(30) camera.stop_recording() camera.stop_preview()