Raspberry Pi Hedgehog Camera
Lockdown 1.0 was a golden opportunity to learn some new skills, move out of comfort zones and into new realms of personal projects.
The Brief
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.
Approach
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.
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:
curl -L https://raw.github.com/pageauc/pi-timolo/master/source/pi-timolo-install.sh | bash
Third step – prototype an output
The big test was getting the camera to take and save some images.
I used the following command in Terminal:
cd ~/pi-timolo
./pi-timolo.py
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).
Disaster struck.
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:
cd ~/pi-timolo
./menubox.sh
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.
Outcomes
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.
In Conclusion
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”.
Further Reading
Hedgehog Info – https://www.hedgehogstreet.org/
Hedgehog rescue – https://www.pawprintswildlife.co.uk/
Pi-Timolo – https://github.com/pageauc/pi-timolo
Hedgehog Camera Guide – https://www.sconemad.com/blog/hedgeycam/
Raspi Online Purchases – https://thepihut.com/
Raspi – a beginners guide (digital or print)
Pact Coffee Voucher Codes
Looking for a Pact Coffee Voucher code? Here are a few I can recommend. It makes a great change; it’s tastes really good and comes in a load of different grinds and flavours. My favourite is probably the Bourbon Cream Espresso – but use the code to explore all the flavours Pact Coffee has to offer! Use the voucher code “PACTPERK” to get your discount now.
Like the Above? Below Are Hands Down the Best Blog Articles You’ve Ever Read
A Drive to Remember
A Drive to Remember: My TVR Adventure Across Europe If someone had told me a year ago, "Would you fancy [...]
Security Security Security
Increase Your Online Security with this Article Covid compliance forced physical shops to close and accelerated the use of [...]
Going Quantum
How to Use Amazons Quantum Computers If annealing, superposition, and qubits all sound like new Netflix films to [...]
Digital Currency: The Next Fintech Challenge?
With the likes of Dorthy Perkins and Topshop on the brink of collapse, what can governments do to stimulate spending [...]
Raspberry Pi Hedgehog Camera
Raspberry Pi Hedgehog Camera Lockdown 1.0 was a golden opportunity to learn some new skills, move out of [...]
Making Meetings More Manageable
"Never ask a question you didn't know the answer too". The first rule I was taught in advocacy at law school. [...]
5 Tips for Setting up Remote Agile Teams
During the recent Maxwell Bond Webinar (kindly organised by Riana Butler) on "Agile Project Delivery" I sat as a panellist. There [...]
Don’t Test The Testers
In the last 20 years of delivery I've lost count of the number of times I've heard "No, we don't need [...]
The Grand Bore
The room erupted in laughter when my colleague accidentally had a double typo in a sprint meeting and wrote “twat” instead [...]
Using Clouds to Help the Homeless
The tech ops guys were banging on about CloudFlare again, and I had no idea why. Did Cloudflare sponsor them? Surely it [...]
Digital Disappointment
Frustration increased as my colleague prodded her greasy index finger on my Macbook Pro’s screen and tried to swipe the web [...]
When Zero Talent Counts
Getting a highly qualified candidate with the most in-depth knowledge about your company’s chosen technology is the most valuable potential employee [...]
Grammarly and Linkedin, a Perfect Partnership?
This weekend I was told by a beautiful girl in a library how to bring my “A” game when writing Linkedin [...]
Do Project Managers Need KPIs
Key Performance Indicators, they’re not something a project manager needs to worry about right? They’re just a buzzy term used by [...]
Getting Team Buy In
What's the best way to get the most out of your team? Rule them with an iron fist and push them [...]
Delphix fixes Data Gravity
The internet is rapidly growing, and it's becoming more and more commonplace just to accept that every site you use pulls [...]
Maffins Wager
The accepted three pillars of project management are: On time, to budget and the right standard. Assuming the latter two are [...]
Failure is not an option fallacy
Many managers use the term "failure is not an option". One of the best pieces of advice I've ever heard came [...]
Context Switching in Programming
Ben Maffin People often talk about how interruptions disrupt their flow and the ability to produce good quality, consistent [...]
The XOX Method for Project Success
A common mistake made by project owners is to create a system which is either over engineered or is overly feature [...]
Live in 2 Days The MVP Conjecture
Getting a site up and running can take months or years for some companies. Can you do this quicker? What are [...]
What’s The Point to Pair Programming
Pair programming is a technique which essentially puts at least two developers on any given project at any time. So What's The [...]
Technical Debt, What is It
Technical debt is often an overlooked element of development but has far reaching implications on profit, delivery and quality of a project. What [...]
What Is Project Success
Like many questions in digital project management, this is a trickier to answer than most people initially think You'll find numerous answers, [...]
Leave A Comment