There is no denying that chickens are having their moment in the sun right now. Our little feathered friends have become a mainstay not only in poultry farms, but also in suburban backyards where they are lavished with as much attention as the family dog. At this point, it is safe to say that chickens have even surpassed the adorable axolotl as everyone’s favorite nontraditional pet. But us humans are not the only ones with an interest in chickens.
For the same reason that chickens find their way into sandwiches, strips, soups, and salads, they also find their way into predators’ mouths. They are just too delicious for their own good, so everything from raccoons to foxes see backyard chicken coops as an all-you-can-eat buffet. Keeping constant watch over a coop is not realistic — especially since most predators hunt at night — so hardware hacker donutsorelse built an AI-powered system called the Chicken Guardian to keep his chickens safe.
Testing the hardware (📷: donutsorelse)
It really does not take much to scare off the animals that typically threaten chickens — a good loud yell will send them scurrying away in a rush. The difficulty lies in noticing them in time to prevent your chickens from becoming their dinner. The Chicken Guardian automates this process using an object detection algorithm, which continually analyzes images taken just outside of the coop. If the detector notices a predator that it was trained to recognize, it will play a recording of donutsorelse’s voice over a speaker to shoo them away.
The system is built around a Raspberry Pi 4 Model B single-board computer. It was important to choose a computer with a good amount of processing power, because the chicken coop is out of range of donutsorelse’s Wi-Fi network. As such, the computer vision algorithm must run locally on the Chicken Guardian.
To make that work, a YOLOv8 object detection model was trained on donutsorelse’s computer using a large collection of images of the types of predators that might show up in his backyard. Some data augmentation techniques, like image blurring, were leveraged to ensure that the model would be able to detect predators under a wide range of environmental conditions. After training was completed, the model was deployed to the Raspberry Pi.
The final installation (📷: donutsorelse)
In addition to scaring off hungry animals, donutsorelse also wanted to be alerted when they were detected so that he could go check on his precious chickens. Since Wi-Fi was not an option for communication, he included a Blues Wireless Notecarrier F card in the build. This allowed the system to send messages to donutsorelse’s home automation setup via cellular networks. That, in turn, controlled a smart plug that was connected to a siren.
The Chicken Guardian is an inexpensive build that is fairly easy to get up and running, so if you have a problem with chickens that mysteriously disappear, you might want to consider building your own copy of it. The project write-up has all the details you need to keep your chickens from becoming a predator’s dinner.