Tag Archives: camera

Dynamically control PiCamera record length: motion sensor fun with the Raspberry Pi

One thing I’ve always wanted to do with my Raspberry Pi was to build a trail camera, and when the Pi Zero was released with a camera port I thought that it was about time I stopped wanting to do it and actually just do it.

It took a while to get parts delivered from various places, but eventually in the last week or so I have finally built a trail camera. I’ll probably post more about that at a later date, but the most intriguing part for me was the programming…

Most of the trail cameras I had seen on the internet that people had built would either take a photo when a PIR sensor was triggered or would take just time lapse photos all night. Neither of these solutions really appealed to me. What I wanted was a video, and more than that I didn’t just want a video to record for a few seconds and stop. I wanted it to keep recording as long as there was movement triggered by a PIR.

In the end I came up with quite a nice small solution using Python and I’ve put it up on GitHub so feel free to fork and use or improve.

What I like about my solution is that when the PIR is triggered it will start recording for a definable number of seconds. If the PIR is triggered within that time it’ll just extend the record time by that many seconds again, and so on and so on until the PIR hasn’t been triggered for at least that many seconds at which point the recording will end.

Easy to use and exactly what I wanted. So feel free to grab my trailcam phython script on GitHub.

Did you like this? Share it: