Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Building an automatic chicken coop door opener (iotforall.com)
126 points by PascLeRasc on Nov 26, 2018 | hide | past | favorite | 83 comments


Reminds me of the story of a farmer asking if an engineer can help him identify sick ostriches on his farm. So to identify a sick ostrich, it doesn't eat anymore, so the engineer develops a tilt sensor that you strap to the ostriche's neck, and if it doesn't tilt enough times a day the ostrich didn't eat and a LED would light up red indicating the ostrich is sick and requires the farmers attention.

Now the problem is to separate the sick ostriches from the healthy ones. So the thinking is you connect the ostrich camp with a narrow passage to another camp, and put out food in the other camp and as the ostriches move to the new camp you capture and divert the sick ones.

Turns out that when you put out food in the new camp, only the healthy ostriches will move to the new camp and the sick ones will stay behind because they are in any case not interested in food.... which negates the need for engineer and his sensor in the first place :D


That reminds me of this story about removing empty boxes from a production line.

https://userweb.cs.txstate.edu/~br02/cs1428/ShortStoryForEng...


> and six months (and $8 million) later a fantastic solution was delivered — on time, on budget, high quality and everyone in the project had a great time.

I don't believe this story


Funny, but obviously not real. If the guys were tired of "tired of walking over every time the bell rang", the number of defects detected wouldn't be 0.


1.Bell is ringing too much and people are tired of walking over: defects > 0

2.Put fan there to blow empty boxes: now defects == 0

I don't see the problem.


Yea you would put the fan before the check point so the line doesn't stop.


I love stories like this. I've heard that software brains love complexity and tend towards complex solutions when given half a chance. But after you've been burnt too many times with unmaintainable systems, the long piece of string with a couple of pulleys suddenly becomes the best solution. Even if it doesn't come with an app!


I was thinking this too. The 80/20 solution is a long rope that extends to a window so you can open/close it without going outside!


> NASA did start to develop a space pen, but the costs soon spiraled and when the agency came up against public opposition the astronauts reverted back to using pencils.

http://www.physics.org/facts/apollo-nasa-pen.asp


I've had my own design of one of these up and running for about 5 years now. I should probably write it up.

I used a normal (non-stepper) motor with some gearbox I found in an old cassette player. The door limits are detected using reed switches.

It is solar powered, with a 12V lead-acid battery. I've had to replace that twice over the 5 years because winter tends to kill it. Since then I've added a winter trickle charge wire from the nearest outbuilding.

The solar panel voltage into an ADC provides the daylight reading. An Arduino Nano provides the main control functions. It spends a lot of time in sleep mode, waking every 5 minutes to check light levels, and at night sleeps until a preset time when it makes sense to start checking for daylight again.

It also has an XBee radio link to a Raspberry Pi which sends me email updates, keeps the Arduino's clock accurate (obviating the need for an RTC), and alerts me of any mechanical problems with the door mechanism. A common one is straw and other mess getting jammed in the door runners, and once a broken door mechanism.

Over the years I've tweaked the opening/closing times to account for the hens' habits, and for predators. I've learned that the dawn/dusk opening technique is not enough on its own, it needs to know the time of day also.

It opens at 6:30am or first light, whichever is latest. Too early in the summer and you're asking for fox trouble, and also the neighbours used to complain the cockerel would crow when it opened too early (sunrise can be before 4am in midsummer).

My hens go to bed very early, so it closes before dark, and again at least by 7:30pm in the summer because foxes can be active by then.

We live in the country and almost everyone near me has hens, but they rely on manual opening. They have all lost their entire flocks to foxes at least once in the time my automated door has been operational, but thankfully we have not. I have seen scratch marks on the sliding door indicating interested predators, but I think my timing is right to keep the coop closed when foxes are about.


"We live in the country and almost everyone near me has hens, but they rely on manual opening. They have all lost their entire flocks to foxes at least once in the time my automated door has been operational, but thankfully we have not. I have seen scratch marks on the sliding door indicating interested predators ..."

We live on a very small island of private property inside a huge expanse of open space / wilderness and thus have very heavy predation on any animals we raise.

In the case of our chickens, I just kept adding hot wires to the fence until nothing could get into the run. There are four hot wires now, two of which form a negative (back bending) slope. It is impossible for a thing to climb the fence now without touching (and holding) at least two hot wires. We've had our current flock for over a year with no losses, vs. losing every previous flock to raccoons and weasels every 2-3 months.

I wonder if you would comment on this (seemingly successful) strategy - you seem to know what you're doing...


The problem with fences is the underground part. I have relatives in France whose chickens were all killed by a fox digging under the fence.

They say you need as much fence under the ground as you have above it.

Your problem with being really isolated is that the predators will not be afraid to come out in daylight. If I were going for a tech solution I might start thinking about detection systems...

Or maybe just dogs?


If I was building it now I'd use an ESP8266 to replace the Arduino, XBee and RPi for a faction of the cost.


I'm wanting to use the ESP8266 more but most things I want to interface with are 5V so it is a little annoying have to incorporate logic level shifters. How you found an easier way to deal with it?


I believe lots of people have found it will cope with 5V but of course that's out of spec. They're only a couple of dollars if you burn one out though.

I guess it comes down to how much hassle it will be for you if you need to replace the ESP8266.


That's the same problem as Raspberry Pi. For output-only digital signals there are some 5V peripherals that will accept 3V3 input levels. And for input-only, you can use a potential divider.

It's bidirectional where you need a proper level shifter. But you can get really small cheap ones. I've used them a lot on I2C interfaces. If you're careful you can design the entire system around I2C and then you only need a single level shifter.

But I've not built many things around ESP8266 just yet. Still learning about it. It's an incredibly cheap and powerful platform though.


If you're still having problems with the lead-acid battery, you might want to try swapping it out for NiCads at some point. The battery packs from cordless drills often contain these; they're just a bunch of 1.2v cells in series so you can always adjust the voltage manually.


Do you mean NiMH? NiCads are pretty outdated at this point. The cost of 18650s is so low now that I'd skip NiMH too. You can get free 18650 cells by going to your local landfill / dump and grabbing discarded laptop battery packs. They typically have a few bad cells with the rest reusable.


NiMH is a fantastic technology, but there are still advantages to using NiCad. NiMH batteries are notoriously fickle because it is very difficult to detect their charge state based on their voltage. Many chargers will just charge at something like 1.5V / 1A for an hour or two and expect you to drain the batteries between charges.

NiCad batteries handle 'trickle charging' much better than NiMH ones, which usually degrade significantly with overcharging. So NiCads are still used in places like alarm backups, power tools, or off-grid applications where they might be connected to a charging circuit for long periods of time between discharges.

And 18650 cells are great, but I would think carefully about using li-ion or li-po chemistries in areas where they will be exposed to the elements and unsupervised.


>It also has an XBee radio link to a Raspberry Pi which sends me email

Nice. Slack is great for this sort of things and adds additional mute channel functionality for normal events. There is the odd service (eg Freshping) that will check it can ping your Pi, even when on your on a dynamic IP, and alert you to outages. Results also sent to Slack but not muted. I hope you have all the bad puns configured for your notification. “Chick in”, “chicken out”.


+1 for the Slack idea - never even considered it.


Their webhook documentation and setup is fantastic.


I wonder how much extra battery/computing power would be necessary to get a camera outside which could detect the immediate presence of a fox. Or maybe a simple motion sensor that would halt opening until there had been no motion on the outside for at least 15 minutes.


Yes I came pretty close to adding a PIR, but that was actually to catch rats that were coming in and stealing eggs. A camera with IR LEDs would work equally well, esp. if activated by a PIR.


Im glad that works. By me a fox will show up at like 2 PM and dart out across the lawn to try and grab something. Thankfully it doesn't come by very often, but at the same time it means catching that mofo is near impossible.


Wow, that's bad news. Whereabouts in the world are you?


Anyone interested doing something like this, I've also done this with a esp8266 and a linear actuator. Detailed how to:

https://blog.garble.org/arduino-chicken-coop-hardware/

https://blog.garble.org/arduino-chicken-coop-hardware/

I've installed a few of these now and love em


> If price weren’t a constraint, I immediately would have chosen a cellular IoT board like the Particle Electron or Boron ($50). Connectivity to the cloud provides several advantages:

I think we should question whether tech as a whole is moving in the right direction when the first question for building a time-controlled, battery-operated chicken door opener is "how do I connect it to the internet?"

