Maybe you are under the impression that only roosters, not hens, can make a lot of noise. You would be mistaken. Although roosters crow more loudly than hens cackle, the cackling of hens can sure wake you up, or your neighbors for that matter. This is a lesson we learned after we bought 6 Wyandotte chicks, a pretty and rather large breed of chickens. From the internet we learned that roosters will start crowing at 6 months of age. Ours started at 4 months. After a visit from one of our neighbors, I started contemplating making an automated door in our chicken coop. But the need for such a device went away when our two roosters ended up in our frying pan. After that, we had no noise problems with our four hens, until they started laying eggs. Again, one of our neighbors, another one this time, came to our door with noise complaints. The hens would get out of their coop at 5:15 am and start cackling loudly. As we sleep on the other side of the house, we weren't aware of this. I promised the neighbor I would keep them inside until at least 7:00 a.m. and he was happy with that. But now I had to make some haste with getting the automated door, since I don't want to go outside at 7:00 every day. On this web page you can read all about how I created the hard- and software for a motorized chicken coop door. Perhaps you have a similar reason as I had for needing an automated door. Or, you may want to prevent foxes or ferrets getting in the coop at night. Or you may want to protect your chickens from the cold. Regardless, the software is easy to adapt to handle a number of use cases. The hardware is cheap and, as it turned out, pretty reliable (in a trial of one).
I started out with putting my requirements on paper. In a nutshell:
* I want to keep the door open as long as possible for fresh air, but close it before the chickens want to go outside. In practice this means that the door has to go down some time before sunrise. (But not in winter, when they go outside before sunrise, we found out.)
* The door has to be controlled by moving up and down a fixed period.
* For improving reliability, the software must be able to handle sensors that detect the up and down position of the door.
Before I started writing code, I made a state machine diagram that captures the behavior of the software. The image below shows this diagram. A state machine diagram shows the various states the system can be in and the conditions that trigger a transition from one state to another. Having this diagram made it a lot easier for me to write the core functionality of the software.
What I also included in the software was:
* A Wi-Fi client that connects the system to the internet.
* A web server serving up a page that allows me to move the door up and down.
* An NTP client that reads the current time from the internet.
* Code for reading the temperature from a Bosch BME280 weather sensor.
For my first experiments, I used a DC motor I took from an old printer and a small motor driver. I stuck all the parts I thought I would need on a breadboard and started making the software. Here a photo of this experimental setup:
This worked very well for creating and testing the software. But this motor is absolutely too weak for lifting the actual door of the chicken coop, which is a triplex board of 300 x 200 x 4 mm. For this I found a motor with a built-in transmission and a really high torque that can be run on 12V.
The second important element is a microcontroller to control the system. I selected an ESP8285 for this task and it works very well. It is also extremely cheap, just a few euros on the well known Chinese websites. I used the Arduino development environment to write the software. It's not the best IDE, but it's free and does the job.
The full list of hardware is:
* Aslong JGB37-3530 12V DC motor with built-in transmission - 20RPM
* L298N Bipolar stepper motor and DC-motor driver
* ESP8285 Development Board
* 12-pin header for...