Look out, Raven Pi is watching you! With its swivelling head, piercing red eyes and loudly Poe-quoting speaker no motion is left un-noticed.
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.
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.
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.
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.
Source: Raven Pi Security Camera