Hacker News new | past | comments | ask | show | jobs | submit login
DIY ESP32 based chicken coop door. Control based on time, light or via app (github.com/esp32-coop)
151 points by thunderbong on Aug 30, 2023 | hide | past | favorite | 59 comments



I did this in the Raspberry Pi 1 era.

* Pi for timing/wifi/status/webserver.

* Opened at 8am, closed at civil twilight. Or whenever I hit the button on the webserver, or the switch board.

* Limit switches.

* Mechanical swing lock for raccoon protection

* Electric drill + rope for the vertical sliding door

* Relay for direction, power mosfet for the drive controller.

* Intermediate board between the 3.3v controller and the 12V power board.

* Lead acid battery + charger for the power.

The door was pretty hefty, and was _solid_. 1/2 or 3/4 ply IIRC. The drill wound up being a mistake, because the power was too high, managed to fry some relays before I got everything worked out. The limit switches were generally pretty good, but they were also pretty well protected by the door design.

The best bug was that the wifi worked really well during the day, but not at night. Turns out that the LOS between the wifi dongle and the AP went through the roost, and chickens absorb enough wifi signal to drop it off the net. So one 3m usb cable later, and the dongle was on the other side of the roost. Solid networking from then on.

Sadly I left it in the coop when moving out.


What happens if the door closes at night and one or more chickens aren't already inside? Is that a thing that happens? Do they pretty much always go inside at the same time every evening? Is it bad if one gets left out alone?

I know nothing about chicken coops.


If a chicken isn't in the coop by the time the sun is setting, then they don't want to be in the coop and you would have to manually intervene anyways. It's always the same chicken(s) too. They want to roost in a tree or on the roof or something. If one of your chickens develops this habit, the best way to break it is to keep them locked in the coop for a few days as soon as you realize what's happening.

But barring that situation, chickens always go in the coop. I can tell it's 15 minutes to sunset when the chickens start ambling up the ramp.


A former colleague of mine spent a bunch of time adding computer vision to his coup control project for exactly this reason.

But turns out, chickens just naturally go into the coup at sunset and it's completely unnecessary.


Point of order: A chicken coop is where chickens live. A chicken coup is what directly precedes coq au vin.


It wasn't really an issue, They'd go in between sunset and one of the twilight light levels, and that was that. When we did it without the automatic door, there was a lot more chasing type manual labor just getting them in if it was early, or we'd forget and it would be super late.

Didn't ever lose one at night, but there were definitely daytime predators that were an issue. (mainly raptors)


It happens that one might get left out and it's no problem unless a predator shows up :)


> Turns out that the LOS between the wifi dongle and the AP went through the roost, and chickens absorb enough wifi signal to drop it off the net.

That sounds like a chicken motion detection system to me.


Chicken presence anyway.

I tell you the bugs you see when deploying something in the real world...


Field work always finds the "what the heck" bugs that lab work never could.


And the chickens will eat the bugs when you deploy them to the real world..


"Certainly, here's your code snippet presented in a more readable manner:" Using ChatGPT to do your README is a good idea, just need to proof read it ;)


I have an automatic chicken coop door from the company Run-Chicken. It is one of the most brilliantly designed products I've ever owned. It has an app for setting up the opening and closing rules, which can be rather sophisticated, based on both time and light conditions.

The device itself has no WIFI, bluetooth, or a radio of any kind. To program the device, you push a button to put it into a programming mode, then hold your phone up to its photo sensor, and it will flash the screen in a sequence of black and white to relay the encoded settings.


Have the same door, has worked flawlessly for the two or so years i've had it I don't even think about it.

Really clever piece of engineering on the programming mode for sure.


A project I've always toyed with in my head is a fancier version that would count / verify the checks have all entered the coop at closing time and warn you if not. With my parents coop occasionally a chicken will decide to brave the night outside, often to disastrous consequences.

Figuring out how to build a low-energy version is challenging, but necessary since the whole system runs off small solar panels and a 12v battery.


I would suggest that you don't need to count the chickens. You could also just verify that none are left out. There are presence sensors (such as the ones that turn lights on when someone comes into a room, or off when everyone is gone). If you had one that worked on chickens pointed into their run, you could close the door when there are none left (plus a time cutoff if Henrietta really wants to keep her trist with the raccoon).


I haven't played with rfid tags or bluetooth beacons myself but I could imagine a solution build around one of the two technologies. I think it should consist of an entry tunnel with two sensors, one at each end. The tunnel and the two sensors could be used to determine the direction the chicken goes. It the chick first triggers the inner and then the outer sensor it is checked out and when it goes the other way its checked in.


I had that problem with the camper chickens (that end up getting eaten by raccoons) and also sometimes additional guests like possums or skunks would enter the coop.

In the end I always closed the coop at night manually and let the auto coop door open in the morning, that way I could sleep in in the summer.

Next level of coolness would be a full coop monitor with non-chicken intruder detection. Alas, all my chickens have passed on by now so it'll remain a fantasy.


The esp32 devboards are magnificent, as it is so easy to replace the need for official Arduino boards

- Arduino compatible

- platformIO supported

- very cheap

- they are usually tiny

- great wifi and Bluetooth

- gpio pins for the different protocols (i2c etc)

- easy to power (tolerance and options in usb and pins)

- lots of exciting new models and active development like the esp32c3, the D1 minis and different models with integrated oleds are cool

- community resources. there are massive amount of blogpost and YouTube videos for esp32 (and Arduino in general)

cons are few;

- 3.3v signal is a hassle quite often in practise

- the amount of different esp32 devboards models can get confusing

- the pins are sometimes shared-purpose and it's not always clear which you can use

- China. Both practical for delivery time, and politically


you can also drop the Arduino bit and use FreeRTOS. Also many of my ESP32 projects end up on a solderable breadboard with a level shifter to deal with 3.3v. But most of what I work with today is 3.3v.


A design with limit switches instead of counting turns seems like it would be much more reliable. e.g. https://www.floweringelbow.org/automated-door-from-an-old-wi...

That way the software can be nearly stateless:

1. Check time and determine desired state (open or closed) 2. Compare desired state against limit switches and run motor until the limit switch is hit (or it times out which is an error)

On the other hand, a turn-counting strategy can lose power in the middle of opening or closing and "forget" where it is in the process.


Chickens are incredibly dirty animals. The limit switches would probably be fouled (fowled?) pretty quickly.

Commercial versions of this can measure motor load (via current), but still require manual calibration. I wonder if they thought they could get away with manual calibration, but couldn’t make it reliable.

I think these people are the market leaders:

https://www.chickenguard.com/

Note that the commercial version latches the door shut, so raccoons can’t open it from the bottom (they would have to learn to pull the string, and then also stick a hind leg or something in the bottom to wedge it open after the string was released).

The new 2023 model replaces the string with what appears to be a high tolerance gear system. That auto-calibrates once, then remembers the set points.


Yeah, it would be interesting to get an update on FloweringElbow's implementation to see how often the lower limit switch is getting fowled :p .

I think it's also possible to design it such that both upper and lower limit switches are placed higher up on the edge of the door, rather than strictly at the top and bottom, which should help with the fouling.

Practically though, any automated system will be vulnerable to fouling/blockage and require regular maintenance to keep the mechanism clear and clean enough to avoid premature corrosion (chicken poop being pretty acidic). In my opinion, it's a pipe dream to have a fully automated coop in a backyard setting and not eventually/occasionally have failures that require manual intervention or lead to neglect and losses due to predation. Better to think of such systems as tools to relax the timing requirements for manual care. Instead of doing all the work at the right times, one can confirm that the animals are out/fed/watered/in/etc as part of doing the normal morning/evening rounds/chores.


Limit switches for all sorts of terrible environments exist. These would probably work https://www.mcmaster.com/products/switches/environmental-rat...



Problems I've had with the chickenguard (I still use it, and probably won't stop, it's good enough with modifications)

The tracks will get warped over time if exposed to moisture. I don't live in a particularly wet place, and it's partially covered, but the wooden tracks warped, and the door would get jammed.

The string will get tangled and quickly finish off the batteries if the door is jammed or the batteries get low.

Modifications made:

I routed a painted solid wood doorway to provide a wider track to prevent the track from warping, and to improve tolerance to dirt, leaves and twigs, which has eliminated door jams.

Battery replacements every 6 months are now on my calendar.


Interesting. Our tracks are plastic. They must have improved it.

I did have to disassemble it and untangle the string from the spool and motor once after initial setup.


I love projects like these, since its typically a neophyte to embedded hardware design and programming a microcontroller.

But just once, I'd love to see a hobby project from somebody who already knows what they're doing, but is using this to try out some ridiculously inappropriate software technique.

Forget Arduino on an ESP32, I want to see somebody do this with FreeRTOS.

It's been on my todo list for a long time. Unfortunately, we have too many predators in our area to let the chickens roam free unsupervised (I lost 5 last year to the same coyote, and I can hear the bald eagles squeaking most clear days), so its a solution in search of a problem.


One problem I see with this is not stranding chickens outside if they didn't return fast enough; I guess you could count by breaking a light beam, or stepping on a plate.

Second would be adding a good lock to the door -- raccoons are very crafty, and love stealing eggs


> and love stealing eggs

and chickens.. in my experience


If you're thinking about doing projects like this, but are in a hurry and willing to skip lots of the fun, I recommend espHome. https://esphome.io/

You should be able to accomplish similar with a yaml configuration file.


Nice. However the bigger problem for me is the mechanics. What motor do you use? Actually I think you also need some gear.

We and many other people we know are using the Kerbl (not related to KSP) chicken coop door which is quite expensive (around 120 Euro).

https://d3w207ykk8w4lq.cloudfront.net/public/thumbnail/33/a3...

You can see in the image it uses quite intricate mechanics with a lever and a spring. It's also supposed to detect a stuck chicken, however that has never happened to us (or we wouldn't have noticed because the Kerbl has silently resolved the problem).


I have a door from Run-Chicken, mechanically it's still good but the electronics went out in it. I'd love to have something like this running it, going to give it a shot.


If you can rip out the old motor and tie a string to the door (drill a hole in the piece that moves?), you can get a standalone motor from chicken guard. (You’d want the pro model or cheaper; their new all-in-one would have you replace the old door)


I might do this, but the servo still works. So long as I can still drive the servo, I think I'm good. It's open loop, so I'll need to watch something to determine when the door is fully shut.


This is a project I have long thought to try. Relatively simple task, but requires Designing a reliable system and sourcing quality components


and chickens ...


and land

Technically I could keep chickens as long as I keep five or less. Realistically my neighbors would hate me. Also, there's a lot of foxes in my area and I don't think that my five chickens would be around all that long.


My neighbors across the street (3 miles from downtown of a medium size american city) have chickens and most days I forget they are there. I grew up with chickens as well, and they really aren’t a nuisance. We also have foxes and uh, the time I did’t forget they were there was when I heard a strange yowling at dawn, clearly a chicken and yet so different from their normal noises. I assume that was due to a fox.


Yeah, hens aren't loud or smelly, so as long as you take measures to curb issues with pests they attract, they're fine. Just don't get a rooster.


As for neighbors, just don't get a rooster. Hens do make some noise but they're not bad at all.

As for foxes, you can use a mobile coop+run. Move it once per day to provide fresh grass and distribute the fertilizer byproduct.


Yeah, if I did it I'd want the area to be fenced in because one of my neighbors is nosy. It's a 1/4 acre plot, so not exactly a huge amount of land.

