[HN Gopher] DIY ESP32 based chicken coop door. Control based on ...
       ___________________________________________________________________
        
       DIY ESP32 based chicken coop door. Control based on time, light or
       via app
        
       Author : thunderbong
       Score  : 120 points
       Date   : 2023-08-30 10:47 UTC (12 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | TurkishPoptart wrote:
       | One thing I see at the very bottom, where it says "Tutorial, here
       | is a video:" There isn't a video, just an image.
        
         | yardshop wrote:
         | At at end of that sentence there is a "//todo".
        
       | dewey wrote:
       | 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.
        
       | finnjohnsen2 wrote:
       | 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
        
         | dekhn wrote:
         | 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.
        
           | [deleted]
        
       | tengbretson wrote:
       | 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.
        
         | nullwarp wrote:
         | 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.
        
       | traviswt wrote:
       | 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.
        
         | hedora wrote:
         | 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)
        
           | traviswt wrote:
           | 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.
        
       | ofrzeta wrote:
       | 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).
        
       | petsfed wrote:
       | 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.
        
       | ukd4ve wrote:
       | 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.
        
         | enachb wrote:
         | 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...
        
       | jack_riminton wrote:
       | "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 ;)
        
         | bbarnett wrote:
         | [flagged]
        
       | btbuildem wrote:
       | How do you not have photos (or a video!) of the finished project
       | in operation??
        
       | xavxav wrote:
       | 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.
        
         | zwieback wrote:
         | 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.
        
         | lhoff wrote:
         | 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.
        
         | sudobash1 wrote:
         | 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).
        
       | leejoramo wrote:
       | This is a project I have long thought to try. Relatively simple
       | task, but requires Designing a reliable system and sourcing
       | quality components
        
         | blitzar wrote:
         | and chickens ...
        
           | fullstop wrote:
           | 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.
        
             | leejoramo wrote:
             | 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.
        
             | uxp100 wrote:
             | 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.
        
               | GravitasFailure wrote:
               | 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.
        
             | blitzar wrote:
             | > 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
        
               | fullstop wrote:
               | 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.
        
               | kortex wrote:
               | 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.
        
               | fullstop wrote:
               | I shall forward your message to my township officials.
               | :-)
               | 
               | Seriously, though, I have to abide by the local
               | ordinances.
        
               | hedora wrote:
               | 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_A
               | nim...
               | 
               | 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.
        
               | kortex wrote:
               | > 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.
        
             | traviswt wrote:
             | 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.
        
               | fullstop wrote:
               | 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.
        
               | lostlogin wrote:
               | Do you think there is a reason they are getting away with
               | ignoring the rules? Maybe you could too - just ask the
               | neighbours first?
        
               | fullstop wrote:
               | 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
        
       | Symbioquine wrote:
       | 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.
        
         | hedora wrote:
         | 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.
        
           | mtreis86 wrote:
           | Limit switches for all sorts of terrible environments exist.
           | These would probably work
           | https://www.mcmaster.com/products/switches/environmental-
           | rat...
        
             | wiredfool wrote:
             | I used something like this:
             | https://www.mcmaster.com/products/lever-
             | switches/subminiatur...
        
           | Symbioquine wrote:
           | 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.
        
           | bagels wrote:
           | 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.
        
       | petee wrote:
       | 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
        
         | Petersipoi wrote:
         | > and love stealing eggs
         | 
         | and chickens.. in my experience
        
       | wiredfool wrote:
       | 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.
        
         | daveevad wrote:
         | > 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.
        
           | wiredfool wrote:
           | Chicken presence anyway.
           | 
           | I tell you the bugs you see when deploying something in the
           | real world...
        
             | djbusby wrote:
             | Field work always finds the "what the heck" bugs that lab
             | work never could.
        
             | thelastparadise wrote:
             | And the chickens will eat the bugs when you deploy them to
             | the real world..
        
         | mk_stjames wrote:
         | 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.
        
           | wiredfool wrote:
           | 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)
        
           | elromulous wrote:
           | 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.
        
           | iamthepieman wrote:
           | 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.
        
           | ofrzeta wrote:
           | It happens that one might get left out and it's no problem
           | unless a predator shows up :)
        
       ___________________________________________________________________
       (page generated 2023-08-30 23:01 UTC)