Introduction: Raven Pi Security Camera
This plastic raven is enjoying a new after-life as a practical yet creepy security camera, the Raven Pi. It has a Raspberry Pi in its belly and a Pi Camera embedded in its neck, capturing HD video whenever motion is detected. At the same instant its piercing LED eyes light up, its servo-controlled head swivels back & forth, and it loudly plays either a random raven sound or an extract from Christopher Lee's reading of The Raven.
The security side is handled by the amazing MotionEye OS software, which is installed on top of a standard Raspberry Pi OS build. The raven even has its own rotary volume control, and its 3m USB cable lets it perch almost anywhere, ready to greet Halloween visitors or freak out passers-by at any time of year.
1x Plastic Raven
Raspberry Pi 2
USB WiFi Adaptor
2x Red LEDs
2x Plastic Beakers
Step 1: Severed Head
Before touching the bird I first got all of the code and electronics working, so that I'd know for sure how much space the components needed. First I soldered the two red LEDs in parallel on some jumper cables, so that they could both be controlled by a single GPIO pin (in this case GPIO 15).
Next I took a hacksaw to the bird, cleanly severing its head - it was very important to get a clean cut as the head would be swivelling later on. I then drilled through the original eyes and hot-glued red LEDs in the empty sockets.
The camera was next, a standard Raspberry Pi model - I drilled a hole for this in the neck and hot-glued it in place, having securely fitted an extra-long 50cm camera cable to it. With the head moving around all over the place I wanted to make sure there was plenty of slack in the wires.
Step 2: Caw Code
Before installing MotionEye OS I began with a standard Raspberry Pi OS build, as I wanted to develop the code needed for the sound and motion first. I started with three separate scripts, one for the servo, one for the LEDs and one for the random audio. Once I had all three working I combined them into a single Python script and saved it onto the Pi as raven.py.
The script I used is available on GitHub, you're welcome to use it but there's nothing too fancy in there, it controls an LED on GPIO 15 and a Servo on GPIO 18, randomly playing any sound files found in the /home/pi/Music folder.
Step 3: Beady Motioneye
I've used MotionEye OS in several builds before, and I have it running on several cameras around the house, but I've never installed it on top of Raspberry Pi OS before. Ordinarily you just download an image for your board, and magically the OS turns it into a full-featured network security camera, but the pre-built images don't include the OS features I'd need to run the script, control the servo and play the audio.
Thankfully there are full instructions that outline the installation process step by step, as well as specific notes for each operating system. I found that as long as I actually read the instructions and followed them properly (instead of thinking I knew better) then everything worked.
After the installation I was able to log in from a web browser and customise the MotionEye settings, set it to upload videos to Google Drive and so on. I just needed to update one setting I've never used before, the one that would fire the raven.py script when motion was detected, the "Run a Command" part of the Motion Notifications settings.
This took some trial and error, and poking around online, but I discovered that the script needed to be made executable and also had to be stored in the folder /etc/motioneye/ - I worked on so many different combinations that something else might work for you, but I'm pretty sure that setup works. This was one of the great benefits of installing on top of a full OS - I was able to log in using Real VNC to make code changes, move scripts around and so on.
Step 4: Squawk Box
Getting the head to swivel was the main objective of the build, but I really wanted to add in some audio as well. It's sometimes complicated to add audio to a Pi project, there are lots of different HATs that work really well if you want great quality, and tiny battery-powered speakers at the other end of the scale, but I thought I'd try something mid-range - not audiophile quality but still powered directly by the Pi.
I turned to a bunch of amplifier circuits I bought a while back - coming in a pack of 5 these were decidedly no-frills, leaving you to solder in all of your own cables, but costing just over £1 each they were perfect for this project. On testing the sound was definitely not high-quality, with noticeable hissing etc, but then again it worked, was very loud, and had a lovely rotary on/off/volume dial.
Next I dug out a dozen or so raven sounds from the web, and popped them in a folder with some samples I snipped from Christopher Lee's recording of Poe's The Raven. I used some code snippets I found on the Raspberry Pi forums to play these sounds at random.
The speaker, the biggest I could find that would fit, was hot-glued to the raven's chest panel, with holes drilled to let the squawk out.
Step 5: Body / Beaker
Next I attacked the body, chopping out an access panel and trying to think of the best way to connect up the head to the neck, that would allow a servo to move it freely and also keep it dead centre. I dug all round the workshop in vain for scrap plastic that would work, and eventually found the ideal thing in the kitchen - old plastic beakers.
The base of the beakers turned out to be just the right size to fill both the head and the neck holes, so after trimming them down with a rotary tool and adding the servo to the very centre (handily marked on the beaker) they were drilled and screwed into place. Before the final fitting I chopped out large sections of both beaker bases so that the cables could feed through from the head, and be able to move without snagging.
With everything working on the bench, it was time to get the electronic "guts" inside the bird.
Step 6: Assembly
There's quite a bit of room inside a plastic bird, but even so things were fairly tight and took a bit of planning.
First I drilled a hole in the raven's butt for the volume knob, then another larger hole to let in the USB power cable. The Pi was next, fitted simply in place with two self-adhesive cable tie holders, the ties running through the bolt-holes in the board.
The jumper connections were next, for the servo and the LEDs, these were taped up as well just in case of movement. The most fiddly part was connecting the camera ribbon cable to the pi - I used surgical tweezers for this in the end, appropriate for the chest cavity!
The last connections were between the speaker and the amplifier circuit, and I tested the system thoroughly before "closing" the chest with cable ties.
Step 7: Evermore
I picked up this plastic raven in the post-Halloween sales last year, and for once it's turned out exactly as I'd hoped. The LEDs and swivelling head give it such personality, and it comes across as more gormless and charming than scary, or maybe that's just because we're used to it and it's daylight. The audio is a great addition, and I think it'll be a great prop in the front garden on Halloween, maybe perched on my car's wing mirror - I'm sure folks will enjoy the Poe as they pass by at a safe distance.
It's much more than a jump-scare prop though, with MotionEye OS running it's a really practical security camera, and I've no doubt we'll find somewhere to perch it all year round. We may change the audio a bit though, and possibly harness the servo to add in remote controlled panning to it's signature head-swivel. It'd also be straightforward to swap out the camera for a PiNoir version, add some IR LEDs and have a night vision version!
I had a lot of fun with this project, and highly recommend keeping your eyes peeled for similar birdies, they make a great Pi project case.
Thanks for reading and Stay Safe!
Participated in the