Chickcam is Dead. Long Live Chickencam!
After nearly a decade of service, the old Chickencam is dead.
An indoor wireless camera I bought an eon ago, I had turned it an outdoor camera by covering it with a clear plastic pretzel container which worked surprisingly well at keeping the water out, but made the camera’s night vision useless because the plastic just reflected the IR lights back into the camera.
No big deal. The chickens and ducks were in the coop at night, so there wasn’t much to see beyond possums, raccoons and the occasional coyote.
Sadly, the plastic and duct tape housing I made to weatherproof the power supply fell apart at some point so the last rain filled it with water and fried both the camera and power supply.
While I wasn’t happy about the camera taking a dirt nap, it did give me a chance to overhaul how I streamed the video. The old camera didn’t support direct video streaming except to a plugin that only worked with ancient versions of Internet Explorer, so I had hacked it to send the video to a Raspberry Pi (a small computer), which then captured, re-formatted, and sent it on to YouTube to stream (almost) live. With the old camera dead, I decided to add a camera to the Raspberry Pi and use it stream directly to the Internets.
Building the New Chickencam
The whole thing was actually pretty easy to get up and running. In fact, making a waterproof enclosure for the computer and camera took longer than figuring out how to stream.
The Hardware
For the streaming hardware I used a Raspberry Pi 3B+ I bought a couple of years ago for about $35 on Amazon. The camera is a Raspberry Pi v2 camera with 8M pixel resolution I picked up for $18, so my total investment was $53, or about $35 less than what I paid for the old camera 10 years ago.
I downloaded the Raspberry Pi Imager software from the Raspberry Pi website and in a couple of clicks had an SD card loaded with the Raspbian Operating System and ready to pop into the Pi’s SD slot. I did that, then plugged the camera’s cable into the board and booted it up.
Once the computer booted all I had to do was enable the camera, and it was ready to go.
The Software
The latest Raspberry Pi OS comes with everything needed to stream video built in, so, unlike the hoops I had to jump through with the old Chickencam, all I needed this time was my YouTube Live Stream Key and a string of code to tell the Pi how and where to send the video stream.
For the code, I read a number of different blogs on how to live stream from a Raspberry Pi, and, after trying several, I found this one was easiest (it’s a little out of date on the YouTube stream key setup, but all you really need is the part where it says “How it Will Work” anyway.)
The TL/DR version is all needed to do is copy and paste this code into the Pi’s terminal window (with my YouTube stream key added at the end):
ffmpeg -threads 0 -f v4l2 -i /dev/video0 -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -acodec aac -ab 128k -strict experimental -s 1920x1080 -b 6000000 -aspect 16:9 -vcodec h264_omx -vb 820k -pix_fmt yuv420p -g 60 -r 30 -f flv rtmp://a.rtmp.youtube.com/live2/[your youtube stream key]
That worked perfectly while I was in the house, but because the Chickencam is down in the orchard where the WiFi signal is weak, so I had to make some tweaks to keep it streaming. I lowered the resolution (the stuff after “-s”) from 1920×1080 (1080HD) to 1280×720 (720HD), and lowered the framerate (the stuff after “-r”) from 30 frames per second, which is standard motion, to 15 frames per second, reducing the number of frames it had to send so it wouldn’t buffer or go dark all the time.
One other problem I kept running into wasn’t the WiFi but the Pi itself. I kept getting “thread queue size” errors, but after a little research I was able to fix that by adding “-thread_queue_size 64” before the “-i” part.
Once I had the hardware and software running smoothly, I needed to put it in a waterproof case.
Making the Waterproof Case
I could have purchased a waterproof enclosure for the Pi, but they were $20 for what was looked to me to be a junction box used for outdoor electrical wiring. Since I’m kind of a packrat (though I am nothing compared to my wife), I have a box in the garage full of watertight plastic containers that once held food, coffee, detergent pods, and the like (see pretzel container from old camera above).Among my container menagerie was a Carnation breakfast drink mix package measuring about 6 inches (15.25cm) wide and tall, about 2 inches (5cm) deep, and made of heavy plastic with a watertight lid. Perfect for the Raspberry Pi and the power supply to fit in with plenty of room for air circulation.
I took a container and drilled a 5/8ths inch (1.5cm) hole in the front for the camera, one in the side for the power cord, and a couple more in the bottom for air to keep the Pi from overheating in the summer when the camera sits in the sun part of the day. Finally, I drilled a hole in the bottom and hot-glued a 1/4-inch nut over the hole so I could screw the case onto a standard camera mount (coincidentally the one I got with Old Chickencam but never used).
Then I put the power adapter inside the case, set the PI on top of that and fit the camera into the hole I had drilled. Duck tape was used to hold the camera in place.
To keep the camera lens protected from the elements, I hot glued a hose washer to a small piece of clear acrylic salvaged from a broken picture frame, then placed it over the camera lens and used more duck tape to hold it in place.
After that, I screwed the case onto the camera mount securely, fed the power power cord through the side hole, and plugged it into the power adapter. I snapped on the lid, added a few more strips of duck tape to cover the gaps, and we were ready to go.
The camera has been running for a week now and survived both high winds and rain, so I’m feeling confident that I’ll have this one for a long time. Photo quality is pretty good too.
Since this is a full computer instead of just a wired camera, I should be able to do a bunch of fun stuff. I bet people more creative than me already have.
If you haven’t checked out my Chickencam yet, please do. No guarantee you’ll see anything other than backyard poultry being poultry, but you never know… Here’s a link to the Chickencam.