Recently I posted the question - 'Who's been taking nesting material'... so we setup a trail camera and did a spot of long-lens lurking to document which birds were taking sheep wool added to the eaves above our 'Welly boot' bird nesting site.
Blue tit on wool
While not a great surprise, turns out it was Blue tits and Great tits. We caught these two on our Trail Camera at the Welly boot nest:
Over the last week or so I've been attempting to photograph my local badgers using conventional means (DSLR + telephoto lens) - the main problem being: 1) badgers are active at dusk / night, so light levels are low, 2) they are very timid so don't let you get close.
This is the closest I managed to get 'in person':
Badger - can you spot her?
Wanting to get better pictures, I cobbled together an improvised ground level webcam to see if I could get a more 'up-close and personal' perspective:
Cobbled together 'Garden-cam'
This is an unused robin nesting box, with a TP-link POE adapter and a Raspberry Pi model B with Microsoft Lifecam Studio webcam. All sourced cheaply from ebay. Connected via oudoor cat5 ethernet cable to a PC running iCatcher Console. The video stream is setup as described in this post.
I part set this up one evening last week, and left wires and components scattered about having popped in to eat - I left it on in the hope that something would wander past, and got this footage of one of my local badgers:
You can see her being a bit wary of the attached gear, but not to the point that she wont come and investigate. Later that night I stuffed all the components into the robin box to tidy things up. Since then, we have got nice views of the local wildlife as the following screen grabs show:
Passing fox: 4:30 am
Red deer fawn
Squirrel
Jay with mohican
In most of my bird boxes I've used the Microsoft LifeCam. I only recently acquired a LifeCam Studio ebay bargain - its much better in low light levels due to a bigger sensor size. It cant see in the dark, but is good for low light levels
In part 1 of this series, I outlined how a Trail Camera is made, and what might be used to make a home-brew version.
I've put together a basic functional trail camera, a very early prototype if you like.
I'm testing with a standard Raspberry Pi camera, not the IR version. I do have an IR version, but haven't got around to using it yet. For now, I'm limited to daylight triggering since I've not yet incorporated my IR illuminators since the box (tupperware - no expense spared) was too small to incorporate all the required bits.
This shows the prototype build so far (lack of hot glue gun skills notwithstanding). This will be hardwired into my home network, and uses power-over ethernet (PoE) hence the wire going to into it.
Simple front view showing PIR and RasPi camera with LDR detailed in insert
PiTrailCam ver1 - Inside
This is a cut-down version of the version I had planned out on my desk, which included a relay that triggered a separately powered IR LED array, which unfortunately does not fit in the box. Version 2 will probably be in a wooden box that is a bit more roomy and durable, and can accommodate a relay switch for the IR LED arrays.
I'm planning on directly splicing a hacked microUSB cable to the TP-Link power-out but bought the wrong cables...so have to make do with more bulky cables following this guide
Micro USB (male) to USB cable (female)
USB (male) to barrel power connector
Small prototyping breadboard
Female to male breadboard wires (various)
PIR motion sensor: Components, wiring and code described here
Mechanism to measure light level: code + components from here
Not strictly necessary in this build, but will be used to measure ilght level to activate IR led array in version 2:
1x 2.2 kOhm resistor
1x 1uF capacitor
1x Light Dependent resistor
Prototype board layout as follows. Note, I significantly slimmed this down to a small prototype board, but tend to use a larger breadboard with GPIO breakout at the 'drawing board ' stage. this also shows a possible layout that will incorporate a relay to operate a pair of IR LED arrays:
For now, I'm just using the PIR (motion sensor) and LDR (measure light level) aspects .
First image: Some things I'm very happy with, others not I'm less so..
The observant among you will spot something wrong with this image...
Whats really cool is that I've got the time and date stamp included at the top (erm, bottom?) of this image.
Timstamp - just to prove it....
How the image capture works
I've coded the scripting side of things in Python. I'm relatively new to this, so its a fun way of learning a new programming language, and to be fair most of this is mercilessly cribbed from other websites/blogs.
The Raspberry Pi camera is a described here, and can be used to capture video or stills, or both at the same time (may come back to this). You'll mostly see the two programs Raspistill and Raspivid referred to which are used to capture still images and video respectively. There are also several third party libraries built for it. For this application I've used the PiCamera library.
My limited Python skills will likely show here, but as I understand it this offers a way for python to directly access the camera hardware, versus using calls to external software (such as to Raspistill and Raspivid).
In your python code, you have the option of either calling Raspistill as follows:
By calling recordImage2() on a PIR activation event causes 3 images (image1, image2, image3) to be saved to a network location that I've mounted to a folder in /mnt, and am currently saving files there. Not sure how that will pan out if I switch to video though.
How to get text overlay working with picamera python library
I'm quite pleased that I have been able to get the text overlay working. The next thing to do is see if I can get a dark background behind the time & datestamp, as date and time in white over a white sky isn't much use to anyone.
At first I could not image overlay to work, and could not see why the instructions here did not work. Turns out I was running an version 1.5 of PiCamera, and need at least the current version (1.8 at this time). You can tell which version you're running by following these instructions here. You can update that by doing sudo update then sudo upgrade, you may need to update the Raspberry Pi's firmware : sudo rpi-update.
How to mount network drive to Raspberry Pi
For info, to setup network mounting you need to edit /etc/fstab as follows:
Ctrl & O, then Ctrl & X exits the nano text editor.
At a reboot, (or sudo mount -all) the network folder will be mounted at /mnt/SHARE
/XXX.XXX.XX.XX/SHARE/TrailCamPi = IP address of target PC with save file destination folder. Although its not strictly necessary, and you could setup a network share with no user password protection, I've set mine up with a dedicated user RasPi user + password on the destination machine, and pass those credentials with the mount command.
I'll sign off with another badger video from my commercial Trail cam, captured a couple of days ago:
Next step is to swop out the standard RasPi camera to the PiNoir, and add some LED arrays.
In a previous post, I've described my Trail Camera, which has been doing a sterling job of photographing the wildlife at the bottom of my garden. We've been introduced to deer, badgers, foxes, mice and occasionally my neighbours dogs who periodically escape and have a romp through the woods.
I've taken inspiration from the AfraidOfSunlight.co.uk blog. The author used a Raspberry Pi + camera + PIR combo to create a home-brew equivalent of a trail cam, with some great footage of birds. Check out the Kingfisher and Sparrowhawk clips.
Why do this?
First of all, a commercial Trail Cameras are not cheap. While mine is great, it has a lot of plus points but has a few limitations:
Commercial Trail cameras
Commercial Trail cameras: PLUS points
Simple interface - no tinkering required
Very long battery life (especially if stills setting used)
Durable - has lived outside for most of this year without problems.
Day vs. Night image capture issues taken care of with automatic IR cut-out filter (more later on that).
Commercial Trail Cams: Limitations
Simple interface - no tinkering required (did you see what I did there !?)
Limited to only stills or video - not both at the same trigger point.
Its a closed device - i.e. cannot communicate with/trigger actions on other devices
EXPENSIVE
My plan is to build one around a Raspberry Pi, which is an open-source linux-based mini computer, available for approximately £30. Along the way I'll go into detail for kit, configuration and any coding used, referred to from this point as "PiTrailCam"
What makes a Trail Camera ?
I've attempted to detail the various components that go into making a Trail Camera, and my thoughts about options for custom designs.
The glue that hangs it all together: Some sort of processing device. I'm going to use a Raspberry Pi mini computer (RaspPi). I've been tinkering with these for a while and there's loads of stuff out there that you can do. My projects have been limited mainly to video streaming nest boxes and timelapse movie creation, however this project will expand to include relays, voltage conversion and MQTT messaging (more later).
1) Camera - Several options here. Could use any/some of:
a) Raspberry Pi camera module
Small, compact wide community of users to troubleshoot. Limited to one RaspPi Camera board per Raspberry Pi, however could use webcam in addition. The PiNoir version has IR filter removed which opens up the option to do Night imaging + IR illumination b) Webcam
I'm currently using Microsoft Lifecam Cinema webcams in two bird boxes which stream video to my home network from which I can extract images/video, currently using iCode's iCatcher software (commercial). Video and/or still images can be captured dirently from webcams and saved to the Pi's SD card. c) Compact camera (with facility to control over USB).
The argument for this is the better optics and zoom of a compact camera. The ShallowSky.com blog combined the Raspberry Pi camera with a Cannon Powershot A520 to create a 'CritterCam'. This used the Raspberry Pi camera as a trigger (via image movement detection) with the better optics and zoom of a compact camera. The downside is that 'as is' they wont work for night shots since the cameras infra-red (IR) filter will be intact. While its is possible to hack your own, I'm not planning this. This particular model can be picked up relatively cheaply on ebay.
Power source (battery vs. wired)
'In the wild' TrailCams are usually battery powered. My commercial one takes 8 x AA batteries and also has a 12V DC in as an option too. I'm going to use wired as this is only planned to be used near a mains power source. In past projects I've used a power-over ethernet kit (PoE) from TP-link which means only need one cable is required to the device.
Illumination For night time imaging, we'll need some sort of artificial illumination. Options are visible light or infra-red light (IR). IR has the advantage of being less likely to disturb the wildlife. My commercial Trail Camera uses a ring of IR LEDs set around the camera. The downside my existing TrailCam is that the IR leds ring surrounds the camera, which means that at night all animals get the IR equivalent of red-eye. My design will use IR illuminators away from the camera to avoid this.
In order to use IR illuminators at night, you need a camera that has had its IR filter removed (This filter is called an IR bypass filter). There are several mods out there to the IR filter from various webcams, but I'm not going to attempt this.
Luckily, there is a version of the Raspberry Pi camera without an IR filter, called the Pi-Noir which I'll be using alongside some IR LEDs.
IR bypass filter
The downside of using the Pi-Noir is that I'll need to add back in an IR bypass filter for daytime imaging. While this isn't strictly necessary, there will be an odd colour cast to the daytime images without one.
Commercial Trail Camera: Night minus IR filter with IR LEDs on, Day time with IR filter in place
This is taken care of nicely in the commercial kits, they probably use a CCTV IR cutout filter module that integrates with CCD board cameras. I'm not yet clear how I'll do this but essentially I'll need to move an IR filter infront of the camera, or camera in front of an IR filter (my commercial trail cam does the latter for IR-illuminated night shots). I came across this IR bypass filter on ebay, designed for CCTV CMOS camera boards that I may try.
File Storage
Options: 1) On the Pi's SD card; 2) On local storage media (eg USB stick); 3) On local network.
My commercial TrailCam has an SD card slot. I have 2x 32Gb SD, I swop one in whe the other comes out. Although I've yet to fill one, its a bit cumbersome when I want to review footage as I have to physically swap cards, and copy images/video to my PC. Since PiTrailCam will be connected to my home network (remember I'm using PoE), I'll copy / save captured images/footage directly to my home network. I also want to get away from having to physically remove storage media since a home-brew affair may be less open-uppable!
Facility to live view captured footage/images
Commercial Trailcams often have an LCD screen which allows you to review captured footage. I plan to make my PiTrailCam accessible remotely over my network so won't need to do this.
Mechanism to detect movement
Passive Infared sensor (PIR)
A Trail camera is essentially useless without some means to detect movement.
This can be achieved either 1) Using software to compare sequential images for changes, or 2) Using physical sensors such as a passive infrared motion sensor (PIR) - the same thing that switches on your outside lights on when you put the bins out at night.
Water-tight enclosure
Various takes on this out there including cardboard, wood and plastic: from Tupperware to a more rugged case such as the Pelican 1040 case, as used in these commercial 'build your own' TrailCam kits). I'll probably go for a wooden one as I'm more comfortable working with wood (see my previous side-view nest box project, which remains water-tight to this day!)
Trigger one trail cam from another
One cool thing that I would like to do is cause one PiTrailCam to trigger another. This might be to capture the same event from different angles, or to utilise different cameras from the same viewpoint; or maybe to capture the progression of a subject from A to B to C. The bonus of the low cost of these devices is that several PiTrailCams can be built for the cost of a commercial one.
I plan to use MQTT to do this. This is machine-to-machine (M2M)/"Internet of Things" connectivity protocol, it sounds a bit complex but conceptually its quite simple. One machine publishes a message to specific 'listening' machines, the message might be triggered by a PIR activation event on PiTrailCam1. The listening machine (PiTrailCam2) can be configured to carry out a particular task (e.g. take a picture) when it receives the message from the first machine.
Over the next few weeks I'll post my progress. In my next post I'll expand on the trigger and image capture side of things, the prototype of which is merrily clicking away in my office when I move about, taking pictures of the back of my head....
In a recent blog post I described some of the wildlife (& cats) that frequent the bottom of my garden.
The most elusive of these is our badger(s). My trail cam has been positioned in the same place for approx six weeks now, pointing downhill across a patch of scrubby grass. In that time I've seen the badger several times, but its always been plodding away from the camera, downhill - Giving us the now familiar "Badger's Bum" view. I've a theory that he does a routine 'route', always in the same direction.
In an attempt to get a head-on video clip, I had the bright idea of moving the camera to the bottom of the hill, facing upwards, so I jury-rigged it to a post. The result is shown below:
Aarrrgh ! I feel a back-garden-conspiracy of sorts going on. There is a brief sideways glance, but no good view of the classic white stripes (the badger, not the band).
I've invested in a second high capacity SD card, and swop one out when reviewing footage on the other, so the camera is always on now in the hope of catching the elusive full face view:
I cant take the credit for this pic, but one can always hope
Last Christmas my lovely wife gave me one of these:
KeepGuard KG-680V, 8MP Trailcam
For the last few weeks, I've had it set up at the bottom of my garden, which backs onto woodland. Before this point, in the garden, we've had occasional fleeting glimpses of foxes and a badger once. When I forget to close the gate, we often get deer into the garden that like to eat all the flowers.
The aim was to see if we could get footage of any of these with the trail cam...
I set it up overlooking a clear 'passageway' through an overgrown patch of land:
It has two settings: image or video capture (not both). I've set it onto its highest resolution settings, which produces some nice images and the video is okay too. It has built in IR illuminators which should illuminate up to 15m from the camera. I'm using a high capacity SD card so can afford to leave it running for a long time
To begin with I thought this could double as a way to document the local cat population, 3 regular cat visitors cats so far..
Anyway, the wild animals caught so far:
1) Deer: We seem to have two regular visitors, we've called these two "Itchy" & "Scratchy" as they spend a lot of time doing just that. There's a lot of ticks in the woods, so I wouldn't be surprised it they're covered in the things...
2) Fox: This is pretty cool - I'm keeping an eye out for more of him/her ?
3) Badger: Our favourite yet. Unfortunately my only sighting is him/her? walking away - we're hoping to get better views over the next few weeks.
All in all, I'm really pleased with the results. Not quite the 'Big 5' but there's time for a Lion yet...
The main limitation as far as I can see with my trail cam is that I need 2x SD cards so I can swop cards when reviewing footage.
Pi Trailcam
I felt quite inspired by this Raspberry Pi trailcam variant on this blog, which I might at some point consider emulating. I particularly like the sparrowhawk.