Lockdown 1.0 was a golden opportunity to learn some new skills, move out of comfort zones and into new realms of personal projects.
Hedgehogs are the first thing which springs to mind, right?
Maybe not, but I decided to set up a Raspberry Pi to capture if the hedgehogs we’d rescued were getting the hedgehog food they were being given, or if cats were eating it.
According to Harv Eker, author of the “Millionaire Mind”, the difference between “I know that” and knowing it, is in the experience.
How many people do you know who’ve bought one of these bits of kit and never used them? Pretty much everyone I know.
People, it’s time to stop watching junk TV, overcome the phone addiction and learn a thing – make the transition from “I know” to knowing.
A big thanks to Ryan Jones for pointing me in the right direction of the Hedgehog cam blog.
Read on to find out how I got to know the incredible Raspi and use it to capture IR timelapse.
Set up a night vision camera in the garden to be able to ascertain if:
The rescue hedgehogs were coming back; and
If a cat was eating the hedgehog food.
I’d spoken to Ryan at some length about his projects involving the Raspi. Indeed, most developers I knew had bought one but had never done any more than getting it out the packet.
What I lack in development knowledge I make up in delivery and general enthusiasm for seeing things through. This seemed a great way to put these into practice in a non-work environment.
The idea was to get an MVP sorted and work from there.
First step – get some idea of how the Raspi works.
The main issue here was having no idea really what a Raspi was or how it worked. I figured I’d need a mid-level spec version (4Gb), along with the Pi NoIR Camera V2. This was duly ordered from the Pi Hut; total order value circa GBP 135 (which included a case I’ve never used and the “Pi Hat” which will be the next project).
There is a guide out there put together by Gareth Halfacree. It cost a fiver, but I couldn’t order it as it was out of stock.
Somehow though I found a print-quality PDF floating about the internet. This gave me an excellent grounding in how to set up the Raspi. It describes the function of all the bits and pieces on the PCB.
The next issue was getting past initial setup – I was just getting a rainbow when plugging the Raspi into a 4K TV and switching it on.
Turns out, after doing some searching on the internet just use the other output port in the Raspi.
This is one of the main advantages of the Raspi. Chances are someone else has had the issue before you, so some simple searches on the net allow you to find the answer.
Read the guide right the way through to make sure you’re not missing something obvious (I got complacent a few times). The guide also makes sure you’re using the right terminology in your terms when searching for solutions.
After completing all the ‘Scratch’ tutorials and a number of the ‘Python’ ones, I felt in a good place to start mucking about with the camera.
Second step – leverage other people’s work and learn from their mistakes
Why start from scratch when you can build on other peoples work?
Andrew Wedgbury had already approached the hedgehog camera problem in his blog “sconemad” (see link at the end). I used this as a basis to start the project.
It’s worth saying at this point, do not be put off by the Terminal. It looks complex and very techie but it’s really not – it’s just you’re so used to the sexy GUI of the iPhone. Most of the time you don’t really need to understand why you’re typing something in straight away, just that it works. I had some experience with it when building a LAMP stack on Digital Ocean and following their guides – but nothing in a work setting.
Within the Raspi there are some neat features (which you need to switch on using either the terminal-based whiptail menu or the GUI), this includes allowing Secure Shell (SSH), Virtual Network Computing (VNC, see below) and the camera module. Both VNC and Terminal options adjust the Raspi config file.
Probably the best thing about the Raspi is the ability to control it remotely over WiFi. Initial setup is done with a keyboard, mouse and screen. Once completed it’s possible to either SSH into the Raspi directly or use VNC.
VNC is a sweet GUI which gives you the same view as you’d see through your TV / Monitor on your computer. It allows you to essentially bin off the peripherals and control the Raspi from anywhere.
Yup, the software will enable you to control the Raspi over the local network without creating an account. You’ll need an account for logging in via a different WiFi network to which your Raspi is connected. I’ve not tried the latter, but the former is formidable.
I set up the camera using the Gareth Halfacree guide (how to plug it into the Raspi board and enable in Rasbian config) and installed the pi-timolo ( PI-TImelapse, MOtion, LOwLight ) from Terminal using the following CURL command:
The big test was getting the camera to take and save some images.
I used the following command in Terminal:
It worked fine – taking a photo of me using my computer and saving it in the relevant folder (which can be navigated to using the GUI folder system). This was too easy. Next step was unplugging it from the TV and trying it out in the hall and logging in remotely (with VNC).
I got a system error message “Cannot currently show the desktop”.
This felt like a massive issue – as the whole point of VNC was for me to use the Rasbian GUI without it being plugged into the TV.
It can be fixed by changing the default resolution in the whiptail menu. The only issue is you need to do this when the monitor is NOT plugged in (otherwise you cannot select the resolution option in the menu, it just selects and then disappears).
This means unplugging the monitor from the Raspi and SSH’ing in, then going through the process of using the menu – it is so counter-intuitive as you’d expect it to work while being plugged in it took me about 4 hours before (after almost giving up) I tried this.
I initially thought there was an issue with the Raspi being corrupt and consequently used the neat NOOBS (New Out Of Box Software) reinstall process from the startup menu; this wipes the OS, and you need to start from scratch. Handy if you’ve made a mess of a config.
When using the Raspi remotely you can’t see the ‘preview’ of the camera as you can when it’s plugged into a monitor – there’s no way around this. Again, another couple of hours researching and a fresh installation before this became apparent.
As for the inbuilt motion detection functionality of pi-timolo, this works fine in good light – the system tracks movements and then takes a photo when you move over a certain point (these can be changed in the config).
The timelapse element is automatically set to 300 seconds (5 minutes). Again this worked fine out the box.
Fourth step – try prototype in the real world.
I set the Raspi up outside and tried to SSH in and start the camera. The message I got back was it was already in use. I tried this about four times, then gave up and used the VNC and the Terminal directly within the Raspi – I think I may need to look at the privileges with the SSH to fix this (e.g. maybe I’m not an admin).
In the wild, the motion detection hasn’t worked in the dark – maybe I need more light for the tracking system to be able to detect changes.
Unlike Sconemad I’ve been using ambient light which is enough for the newer version of the camera to pick up the surroundings. I’ve also avoided buying an IR set of lights for two reasons:
They looked expensive, and
The ones I have looked at have warned they can be harmful to human sight. I don’t want to burn the hedgehog’s retinas given they’re nocturnal and likely to be more sensitive than ours.
Using the whiptail menu in Terminal, I decided to change the default setting of the pi-timolo from 300 seconds to 1 second:
And got the following picture of the hedgehog having a drink. There’s a number of settings which mean you can’t take photos this quickly (such as time for the camera and Raspi to monitor the scene and work out exposure time).
I tried to play with these quickly as they are editable, but the camera stopped working so I had to revert them back to the original settings.
If you want to stop the pi-timolo application running simply use:
"Control + C"
in Terminal (it’s cleaner than unplugging the Raspi mid process).
Leaving the Raspi on, and letting it take loads of timelapse photos also means you can use the inbuilt pi-timolo timelapse video creator – run it from the whiptail menu (using the command above in Terminal) and it outputs a video of all the images you’ve taken (as long as they’re in their original folder) into a video folder.
Remember to also shut down the Raspi properly. I just pulled the plug a few times and had to go back and start again with NOOBS when the OS became corrupt. Not as bad as reinstalling Windows, but still 20 mins you’ll never get back – when remotely closing down it looks like it takes about 10 seconds to finish before you physically switch it off.
Did I answer my initial questions with the MVP?
The query as to the rescue hedgehog returning was probably a bit too vague. Indeed, a hedgehog was captured on the Raspi but was it the original one or are there more?
Is the cat eating the food? Again, not sure. It didn’t look like there was any food left for the cat after the hedgehog has been, and I’m fairly certain the cat can’t fit into the hedgehog cafe. I’d also not captured a cat around or in the hedgehog cafe with the camera.
Ideally, I need to get the motion detection working better and the Raspi out for longer. Short of tagging the hedgehogs with some IR paint, I’m not sure I’ll be able to tell if it’s the same one or a different one coming (without there being two in the shot or a significant difference in size, in the same space).
I want to use the Raspi with a battery system and also look into making better housing for it as heavy rain has threatened to turn the whole thing into a paperweight a few times. I’m tempted to put the camera actually inside the hedgehog cafe, but all this needs to happen reasonably soon before he hibernates for the winter.
The shot I took was a little blurry. I’ll try and move the camera a little further away, failing that it does come with an adjustment tool to you can change the focal length.
New goals for the Raspi Hedgehog Camera in Lockdown 2.0:
Create a more robust/watertight housing environment for the Raspi.
Decouple the plugged-in power supply.
Attempt to film inside the Hedgehog Cafe.
Improve the quality of the photographs by adjusting the focal length.
This has been terrific fun – and I’m going to start to look at how I can use the Pi Hat I bought with the camera as a separate project.
One final note, I 100% believe every kid in the UK should have the opportunity to learn how to use one of these, rather than be glued like addicts to their phone. Maybe this Xmas think about giving social media a miss and spend some time learning Scratch or how the Raspi works with the kids. Just a thought – you can both then honestly say “I know”.
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.