I know that my neighbors down the street have chickens because I occasionally hear them, but their yard is completely fenced in. I only know them well enough for casual greetings when we see them in passing, and there's a language barrier preventing more in depth conversation.


Do you think there is a reason they are getting away with ignoring the rules? Maybe you could too - just ask the neighbours first?


They might not know that the rules exist at all -- you have to go looking to find them. I'm sure that they're getting away with it because nobody cares and the yard is fenced in and nobody sees the chickens and because none of their next door neighbors care.

I don't talk to them much besides "hello", as communication is difficult since they don't speak much English and I don't speak much (any) Swahili.

The coop is somewhere in here: https://i.imgur.com/t6FqF6G.png


> I could keep chickens as long as I keep five or less

Is that a specific chicken clause in a contract somewhere or a general head of livestock / pets clause.

5 chickens != 5 dogs != 5 horses


I looked up the ordinance, and I was wrong about a few things. Livestock or poultry may be kept provided that there are no more than 4. So I was wrong about the limit -- it's less than five and not five or less.

Also:

  * I need to have a 1 acre parcel, and I have only a bit over 0.25
  * It needs to be 25 feet from all property boundaries and fenced in, which limits placement options

So my options, for this plot, are nil.

I don't recall the 1 acre limit when I looked before, so I'm wondering if this has been updated.


I have 12 on a 1/2 acre plot, about 2/3rds of which is backyard they can access (so call it 1/3 acre of roaming). That amount seems more than ample, though these are pretty bougie chickens. Four in even 1/8 acre should be fine.


The minimum square footage per “cage free” chicken is only 1.5 sq ft, (in California, which passed a ballot initiative to increase it to that number)

https://ballotpedia.org/California_Proposition_12,_Farm_Anim...

So, 1/8 acre could hold 3,630 “cage free” chickens, in theory (I am not condoning this).

In you don’t need much space to keep chickens happy. However, they produce a lot of dust, and can’t be kept in a house.


> However, they produce a lot of dust

This was actually the most surprising thing about first time chicken ownership. I was expecting the poop, I wasn't expecting the dust and the dust bathing. They will pick one or more parts of the yard and crater it and use it for their dust baths, meaning that soil will transport elsewhere and you'll need to replenish the sand. You can kinda suggest where they do it (they prefer overhung spots that don't get rain, so it stays dry and dusty) but like cats and cat beds, they decide where to do it. I intended the under-coop space to be used for this, but they decided they like under my gazebo-tent was preferable.


I shall forward your message to my township officials. :-)

Seriously, though, I have to abide by the local ordinances.


I actually live downtown in a small city. We have a small backyard but enough room for hens. They make minimal noise, much less then dogs. And they not make cause any unpleasant odors.

In the 9 years we have had the hens, no one has complained. However many people bring their kids by to watch them through the fence.


I have a similar setup, but used an actuator for the door, so it can't be pried open by a racoon. I use Home Assistant rules to open and close the door according to readings from a light sensor in the coop.


This. I have had a gravity based door mechanism for 2 years and eventually your door gets jammed. I started with one limit switch and calibrated number of turns, but even that over time started to get into weird conditions.

Cheap linear actuators from Amazon with built in limit switches are the way to go IMHO: https://www.amazon.com/ECO-LLC-Actuator-Mounting-Brackets/dp...


We bought something similar to that as a kit you have to assemble yourself. I additionally hooked up a Unifi camera pointed at it so my parents can check if everything is alright.


This is really cool. I wonder how easy it would be to add 'chicken detection' so that the door doesn't accidentally close on one.


One thing I see at the very bottom, where it says "Tutorial, here is a video:" There isn't a video, just an image.


At at end of that sentence there is a "//todo".


I hope the door has a little klaxon and red bubble light while it operates


How do you not have photos (or a video!) of the finished project in operation??




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: