Chicken Robot

Chicken Robot in development

Current Status:

I’ve had backyard chickens for 25 years. They give us eggs in season and we feed them and keep them safe. For two and a half decades we’ve had to worry about our hens and a rooster at times, and the various critters that would consider them a tasty snack, coyotes, raccoons, bobcats, mountain lions, and hawks. For 25 years, we’ve had to make sure the coop was locked up and secure at dusk, and open at sunup.

The chickens go home in the coop by themselves at night, but we still have to close the doors. Wouldn’t it be nice, I thought, if the work of opening and closing the coop door was done by someone else? Possibly by a robotic assistant?

Former Chicken Robot, 2006-2010. Pieced together from detritus, including bicycle frame, rotisserie motor, and household timers.

Some years ago, I created a coop robot that was strictly an analog mechanical affair. Bastardized bike parts, a rotisserie motor, a couple household timers. It was a janky piece of shit thrown together in an afternoon. It worked for a while with steady maintenance and frequent repairs. In the end, some part broke that needed welding and I added that more serious repair to my To-Do list. Fast forward, what, ten years?

During the pandemic lockdown, I was ever alert to ways to distract myself. We recently made a new coop, and it seemed time to make a new Chicken Robot, this time, a smarter, more robust version.

The new chicken robot could not only control the doors, but adjust for sunrise/sunset and even daylight saving/standard times. Easy enough.

I started experimenting with a Raspberry Pi controlling a beefy stepper motor via a simple stepper controller.

It would be nice if it could tell us somehow that it took care of the doors. I could have it turn on an indicator light. What if we were gone? Maybe I could make it send us a message that it was on duty and had opened or closed the doors.

A dual relay board controls the door indicator light and the infrared camera light

I did some successful experimentation with an SMS/MMS API. I found that I could send a text message to me and my housemates to tell us that the Chicken Robot had closed or opened the doors. Success!

We have a couple of recalcitrant hens who sometimes decide to roost outside. If the doors closed automatically, we wanted to make sure no hen was left behind. I thought I could attach a webcam to the Pi and take photos inside the coop. It’s dark in the coop, so perhaps I could use infrared webcams. Even infrared webcams need a light source, and cameras with their own light source can be pricey. I experimented with my own array of infrared LEDs and made my own cases for the camera module with plumbing parts.

Homemade webcams with an array of infrared LEDs

My experiments with these little inexpensive webcams were confusing. Even with an infrared light source, they took quite dark photos. They were sold as infrared webcams, but after writing the manufacturer in Schezuan, they told me they were not in fact infrared cameras and had an IR filter that prevented IR light from reaching the sensor.

With the IR filter, the webcams took rather dark photos unaffected by infrared illumination
One of the cameras was to poorly focused, it made amazing abstract impressionist images.

Looking in the front of the lens, I thought I could see the distinctive red-pink-yellow sheen of the IR filter. On the first camera, I used an exacto knife to break out the filter and removed the pieces. On the second and third cams, the forward lens unit pushed out along with the filter, so I was able to put it back in minus the filter. After some focusing and converting to black-and-white with softwaree, I got sharp images illuminated by my infrared light source.

Sharp black-and-white photos illuminated by infrared light.

If the chicken robot could talk to us via text message, could we make it so we could talk to it as well? Yes. So I programmed some simple commands that it could respond to: Help, Status, Photo, Open, Close, Sunrise, Sunset, Cameras. Here’s what it looks like when it closed the doors at sunset:

Along with the status update, the Chicken Robot automatically sends photos from the coop.

Webcam photos sent by Chicken Robot while it is on my workbench

The brain of the Chicken Robot is a Raspberry Pi, the tiny little capable computer that costs about $35. The Pi was the obvious choice because of its incredible adaptability and modularity, including:

  • standard Unix OS/Debian
  • ability to run python and its many useful modules
  • Chromium browser with leading edge JavaScript support
  • Wifi and Bluetooth
  • GPIO access to control hardware
  • selection of various inexpensive hats/peripheral boards
  • capable ARM processor
  • HDMI, ethernet, and USB connectors
Python Door class

I programmed the Robot in object-oriented (OOP) python, creating classes for each of the parts of the controller: GPIO, Doors, Comms, Camera, Light, and the ChickenRobot itself. I never fail to be a little awed by object-oriented code and how easy this programming paradigm makes coding.

After all the bench testing, it was time to assemble the robot. I had already cardboard prototyped all the pieces I’d gathered to see how they would come together. The Pi and all the little helper boards were connected with flimsy jumpers and a lab bench breadboard. So I desoldered headers and replaced with screw terminals. All of the components on the breadboard were moved to a perma proto board.

Next: Installing the robot.

3 thoughts on “Chicken Robot

      1. Will you ever post more on this? I’m seriously interested in being able to do a similar thing myself, but am a complete neophyte… would you be willing to post parts list, schematic and code, or are you wanting to keep that to yourself (I’d completely understand if that’s the case)

Leave a Reply to John Young Cancel reply

Your email address will not be published. Required fields are marked *