I’ve just started exploring the Raspberry Pi and was intrigued with the Pi infrared camera module. I live in a somewhat remote area and have seen signs of various wild critters exploring around the house at night.
I had an idea of creating a night time game camera using a Raspberry Pi NoIR Camera Board with a PIR motion detector and an external IR LED spotlight to illuminate the area to allow the IR camera to capture video.
I started with something simple, but like all engineers, I kept adding more and more. So here is how it works:
This project uses a Raspberry Pi set up with WiFi in a headless mode. I can have my remote camera within the WiFi range so once connected I can start the program and retrieve the captured video files. There are lots of instructions on-line to do this so I won't try to rehash that here. I also installed the Raspberry Pi camera following the on-line instructions as well. Test the headless (if this is what you want) and the camera to make sure all works.
This project uses the Raspberry Pi NoIR Camera Board (infrared) for night time video recording when something is detected. The Pi NoIR Camera Board can also be used during daytime but since the IR filter is removed, the color is somewhat washed out. I built an external IR LED Spotlight that is enabled when motion is detected to illuminate the area while capturing video. Once the selected video duration completes the IR LED spotlight is turned off. The design also has an LDR circuit to detect whether its day or night. If it is nighttime and motion is detected, the IR LED spot is enabled and during daytime it is disabled. Connecting the external IR LED spotlight cable grounds a sense pin to detect if the lamp is connected to the camera. If the external IR Spotlight is not detected, the lamp output is disabled. After PIR detect, if night, GPIO pin 22 activates the relay which drives the high current IR LED's (If connected).
Capturing video also can take up quite a bit of disk space and could fill up fast. I discovered once I totally filled up the disk space and was unable to remote in and the Pi wouldn't boot. To fix this I added some code to measure disk space and abort the program if disk space is running out.
Step 1: Parts List
WiFi dongle (if desired)
1M ohm potentiometer
100K ohm resistor
1K ohm resistor
100K ohm resistor
Misc IO pin connectors, as required
Interconnect wire, as required
Enclosure to house the Pi and shield
Interface connectors, as required
20 high current IR LED’s
47 ohm, 5W resistors (qty 2)
Lamp enclosure (I used a trailer brake enclosure)
Step 2: Create the Shield
I created a shield to mount the relay, relay driver, PIR interface, LDR circuit, IR LED Lamp sensor and other IO.
I used the Humble Pi Shield: http://www.seeedstudio.com/depot/Humble-PI-Protot...
I dug around in my miscellaneous parts and used a 75468, high voltage, high current, Darlington transistor array. All you need is some driver with enough output current drive to set/reset the relay. I also attached a Visio file to show how I placed the parts and added the jumper wires as well as the schematic (Eagle format).
I used some spare socket pins and shrink sleeving to make connectors for IO from the board to the enclosure connectors, PIR and LDR.
Step 3: Build the Enclosure
I found a spare enclosure in my parts junk boxes. Something simple, but in the future I might replace it with a waterproof enclosure and experiment with battery/rechargeable power source.
I cut a hole in the enclosure so the PIR sensor would stick out and mounted it to the enclosure. I also used a panel-mount LED grommet to hold the LDR.
I cut another hole for the Pi Camera. I glued a Plexiglas window over the camera to protect the lens.
I installed a DB-9 type connector for the external IR LED Spotlight.
I installed a power connector to power up the whole thing.
Because I used a spare enclosure I had on hand, this enclosure doesn’t allow easy access to the SD Card and the WiFi dongle. But once you get it all working, you won’t really need to get to that unless something really breaks.
Step 4: Make the IR LED Spotlight
The IR LED Spotlight was fairly simple. I found some cheap high power IR LED's on EBAY spec'd at 700 mA peak. I created 4 strings of 5 LED's wired in serial (see schematic). I wired the two strings in parallel and attached a 47 ohm, 5W resistor to each string. I found an external plug in power supply that provides about 17 VDC. I selected a the resistors to limit the current so I don't burn out the LED's. You'll need to figure out the specs on your LED's, how many you want, what supply to use for the LED drive current and calculate the limiting resistors. There is no way the Pi can drive these by itself. The Camera Shield uses a relay so it doesn't matter what you use. Just make sure you don't drive more current than the relay can handle or the wiring you use.
You will also see a loop of wire between pins 8 and 9. I use this to detect if the lamp is attached. The CAM shield has a pull up resistor attached to the raspberry. When the cable is attached the sense line is pulled low, when not attached the sense line is pulled high.
I also discovered that by using a trailer brake lamp housing the red bezel does a great job in dispersing the IR "beam" to illuminate a larger area. The LED's I got have a fairly narrow beam. Without the bezel, the LED's provide a fairly tight beam.
Step 5: Upload the Program
Attached is the python file I created (I'm still trying to figure out GitHub).
The video files are saved with a.h264 extension. I use an FTP program to upload the videos to my computer. You can use VLC media player to view the videos.
I attached a few captured videos. One was a bobcat and another was a cat.
I added a few other things to the raspberry operating system to make things easier. I don’t have a real-time clock so each time I power up the raspberry pi I needed to set the date and time. I did this with the Sudo command to hard-set date and time on Raspberry:
sudo date -s "Mon Aug 12 20:14:11 PST 2014"
I also wanted to disable the Raspberry Pi camera LED so it wouldn’t alert whatever I was recording.
To disable the Camera LED, modify: /boot/config.txt And add the following line:
I was thinking to make the whole thing battery powered so I did find I could save ~20mA by turning off PAL/HDMI outputs by changing config.txt by adding:
Step 6: Wish List
I have a few other ideas to improve the camera. I might work on some of these and I'll update as i upgrade...
1. Save video as a more standard format (mpg, etc)?
2. Send files through WEB server
3. Use the motion program for day detection. Motion program detects movement by looking for pixel changes. You can also focus on specific a specific target area. This will help in daytime detection. The PIR detector works great at night, but can be somewhat sensitive in full light and can trigger on tree movement from wind, or other movements you might want to ignore (such as cars on a road, etc.). You can adjust your PIR detector sensitivity, but Motion would be pretty cool.
4. Optimize code – Use calls for repetitive tasks (start/stop video, disk size, etc.)
5. Use MUX to swap camera modules from day to night?? Can that work?
6. What would it take to make the system battery operated?
7. Add real-time clock module (if not able to connect to internet)
8. Add program to automatically re-connect to wifi when it disconnects
9. Have the program automatically start when booting (when you apply power).