(Sorry for the sarcasm, otherwise, it's a really cool project though)


If I am allowed some sarcasm as well, that is anyway the "old" approach, a more modern one would involve (besides the connection to the cloud) a camera, a database of "known" chickens and an AI (possibly a neural network) to identify (besides matching the actual authorized chicken wanting to enter with the image in the database) "chicken like" animals from "fox like" and similar ...


i mean, yes? but also his concerns around clock drift and email notifications are legit.


He could probably synchronize his RTC to the GPS system. GPS works by sending a clock signal plus satellite ID from each satellite. Devices using GPS then use an ephemeris to determine the location of each satellite and then calculate the relative position of the receiver.


There are also time signal radio stations like WWVB, which are used by millions of devices to sync their clocks.


My coop is outfitted with one of these automatic door kits: https://chickendoors.com/product/right-standard-pullet-shut-...

It opens at daylight, closes at dusk. Adjustable tolerances in either direction which I need to adjust occasionally but not often, like after DST changes to allow the door to stay open longer while the chickens get used to the shorter days, ensuring they can get inside before the door shuts, with darkness falling earlier. Small solar charger and battery keep it operational.

I understand the impulse of the author to design something complicated, but practically speaking there is no need to remotely control the opening of the coop door over the internet, especially if you have a photoresistor already to detect daylight.


Not sure I understand; if the coop is opening at dawn and closing at dusk, why does it need to adjust for DST? From the chickens' perspective, the sunset time doesn't change substantially at the moment of DST change.


Nice project!

Needs to be battery operated and last for at least two weeks (14 days): UNOs are notoriously power-hungry. It's highly unlikely that 4 AA batteries can power an Arduino UNO full-time AND open/close the coop door. Maybe with some advanced deep-sleep-cycle, but I'd love to know more about this.

I also fail to see why he didn't use a cheap ESP-board. They're usually cheaper than Arduinos (as in: below 5 bucks), have an onboard WiFi chip and they run Arduino code just fine. You get a couple of pinouts less, but since he's only using a sensor and a stepper motor this won't be a problem.

If I were to make this, I'd go with a nodeMCU and a cheap solar charging setup. Probably would fit in the budget, too.


> UNOs are notoriously power-hungry... Maybe with some advanced deep-sleep-cycle, but I'd love to know more about this.

The naive Arduino code has two basic functions setup() and loop(). Putting your main code in loop results in a busy wait that spins up 100% of the CPU all the time. It's also running all the peripherals all the time.

You want to use "avr/sleep.h" and "avr/power.h" to put the processor to sleep with peripherals off (except the one which will wake up the processor). See http://www.gammon.com.au/power for a nice tutorial. Opening these headers and their source in the avr-gcc libraries and comparing to the documentation on the processor is a good exercise in getting right down to the metal of how the processor manages power.

You also want to get rid of the ancient 7805 regulator; many clones use a better LDO voltage regulator to alleviate the problems with high standby current.


He also seemed very concerned about the cost of an RTC module at ~$15 but they're readily available for less than $1.


Really fascinated by this kind of stuff, but getting into it seems really overwhelming. I think it would be something really fun for me and the kids to do together, does anyone have any personal beginner resources to recommend?

Of course I'll do the googles too.


Like software development the best approach is to learn a concept at a time and then put them together into something bigger. Start off just with an Arduino and some basic LEDs and switches - that'll teach you the basics of connecting things together (if you're really at the beginning don't even involve an Arduino, just get do it all on a breadboard). Once you're comfortable with that maybe add some more exotic inputs and outputs, like light sensors and motors. After that maybe replace your Arduino with an ESP32 which will give you wifi and bluetooth to interact with your system.

Once you've spent a while doing that you should be in a good place to start on more complex projects - there are a few robot kits designed to have a Raspberry Pi mounted on them to make them programmable, or maybe look at ESPHomelib[1] to do some home automation.

[1] https://esphomelib.com/


You might want to seek out a local maker space? Is the USA these aren't too uncommon. Or, with the kids, take things apart and rebuild them, modify them. Unscrew, unclip, use a solder iron to remove components. Hours of fun. Maybe since we care nowadays, first check (google) for toxic materials such as Asbestos or lead or mercury.


Adafruit has some great tutorials and beginner-friendly videos to teach the basics - the portable trellis soundboard is a fun music-related one


Very creative and useful project. The Internet of Poultry (IoP) has finally arrived:)


Honestly, farming is probably the place where IoT makes the most sense. Especially for very environmentally sensitive processes like winemaking, large sensor networks and data analytics offer a lot of value to the farmer.


