Mechanise your chickens

My friend Tony always excuses himself early from parties, because he has to get home at dusk to shut his chickens in their coop. Tony, this one’s for you so that next time, you get to stick around for dessert.


Chickens are birds of habit. You don’t need to shepherd (bird-herd?) them into their coops when the sun goes down; they’re programmed to head to their perches as night falls. Foxes and other predators, unfortunately, take advantage of this to chew on stationary, sleeping chickens, so the door of the coop needs to be firmly closed once all the birds are roosting, and opened again at a repellently early hour in the morning. Usually a human will go and do that job. (When I was a kid, I had to do the same for our family’s ducks. I hated those ducks.)

Let’s face it: given a chance to exercise a bit of laziness, most of us will jump at it. (Metaphorically. Lazy people don’t like jumping.)

Eric Escobar has a very neat Pi-powered solution to the problem of night-time chicken imprisonment, which is safer than some others we’ve seen, which use linear actuators. This door’s lowered using gravity, so there will be no very, very, very slow and eventually deadly crushing of any chickens or small children with Eric’s setup. The door is programmed to be lowered at a certain time of day, once it’s dark enough for all the chickens to have moved indoors.

Everything you need to replicate it yourself, right down to schematics, is at Eric’s GitHub.

The nice thing about using a Pi for this sort of thing is that it enables a certain amount of feature-creep. Now the basic functionality’s there, Eric (or you) can add things like the ability to count chickens in and out of the coop; a camera; automated feeding…I’m trying to come up with a way to get the Pi to collect eggs, too, but I’ve got nothing. Ideas in the comments please!

Chicken-owners will be pleased to hear that we’ve got more chicken-husbandry content for you coming up tomorrow. And something that’s a bit like a chicken for Friday. We’re all about the poultry this week at Pi Towers.




Liz Upton avatar

And I really do mean it about crushing small children to death with linear actuators. The kid next door managed to get his head stuck in the little door of our ducks’ coop when I was little. He was stuck there for several hours, weeping, before any of us dared to go and tell a grown-up. Just imagine that scenario twinned with a gradually and inexorably lowering guillotine door.

Hove avatar

A guillotine for my chickens, hmm very tempting. They get let out at 5.30am at the moment when the kids wake us up. Actually, that guillotine might have a secondary purpose come to think of it.

Liz Upton avatar

In your case, it appears that linear actuators are the way forward.

Alan Mc avatar

“Running around like a headless Pi”

Alan Mc avatar

A great Chicken Scoop (as Gert would say).

Will have to show it to my father-in-law to add this option for our 6 feathered friends in Orange. Looking forward to the other blogs this week dedicated to hacking hens’ happiness so.

Cot cot cot ! (That’s “Cluck Cluck Cluck” in French)

Liz Upton avatar

Coin coin coin right back at you.

Alan Mc avatar

Quackers indeed.

Fester Bestertester avatar


Fester Bestertester avatar

Brings to mind Pam Ayres’ “Battery Hen”

bluecar1 avatar

now could you combine this with the beer fridge project and put the hen house on a wii fit balance board and count the chickens in at night and notify a human if not all present inside for night?

then you just have to work out when the fatest chick is leaving at silly o’clock for the guilitine door :) timing would be evertything on that one though

Steve Williams avatar

To mis-quote Brian Hanrahan:

“I’m not allowed to say how many [chickens entered the coop], but I counted them all out and I counted them all back.”

Homer Hazel avatar

I think before someone implements the guillotine door they should first implement some sort of photo identification. You would not want to Kill the Old Red Rooster before its time, would you?

I imagine this concept could be expanded to close the barn door after the horse has left. How does that saying go? It can also be used to let the cows out in the morning or in for milking. It’s been a long time since I have helped with the milking, have the milking machines advanced to the point where they attach themselves yet?

Yvan T. avatar

Yes they do. Laser guided…
These systems can even give you statistic of how much milk a particular cow gave

Martin O'Hanlon avatar

I have rabbits, who while they do return to their hutch throughout the day, need to be encouraged back into their house each night. I swear they wait until its time for bed and then come out for a final run just to annoy me!

I have been scratching my head thinking of ways of sensing that all rabbits are back in their hutch. Any ideas?

Andrew Oakley avatar

Any UK vet and many animal shelters will tag your pets with a grain-of-rice sized RFID ownership tag ( ).

It’s then just a case of looping an RFID reader antenna around the hutch door until it is sensitive enough to detect the tag. Kind of like those RFID anti-theft bollards you see inside the doors of cheap clothing stores (but never the expensive stores – apparently thieves have poor taste). Ask your colleague Mr. Whalley about that ( ).

Alternatively you could use RFID collars, but in my experience, most animals left to their own devices will remove or destroy a collar. Hence why cows have ear tags.

Jon Gritton avatar

The problem with RFID is range. You need enough range to ensure the animal is always detected (range for the lower freq readers can be very short – inches) but you also need to make sure your “in” and “out” readers aren’t within range of each other (so they don’t fire at the same time), which could be tricky unless you have them going through a tunnel of some kind.

