Showing posts with label USB camera. Show all posts
Showing posts with label USB camera. Show all posts

Thursday, 25 September 2014

PIR to control USB camera

One of the things I want to try out is automatic recording of birds which visit the bird bath so the idea was to use a passive IR movement detector to tell the RPi when to record a photo from a USB camera.

It took a couple of hours scouring the net to find all the information I needed along with lots of failed coding attempts but eventually I got the idea to work just as a test layout in the kitchen. Very few components are needed - the Raspberry Pi (B+ in my case), the USB camera and the PIR:
(clicking on a photo will open a larger copy)

IMG_0126

Of course a screen, mouse and keyboard were attached while coding.

Cobbling together several pieces of code from different sources resulted in:

IMG_0124

modules loaded:
GPIO to acces the pins
time to be able to add delays where needed
os to give access to fswebcam code

N is a numerical counter which increments each time a photo is saved and added as a four digit number to the file name.

IMG_0125

IMG_0127

Next will be to get the photos saved on a USB stick instead of the micro SD card.