Chicken Coop Controls

During the summer our chickens are housed in moveable "chicken tractors". These are 4 foot by 10 foot cages that can be easily moved to provide fresh grass, weeds and bugs for the chickens. Most of them also get to run free during the day and are put back in the tractors at night for their safety. The winter is another story. Last year our chickens spent the winter in our big greenhouse. It is 30' by 48'. The ground in it never froze and life was much better than being outside or in a stuffy chicken coop. On the really sunny days it did get too hot and the chickens looked like overheated sun bathers. This year a small number of chickens are being over wintered and they get the small greenhouse. It is 4' by 10'. So far it seems to be a bit cooler than the big house but we could still overheat the birds so I wanted to automate vents to keep them cool. With small adjustments to can be used to vent the greenhouse for the plants in the spring and summer too.

If you want chickens producing eggs in the winter they need the right environment. That is longer periods of light than the short winter days provide, warmer temperature, reasonable humidity, water not ice and feed. I have set up my Arduino project to address a couple of the issues.

I wanted a fairy energy efficient and time saving way to make it nice for the chickens. The light is already on a timer and I didn't have a real time clock for my Arduino so the old fashion timer still runs the light. My wife still fills the watered and feeder when she collects eggs. We have an electric heater for the waterer but I wanted to not just let it run 24/7. I also wanted a way to cool, heat and ventilate the coop/greenhouse.

Be careful if you build something like this as it deals with 120 volt line current. It can kill you if you stick your fingers in the wrong place when the system is powered up.

The original plan was to have small geared down stepper motor open the two triangular panels at the upper ends of the greenhouse for cooling and humidity control based on an air temperature and humidity sensor. I was also going to turn the water heater on only when the water got close to freezing. The stepper motor didn't have enough power to open the vents so I asked on a local email list is anyone had actuator from an old satellite dish. I didn't get any of those but I did get two offers for antenna turner motors and a hospital bed actuator. This project is using the actuator.

Inside the box

Here are the components mounted in a 6" by 6" box.

Assembled box

The box has 110v power supplied through the orange extension cord, a temperature and humidity sensor, a waterproof temperature sensor, a 110v extension cord switched output for the water heater and a connector ( 110v) for the hospital bed actuator. There is also a small red button switch on the face of the box.

Electrical box support on rafter

Box mounted with cord to actuator

Wires for power in, power out to water heater, temperature sensors

East vent opened by rope from the west end vent

Temperature sensors down at chicken level

The roster looking after his hens

Parts for Coop Controller

The Arduino sketch is attached below. It requires the following libraries;

dht11.h for the temperature and humidity sensor

OneWire.h and DallasTemperature.h for the one-wire temperature sensor. The sketch has comments throughout that should explain most of what it is doing.

The actuator that opens the vents goes from fully extended to the close position in 45 seconds. There are no limit switches to turn off the motor at either end of the travel but it does freewheel. The Arduino has no way of knowing the position of the actuator at start up. I ended up installing a momentary switch which when pushed will retract the actuator. It will also reset my position variable to zero or the closed position. During operation the sketch moves the actuator out out in in 5 second increments once every two minutes. The sketch keeps track of the position by adding or subtracting 5 from the position variable. Originally I had the sketch just retract the actuator for 45 seconds to make sure it was in the closed position but no knowing how the actuator handled the slipping when fully retracted I decided to go with the push button. The set up of the button is a little weird. It doesn't make the pin go high as I would normally expect of a switch but goes low. The sketch turns on a built in resistor on the button pin so it is normally high. When pressed the button connects to ground so it goes low. The two pins for the switch are connected to the digital pin and ground.

In the loop section of the sketch the state of the button is checked every half second for two minutes, 240 times. If the button is pressed the actuator is activated until the button is released. Once every 2 minutes the temperature and humidity is checked and based on the results the vent is opened or closed. The water heater is also turned on or off based on the temperature of the water in the chicken waterer. For right now the humidity in the coop is being ignored. It was cold and rainy the day I got the system working. The humidity was close to 100% in the coop and less than 40 degrees F outside. The vent started to open. I figure the code needs to prioritize its need to open the vent and not do so if the temperature in the coop is too cold already. The outside humidity may need to be checked and if it is as high or higher than inside not open the vent.

Connections for the sensors and relays are fairly straightforward.


There have been a few modifications to this setup over the years. A fan was added to the vents in the peak to get more air circulated. It will also be getting a window security switch added so the vent can figure out at startup where it is and not have to wait for the user to rest it to the closed position. The temperature sensor, dht11, has been a little flakey recently so that will be replaced with a DS18B20.

Check out the material list and the cost of the Arduino. They are a lot cheaper now.

Original code


More recent code with a fan control.