AndrewS avatar

RFID collars? And then an RFID sensor on each side of the doorway so you can tell whether each rabbit is going “in” or “out”.

One of the places I used to work did a similar thing with RFID keyfobs (which also acted as doorkeys) to track who was and wasn’t in the office. No idea how reliable it was though, especially when multiple people left

AndrewS avatar

…or arrived together in a group.

Andrew Oakley avatar

Further ideas:

* Contact sensors that sound an alarm if the feed bins are left open for more than 5-10 minutes (damned RATS. I hate rats. Thoroughly recommend plastic barrels for chicken feed).

* Some kind of fox deterrent. PIR sensor? NOIR camera and image-based movement sensor?

* Anything that annoys cockerels, because they’re just basically the most evil animals on Earth. They’re all talons, those barstewards. Low-powered USB foam dart missile launcher to remove them from the apple trees, for example.

* Humane rodent trap activation sensor + SMS message. My VOIP provider ( ) gives me a nice HTTP GET API for sending text messages, ideal for CURL. I’ve been using it to track low diskspace and debug a runaway zombie script, and it’s been very easy to use. Obviously if you’re using neck-snap traps then there isn’t quite the urgency that would justify an SMS… ;-)

Foghorn Leghorn avatar

You’re way off, ah say you’re way off this time son!

‘course you know this means war.

Liz Upton avatar

> Anything that annoys cockerels, because they’re just basically the most evil animals on Earth.

I see you are not familiar with turkeys.

dhruv avatar


But I really don’t understand how gravity pulls it down .

I’m sort of a noob so forgive mw

AndrewS avatar

It looks like as the motor “unwinds” the string, the door is simply lowered under its own weight. So any “trapped chicken” would only have the weight of the door pressing down on it. (but presumably the door is lowered so slowly that the chicken would simply get out of the way first)

Foghorn Leghorn avatar

Ah thought, ah say, ah thought ah had a sittin’ duck, but turned out he had a pigeon. That’s a joke, ah say that’s a joke, son. I keep pitchin’ ’em and you keep missin’ ’em.

greg58 avatar

Interesting solution.
The same problem was solved by my grandfather 50 years ago – without RasPi and even without electicity.

Liz Upton avatar

Do check out today’s post at – there’s another solution to the problem. Which is unlikely to be the one your grandfather used. (Do tell – we’re curious!)

greg58 avatar

He observed that the chicken were collecting at sunrise in front of the window. So he put a chicken roost in front of it and connected a rope to the door. Since then the door was lifted as soon as certain number of them were sitting on it. To prevent the door from falling down again he used a ratchet in the system.
At night they never sitting there and used their normal roost so the door was never opened accidentally.

Luke Townsley avatar

There is a whole host of automation and projects surrounding chickens that needs to be done for small scale regenerative farmers.

The electronics is actually relatively simple, but you also have to take into account human behaviour, chicken behaviour, predator behaviour, and make it beyond bulletproof on a tight budget.

Thankfully there’s Raspberry Pi. ;)

We’re getting set up to start working on some of this over at

Michael avatar

To collect eggs, you need to make a setup similar to the game you find at kids arcades to win teddy bears. You use a crane that will lower and have a claw pick up the egg, lift it up and take it to an outlet shoot. A camera can be used to identify the location of the egg.

I am designing one for fun to pick up golf balls when putting in the garage. Yours is a little more complex but still workable.

Liz Upton avatar

Oh, those things are IMPOSSIBLE. There was an arcade near the hotel I last stayed in in Silicon Valley, and I spent untold dollars trying to “win” an 18-inch-long, plush bottle of Sriracha in one. I am still sad; it was one of the stupidest things I’ve ever seen and I wanted it for the kitchen windowledge.

Tobias K avatar

NPR (National Public Radio) had an interview with someone who researched about those claw machines who found how manufacturers allow you program them to be “rigged” so that they can be made to fail a certain percentage of the time, no matter how skilled you may be. I agree, these are horrid contraptions, and even more so now that the suspicion of their unfairness has been confirmed!

Liz Upton avatar

I’ve just found an article talking about the rigging you mention – really interesting, and I am never going to try to win another plush bottle of Sriracha, no matter how tempting!

Tobias K avatar

Yes, the Claw: more evil than a flock of cockerels or turkeys, nearly silent, but way more annoying. Insidious, vile and corrupting.

Kamil avatar

Armata na muchy

Walter Jeffries avatar

Or just don’t lock them in. We don’t. We have rings of defenses. Outer fences, inner fences, dogs patrolling and we have no need to lockup animals despite high predator pressures. The fences mark the boundaries and any fools who penetrate our defenses get eaten by our dogs. It’s easy, and automated. The best solutions tend to be the simplest ones.

Phill avatar

//automated chicken defence script

if(predator && !dog_see_you)

Phill avatar

Damn typo!

//automated chicken defence script

if(predator && dog_see_you)

Comments are closed