Automated Chicken Door

Automating the opening and closing of the chickens door reduces the mental payload and gives more freedom. It also makes the chickens more safe as humans might forget to close the door in the evening.

This is the very definition of progress: making life easier.


Solution Price Plus Minus
12V timer ~10€ Easy to set up, reliable Setup has to be changed over the year ; 12V powering needed ; Power consumption ?
Arduino mini + electronics ~8€ If battery/solar powered, the board has to be modified to reduce the power consumption ; Electronic circuit has to be built and programmed
Analog electronics ~5€ Low power Electronic circuit has to be built


Solution Price Plus Minus
Electric car antenna ~20€ Easy to integrate
Winch actuating a sash ~10€ Can be built with broken electronics Has to be built
Servo-actuated self-locking door ~10€ Complex to build


Solution Price Plus Minus
Solar panels ~5€ Energy self-sufficient ; Coop easy to displace Requires low power electronics
Power adapter ~5€ Stability Requires a power line
Rechargeable Battery ~15€ Coop easy to displace Inconvenient ; Requires low power electronics

As we try to reuse the tings we have and to buy as less as possible, the solution depends a lot on the material already available.

Function Selected solution Why
Controller Analog electronics low power, low cost
Actuator Winch actuating a sash no cost because reused materials
Power Solar panels we can reuse solar lightings for garden, can be moved, energy self-sufficient

The total cost will only be around 5€ for the electronics. The drawback to this is the time demanding construction work.


The photo-resistor is a component which resistance depends on the quantity of light illuminating its sensitive area. During the day, its resistance drop to below 100ohms, while during the night, it is higher than 100Kohms.

The photo-resistor is placed in series with a fix-value resistor. The tension between both components (V1 on the schema) is higher during the day, and lower during the night.


The tension V1 is compared to two fix tensions V2 and V3. If V1 > V2, we consider the state to be “day”. If V1 < V3, the state is “night”. This is done by two comparators. Below is the output of both comparators depending on the voltages.

V2 < V1 V3 < V1 < V2 V1 < V3
day undefined night
V4 6V 0V 0V
V5 0V 0V 6V

Limit switches

When the state becomes “day”, we want the door to open. This means, that the motor turns in one direction, but only until the door is open. This is why the limit switch S1 opens the circuit and stops the motor when it detects that the door is open. Similarly, the limit switch S2 stops the motor when the door is closed.


The H-bridge is composed of 4 BC547 transistors. It allows the rotations of the motor in both directions. When V4 = 6V, and S1 = closed, the upper left and the lower right transistors are activated, a current is flowing through the motor from the left to the right, thus making the motor turning in one direction. The two other transistors activate the other direction.

If the system is powered by a battery or a solar panel, an energy analysis can be done to be sure of the feasibility, or to be able to improve the design.

Energy used by the motor

Parameters we need to know:

Current measured through motor while door is lifted I_motor = 100mA
Voltage powering the motor V_motor = 6V
Time measured to open T_open_door = 10s

First we calculate the power drawn from the motor:

P_motor = V_motor * I_motor = 6V * 100mA = 600mW = 0.6W

Then we can calculate the energy used by the motor to open the door:

E_open_door = P_motor * T_open_door = 0.6W * 10s = 6W.s

This energy can be converted in W.h:

E_open_door = 6W.s = 6/3600 W.h = 1.6mW.h

As the door needs to be closed as well, we just double this value to get an approximation of the total energy used by the motor per day.

E_motor_per_day = 2 * E_open_door = 3.2mW.h

Energy used by the electronics

We try to use resistors having high values to reduce the power they use (0.07mW in total). As a result, the component consuming most of the energy is the comparator. This is why we use the an ultra low power comparator draining as little as 0.05mA. More information can be found in the datasheet.

P_comparator = U_comparator * I_comparator = 6V * 0.05mA = 0.3mW
P_electronics = P_comparator + P_resistors = 0.3mW + 0.07mW = 0.37mW

Energy used by the electronics per day:

E_electronics = P_electronics * 24h = 0.37mW * 24h = 8.9mW.h

We can see that it is the same order than the energy used by the motor. While the motor consumes 2000 times more power than the comparator, it is used only 20s a day, while the comparator is always on.

Energy available per day

The solar garden lighting give approximately 4h of light every night. From this information, we can estimate the energy available per day.

The LED is powered with 1.2V and consumes 30mA. We can measure this with a multimeter.

P_led = V_led * I_led = 1.2V * 30mA = 36mW
E_led_per_day = P_led * 4h = 36mW. 4h = 144mW.h

The batteries of the garden lighting have a voltage of 1.2V (can be read on the package). As we want to power our system with about 6V, we have to use 5 garden lightings, and to connect their batteries in series.

E_available_per_day = 5 * E_led_per_day = 144mW.h * 5 = 720mW.h



E_motor_per_day 3.2mW.h
E_electronics_per_day 8.9mW.h
E_used_per_day 12.1mW.h
E_available_per_day 720mW.h

We are happy to see that more energy is available than used. The security margin tells us that after one normal sunny day, the system can work without additional energy for 59 more days, which is very good.

Security_margin = E_available_per_day / E_used_per_day = 720mW.h / 12.1mW.h = 60

Due to difficulties in debugging and maintaining the old chicken door, a new version has been built utilising an Arduino Nano. The operation of the system is much the same - The door is actuated by a 12V DC motor when the voltage of a photoresister hits a specific value, and the turning of the motor (thus the opening/closing of the door) is stopped with a limit switch.


The design consists of the following components:

  • 1x Arduino Nano
  • 1x Photoresistor
  • 1x 15K Ohm resistor
  • 2x Hartmann MBB1 micro switches
  • 1x TI L293D (for driving the DC motor)
  • 1x 12V DC motor with gearbox for torque


A sketch of the design can be found below:


The Arduino code can be found here. It is relatively well-commented and fairly straightforward in its operation. It is contained as a PlatformIO project, which provides a collection of useful commandline-based tools for working on Arduino projects. In order to build and run the code, it is necessary to download and install PlatformIO.

Once PlatformIO is installed, clone the repository.

$ git clone

To build the code without uploading it to the Arduino (which is useful for testing the correctness of your code), use the following command

$ pio run

If this runs without any errors, it can be uploaded to the device in the following way: $ pio run –target upload –environment nano. In addition to this, one can monitor the serial output of the Arduino device with pio monitor.


The DC motor is powered by a 12v power adapter, and the Arduino by a USB cable plugged in to a mains adapter. The entire ensemble sits inside the chicken coop to protect it from the rain. In theory, the powering of the entire thing could be switched to a solar solution - We are in possession of a solar charger/battery in the form of a phone powerbank. It is capable of outputting up to 9v. Without the circuitry to 1) break out from the USB output provided by the powerbank and 2) Step up the voltage to 12v in order to power the motor, it is not currently a viable solution. This is worth investigating in the future, since the current chicken coop is mobile and it would be advantageous to not have it being tethered to the barn.


Generally, the construction is simple - The DC motor is part of a gearbox assembly that is connected to a winch. The winch is connected to the door via some fishing line/monofilament. The photoresistor is fixed in place somewhere useful (Ideally inside but pointing outside). The limit switches are placed in positions where the door will hit them on completely opening and completely closing.

There are two important aspects of constructing and installing the chicken door. Firstly, the position of the motor must be such that there is as little friction when raising the door as possible - failure to do so could end up with the door beingjammed and potentially burning out the motor. Secondarily, the limit switches must be placed fairly carefully such that they are hit by the door when it raised and closed.

Other than that, the construction is fairly simple - make sure to guide cables away from the floor as much as possible - chickens and ducks are curious and like to chew on/piss on/mess with your hard work.


  • Door opens/closes too early/too late
    • This can be resolved by altering the LIGHT_THRESHOLD and DARK_THRESHOLD values, respectively. LIGHT_THRESHOLD is the value to determine when it is 'morning', and DARK_THRESHOLD when it is 'night'. The higher the value, the more light the photoresistor needs to determine this.
  • Door continues to wind up/down
    • This is most likely caused by the limit switches not being hit successfully. I have had some success by adding tabs to the door in order to ensure a successful hit.
  • The cable connecting the door to the winch tends to stray to the sides, causing the motor to jam
    • I have fixed this using two nails placed just below the winch in order to guide the monofilament, so it cannot stray too far from the middle. This seems effective.

Suggested Improvements

While the chicken door offers basic functionality, it could be iterated on and improved in a couple of ways.

  • . Display current brightness. Using a small LCD display it should be possible to display the current brightness received by the photoresistor, allowing us to more easily estimate when the door opens/closes
  • . Manual control. It would be useful to be able to manually control the door in some circumstances - debugging and when one might want to lock the chickens in/out regardless of the time of day. Using two buttons it should be simple to be able to toggle auto/manual control and toggle the position of the door.
  • research/automated_chicken_door.txt
  • Last modified: 2018/04/24 15:44
  • by martinp