Intro: Simple Raspberry Pi Camera Trap Made From a Food Container
"It seems to me that the natural world is the greatest source of excitement, the greatest source of visual beauty, the greatest source of intellectual interest. It is the greatest source of so much in life that makes life worth living."
- David Attenborough, English broadcaster and naturalist
Do you like to sit back and admire the beauty and wonder of the natural world while the birds happily tweet and sing their songs? You may also like the idea of seeing nature up close and personal without the need to disturb it. If so, why not consider making yourself a Simple Raspberry Pi Camera Trap!
'What is a Camera Trap?' you might ask.. basically it's a camera with motion sensing capability that triggers the capturing of still or video images whenever something comes into view (such as nature's wildlife!).
Camera traps commonly use a PIR to trigger the taking of a photo or the recording of a video. Unfortunately this can sometimes result in the the best camera shot being missed or the target disappearing altogether before the camera is triggered. With this camera trap we can solve that problem by doing away with the PIR and instead using a detection system that is based on pixel changes in the image. We can also capture the events that take place prior to motion detection (thanks to the capability of the software), which increases the chance of getting that perfect photo or video sequence.
With the unusually good weather we've been having here in Wales lately there has never been a better time to make it, and fortunately it's also a bank-holiday weekend so the perfect opportunity to throw one together (mostly from some bits I have lying around the house already).
Grab hold of a Raspberry Pi and rummage around the kitchen cupboards for a plastic food container (if you're married I recommend you check with your partner first, they may not appreciate you raiding the kitchen), and you can throw this thing together in around 30 minutes.
Tip: If you use the No-IR Pi Camera Module (without the Infra-red filter) and some IR LED's, you can make a camera trap with night vision capability.
To make things really simple we're using MotionEyeOS with the Raspberry Pi. It's intended for CCTV but it's perfect for our camera trap as it supports still images as well as video, HD quality recording, and it has the motion detection capability. Let's move on to the first step and find out what else you'll need...
Step 1: What You'll Need
To build this simple camera trap you will need the following items:
- Raspberry Pi- the Pi 3 Model B+ is recommended, but you can use any Pi (including the Zero).
- MicroSD Card- Use Class 10 for better performance and high capacity for more recording time.
- Pi Camera- I recommend the Pi Camera Module V2, but USB webcams will also work.
- Use a No-IR filter Pi Camera with Infra Red LED's for night vision capabilities.
- Portable Battery Pack with USB Outputs- Choose a high-capacity battery for longer run-times.
- Plastic Food Container- Use one with an airtight seal-able lid to help make it weatherproof.
Optional Items you may want to consider:
- Additional Camera(s) - for multi-directional recording.
- Note that the Pi only has one native Camera Module connection, any additional cameras will need to be connected via USB.
- Wire/Fabric mesh to cover the optional ventilation hole.
- USB HDD- adds extra storage capacity but will consume your battery faster.
- Rain shield - I used a plastic knife, now things are getting technical.
You'll require a small selection of tools:
- Philips Screwdriver.
- Hot-melt Glue-gun.
- Drill-bit(s) - I used a cone-cutter.
- Dremel Multi-tool (or equivalent)- not essential, but comes in handy.
- Sharpie Pen - or any other fine point marker pen.
Software and Downloads:
Step 2: Building the Camera Box
Building the Camera Box is real easy, just follow the basic steps below:
- Using your sharpie draw the outline of the camera lens on the wall of the container (including IR LED's, if using).
- Using the drill with the cone-bit, drill from the center of your outlines and cut-out the holes until you can no longer see the pen marks.
- Use the Dremel multi-tool to trim and clean up the holes, if necessary.
- If you're fitting the optional rain shield (or knife), cut it to size and secure in place with hot-melt glue.
- Attach the flat camera cable to the camera module (follow the instructions provided with your camera to confirm which way round it should be installed as it may vary).
- Use hot-melt glue to secure the camera module in place - try to avoid getting glue onto the module's components, this will make it easier to remove the camera from the box at a later date.
- Place everything in the box and see how it all fits :-)
Tip: Drill an additional hole in the box and cover with wire/fabric mesh to provide ventilation. If your box is likely to be left out in the sun for any length of time it is recommended that you allow your Pi (and particularly the battery) fresh air for cooling purposes.
With your camera box ready it's time to move on to setting up the Raspberry Pi..
Step 3: Setting Up the Raspberry Pi
If you are already familiar with the Raspberry Pi this step will probably be a breeze, but If you are new to the Pi I would recommend some additional reading. Take a look at the below:
Installing Operating Systems
Note: We are using a MotionEyeOS image, so there is no need to download Raspian.
To set-up your Raspberry Pi follow these steps:
2. Once you've downloaded the image you need to extract it, for this I use RAR.
3. Insert the MicroSD card into your computer and write the image file to it as described in the articles above. In my case I have Windows, so I used Win32DiskImager.
4. Once image writing is complete remove the MicroSD card from your computer and insert it into your Raspberry Pi, then power it on.
5. Once the Pi has powered on and booted up (usually takes around 30 seconds) it can be accessed via a web browser, you just need to find out its HostName or IP address then enter this into your browser's address bar. If you are unsure of how to do this I recommend this additional reading from Raspberry Pi: About IP Addresses.
Note: You'll want to connect an RJ45 ethernet cable from the Pi to the router for the initial setup, it will be easier to do this at in the first instance then set-up the Wi-Fi connection later.
Tip: An easy way to find your Pi's IP address is to access the web management console of your internet router. This is typically done by entering its IP address in a web browser address bar (e.g. http://192.168.0.1).
Step 4: Configuring MotionEyeOS
Okay so you've built your box, prepared your Pi's SD card, powered everything up and accessed the MotionEyeOS web console, so what now? It's time to tweak and configure MotionEyeOS to suit your requirements.
When you first attempt to log-in to MotionEyeOS it will prompt you for credentials, the default username is: admin and the default password is: --blank--.
For a complete guide on how to set-up and configure MotionEyeOS I recommend you read the HowTo guide, we will be covering the basics, but the web interface is fairly intuitive so you shouldn't have much trouble:
- I recommend setting a password for the two default accounts (Admin and User).
- Set the correct Time Zone so the media files have the correct time stamp on them.
- Enable the Wi-Fi and enter your Wi-Fi credentials so you don't need to hard-wire with an Ethernet cable.
- Set your desired camera framerate and resolution (I used 1-10 fps and 1920x1080).
- Set your file storage - leave as default if using the SD card, amend if using a USB HDD.
- You can choose whether to capture still images or video, or both simultaneously.
Tip: The interface includes a hover-over help-tip for every option and setting. If you don't know what something does just hover your mouse cursor over the (?).
As this is a camera trap we will be using the 'Motion Detection' feature. This allows a motion event to trigger the capture and recording of images and/or video. Motion Detection is achieved by detecting changes in the pixels of the camera image, subject to the various parameters that are customisable.
I am using the following Motion Detection settings, but I suggest you have a play around with the options until you find what works for you as every scenario is a little different.
- Frame Change Threshold = 1.5%
- Auto Noise Detection = Off
- Noise Level = 12%
- Light Swith Detection = 0% (disabled)
- Despeckle Filter = Off
- Motion Gap = 5 seconds
- Captured Before = 5 frames
- Captured After = 10 frames
- Minimum Motion Frames = 5 frames
MotionEyeOS also provides you with the option to enable a detection mask, this allows you to exclude areas of the image from motion detection.
Once you have finished making changes to the settings select the 'Apply' button, it will take around 10-20 seconds to refresh. Note that some changes will prompt for a reboot of the Pi.
Step 5: Deploy Your Camera Trap Box
Now that you're camera is all set-up it's time to deploy it. How you do this will largely depend on what you are trying to capture, so you may want to take some steps to hide the camera box.
I decided to cover mine with some tree cuttings, this should help it to blend in with the surroundings, we don't want the box to scare the wildlife off now do we!
Tip: As an alternative to covering in foliage you could cover your box in a vinyl camouflage wrap.
Be sure to cover as much of the box as possible but don't obscure the lens. If you are using infrared LED's for night-vision capabilities you also need to make sure you don't shade those either.
Once you are happy with everything, walk away and let your camera do the work.
I alternate my camera box between using a regular Pi Camera Module and the No-IR version (with IR LED's) to give my camera trap night-vision. I made an extra hole in the box to accommodate both cameras. I just swap the camera cable when I need to.
Note: To maintain accurate time stamping of your media files the camera box needs to remain connected to an internet enabled Wi-Fi connection. If one is not available or is out of range the camera will continue to record but the timestamps may not inaccurate. Also you won't be able to remotely manage it.
Tip: Remember to connect your Raspberry Pi to the battery pack before sealing and covering the camera box, otherwise you'll be starting over, Oops!
Step 6: And Finally.. See What You Caught
How long you leave your camera trap deployed will largely depend on the capacity of the battery you used and whether you have any additional items that consume power (i.e. IR LED's, USB HDD). In my case I get an average of around 2-3 days run-time before I need to retrieve it. Once you're ready grab your box and find out what you've captured. If you're lucky enough to be able to maintain Wi-Fi connectivity while it's deployed you can also check out your captures remotely (as long as your camera box battery hasn't given up yet of course!).
MotionEyeOS gives you the option of viewing the captured images and video direct from the web interface, which is rather convenient. It also allows you to download individual media files and save them to your device for viewing later and sharing.
If you need to download a batch of files in one go I would recommend a third party utility such as WinSCP or FileZilla. This will allow you to connect to your Pi using SSH and download the files using SFTP (SSH File Transfer Protocol).
Tip: If your camera trap has captured a large number of false-positives (i.e. motion detection is too sensitive) try adjusting the motion detection settings accordingly.
Thanks for reading, I hope you found the Instructable helpful. If you have any questions or comments please let me know, I endeavor to respond to as many as possible.
MotionEyeOS is the copyright © of Calin Crisan, many thanks to him for making this great software freely available. Visit the GitHub for more information and to support development of the software.