It won't be too long in the future when the most productive farms are run by a couple local people who maintain the equipment, and every current labor-based task handling the livestock or produce is completely automatic. Imagine the power of knowing exactly every perturbation that a given crop or animal might have experienced and compare it to its yield. Eliminating variables like the productivity of the individual farmhand would go a long way to better control and extend our food supply.


You can do a lot of the same stuff with Bluetooth Low Energy and avoid putting your entire winery on the internet. I really like BLE because it's a very straightforward set of protocols for building sensor networks and sending/receiving data.


LoRa is probably the way to go for farmers, given the range requirements. No need to connect to the Internet regardless.


Great project and all, and definitely something fun to work on, but this is a pretty questionable application for IOT (don't wish to discourage).

What's the key metric here? The chicken coop opens and closes at the appropriate time of the day? How does IOT help solve that objective? There's some great parallels here to an MVP in the software world.

As for my two cents, an alternative and more robust solution, could be put together with something like an aliexpress ambient light switch, limit switches, a recycled car battery, a trickle charge solar panel, and some relay logic.


I'm unclear on why this is a questionable usage. My wife keeps chickens, and going out morning and night to open the doors is...certainly not hard, but inconvenient (particularly the night one, as you often remember AFTER you've settled in for the night and must head out, regardless of weather.

Skipping the occasional visit doesn't work either - they need to get out both for general happiness and foraging, and if you don't close the door, creatures kill your chickens. (This has happened to us twice, and we're in the middle of suburbia, albeit the Seattle variety with more wildlife than the average cul-de-sac)

> The chicken coop opens and closes at the appropriate time of the day?

It's closed sometime after chickens have entered for the night, which tends to go off of sunlight, and opens early enough that the chickens aren't literally cooped up when they want out. That's rough, but the machine doesn't have to be perfect, it just has to do as well or better than we humans do.

As for what value does IOT add? Well, it can help confirm when it is/isn't working, but mostly it's that the cost is almost the same, at least for those of us without extensive electronics experience. Your alternative (I'm not sure how it's more robust) solution LOOKS cheaper, but I wouldn't know how to connect the parts and would likely screw up the amps/watts enough to break stuff and require replacement parts. For me, spending an extra $50 on parts is worth the saved time and effort - even as the $250 version that has no options for customization of behavior/interactions is NOT worth the saved time and effort.

Probably - it should be noted I've been researching this topic (along with any way to ensure the chickens ARE all inside - if they get broody they may nest elsewhere, which ends poorly) for the past year but so far we're still doing it manually. I expect this to change over the holidays.

> There's some great parallels here to an MVP in the software world.

Only in the vague "is this adding enough value to be worth it?" sort of way, but as the answer is "it depends" I'm not seeing the great learning opportunity you're implying.


I have no qualms with the merit of an automatic chicken coop door. Obviously the benefits can be considerable, and the project certainly fits the bill.

The point is, almost all maker projects jump straight to let's throw an Arduino at it, with no consideration to the tradeoffs at all. This can be quite a disservice.

There are tradeoffs, eg. power management? (those batteries aren't going to last at all), fault tolerance? (arduino crashes due to condensation shorting out the timing crystal), maintenance? can you instruct an untrained individual to perform any meaningful repair work (eg. bend the arm on a damaged limit switch).

One benefit IOT can bring, is the detection of fault conditions etc (door took too long to open fully something stuck in the tracks), but implementing that kind of handling in a meaningful way is a complex problem.

These things rarely matter for a diy project, but you see this stuff everywhere. Consider whether a problem can be solved in an analog or mechanical manner, it's likely to lead to a simpler and more robust solution.

As for ensuring chickens are inside of a coop, that's a tough problem and I'm interested to hear your thoughts on that?

Eg. for the above chicken in coup problem, something as simple as a weight triggered switch on the ramp (or a push bar near the coop opening) is likely to out perform anything more complex.


> I'm interested to hear your thoughts on that?

My thoughts are definitely too complex. Currently I'm thinking of a camera that will turn on a light and take a picture (at a specified time || when door closes) and send that to our family Slack - someone will habitually look at any notification, and we don't have a large number of chickens so it's fastest to rely on human perception to see if someone is missing. Or just a camera that we can turn on remotely to check the feed ourselves.

That's the "simple" version - a more complex one would take a picture and compare to an empty sample to decide how many blobs there are, but that is hampered by (1) If chickens huddle, that becomes complex and (2) it's not a problem space I have any interest in, so the problems won't be fun to solve.


Vision sounds like a really tough way to solve it, challenging lighting conditions just to make things trickier.

I know that in some contexts, RFID tags are used for livestock tracking. Don't know if they would comfortably work on birds though.


I think IoT here actually meant DIY electronic... at least I can't see anything in the article that says this was connected to the internet at all.


Fair enough, I got the impression the target audience was more IOT focused given the site it was hosted on.


I think the author considered an IoT solution, but he did go for a simpler one (Arduinos by themselves can't connect to anything wirelessly).


How does the track mechanism work? Is that just a string being wound around the motor shaft?

I've been playing around with Arduino and find the electronics easy but it's really hard to get good information about linear motion in terms of what parts to get and what wheels / accessories are compatible / needed with what tracks. Very few resources out there and I've ordered so many incompatible tracks, wheels, carriages, etc because I couldn't find any information on what mates with what.


I used a raspberry pi, a controller board and a linear actuator to create a similar solution. I also coded up the door lock, but turns out the linear actuator has enough resistance to stay closed on it's own.

https://github.com/HenriPro/ChickenCoopDoor


Cool project, but is it a failure for one of the requirements being that it costed under $50 and title says it costed $100?


I believe it was $50 for the door and the remaining $50 was for the parts.


Depends what you value your time at, but I've had two ChickenGuard automatic door openers for years now, and they've worked perfectly: https://www.chickenguard.com/


I'm glad it works, but this is the exact product I thought he was trying to avoid buying. While a lot of thought and development probably went into chickenguard, it ain't cheap.


The range of prices is £95.83 to £129.16, not including shipping or the door kit. Higher than DIY, but seems reasonable to me.


If they only lasted a year, I would have said they were a rip off. However, we've had ours 4-5 years now, I think? Only thing we've had to do is change the battery and I think twice untangle the cord that raises the door - probably because a chicken banged the door and caused a loop in the string.


Heck, why not just go to the store and buy some eggs?


The taste (not to mention the color) of store-bought eggs aren't up to par. Eggs from own free-range chickens are simply... better.

Also, chickens are really fun animals, and they taste nice too.


I agree! But my comment was sarcasm/extension about his suggestion to reduce effort by buying a commercial door opener. Like damn, if you’re not going to make your own door opener with an Arduino, are you truly even committed to raising chickens?


I got the sarcasm and found it highly amusing, more so with the amount of comments about egg quality!


Ha ha. Fair point. And it might be only a couple of hour's work for the OP. For me it would take a week or two and a fair bit of swearing.


Do'h! Didn't get the sarcasm.

Now I have to build an automatic door opener to prove my commitment. :D


Because there's simply no comparison in taste. Supermarket eggs taste like plastic in comparison to home-laid ones. Plus the hens recycle all your waste food into fresh eggs daily. What's not to like?


I’m sure! I am all about slow, organic and natural food. Here though my comment was meant to say that heck, if you’re going to cut corners and buy store-bought door closers, why not raise your own chickens at all!? I wasn’t entirely serious. The point of DIY is DIY, though, and this is HN.


Why do anything if you're not willing to do everything?


This project probably had a negative cost.


We've been using https://adorstore.com for years for our turkeys.


The biggest problem is to convince chicken to go sleep at the coop instead in its favourite tree.


I'd be very surprised if the motor and electronics last a season without fault.


Annoyingly, doesn't mention how it counts the chickens. :)


It has a light sensor, so it assumes that once its dark enough, the chickens will have come inside of their own accord. Based on chickens I've met, this is probably accurate.


When I did it, I just closed the door at ~nautical~ civil twilight. The chickens come home to roost before that, and the predators (raccoons) generally were later than that.

My design was Raspberry PI -> sensor/power board -> battery powered drill. And an extra long usb cable to get the wifi dongle to the other side of the roost, because when the chickens were in the coop, they absorbed enough wifi signal to make it drop off the network.

Edit -- changed which twilight. Also, code here: https://github.com/wiredfool/coop-door

Unfortunately, schematics and physical door design are lost to several moves.


TIL chickens are wi-fi jammers


All sacks of meat, humans included, are to some degree. We're made of a lot of water.


our neighbor had an automatic door and the coyotes learned what time the doors opened.

They were first in line for breakfast.


Where is the video? (I'm on mobile Safari)





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

Search: