Kokot: a low energy chicken coop door

This automatic chicken coop door will help to keep your chickens safe

Similar projects worth following
Automatic chicken coop doors help to keep your chickens safe by working on sunrise and sunset hours to open and close.

A chicken coop door is essential and its primary purpose is to provide safety for your chickens from predators.

Kokot is an automatic chicken coop door which works with battery power and solar panel.

It is designed to be as cheap as possible, fully automatic and will be a "low energy" device.

The idea 

Le "100e Singe" is a Third Place, in vicinity of Toulouse, half-farm half-office, combined with an agricultural incubator that welcomes and experiments with new forms of work: cooperatives, collaborative, with meaning and impact on major societal issues.

They built a "portable chicken coop" and asked me if I could design an automatic door... The Kokot project was born!

After a few brainstorming sessions we came to the following key specifications:

  • the door should open/close phased with the sunrise and sunset hours. This seems to be better than classical light sensor. These sensors are prone to "false detection" in case of bad weather (false night) or when illuminated by car headlights (false daylight). 
  • the system should be self powered (no mains into the fields)
  • it should use a rechargeable battery and should be equiped with a solar panel
  • the door should be "guillotine style" for compactness and efficiency (see picture above on right wall)
  • the door should be automatic but should also offer manual "open close" capabilities
  • the whole system should cost less than 40€

Optionnal specifications

  • Kokot should be "smart". That is connected to internet and/or your smartphone 
  • kokot should monitor temperature and humidity into the coop

And of course kokot must be energy efficient to avoid draining the battery and to keep the costs as low as possible (smallest battery, smallest charger, smallest solar panel, smallest motor...)

Video of Kokot running

Here is the door opening: exciting video! But project is working.

And please note that the music is : If I Had a Chicken – Kevin MacLeod 

Motor selection

Regarding the motor's technology we had basically two possible choices:

  • Stepper motor
  • DC motor

A stepper motor would have been a simple device to drive. However it suffers from a major drawback : if not energized the motor would loose its torque and the door may fall down only with its own weight.

Furthermore, these motors do not have a lot of torque and if they loose steps, nobody would know it as they are driven in fully open loop mode.

On the other hand a DC motor, when equiped with a gear box, will have much more torque, could be driven at low speed and will not reverse when not energized (provided that the gear box has sufficient reduction ratio to have "friction").

But these motors are not driven precisely ... unless you add an encoder on the shaft!

This being said we have choosen a small DC motor able to run at a very low 10 to 15 RPM speed. That is 0.25 turn per second (max speed) or 1 turn every 4s.

As you can see it is equiped with a gear box allowing to increase the torque but also to prevent moving when not energized.

This motor is really tiny (the shaft has a 4mm diameter)

It will be driven with a little DC motor driver

The specifications of this motor are not "impressive":

As you can see it is a "low energy motor" which will drain 40mA on a 3V battery. It is said to have a torque of We will see later the reallity.

Selecting this small motor gives the following additionnal specifications:

  • the battery must be a 3.3V one. Which is fine as I wanted the "smallest" one. A single Li-ion 18650 cell should be enough.
  • the apparent weight of the door should be in the range 200 to 300g to avoid stalling the motor.

Finally, these motors are incredibly cheap : less than 5USD...

This motor has been qualified under "load". These tests being successfully passed we could go on designing the electronics.

Energy for Kokot

I wanted to power the door with a single 18650 Li-ion cell.

Knowing that the motor eats 40mA when running and that it should run twice per day during max 30s, we can easily compute the power requirements for such a battery.

To get a worst case I did measure the current while holding the motor shaft. It indeed rized up to 60mA at the maximum torque before stalling and when powered...

Read more »


list of material for kokot V1 (including hall sensor). A few bolts and nuts are to be added to this list !

sheet - 1.16 MB - 06/20/2023 at 10:13



single sided PCB eagle files

RAR Archive - 62.84 kB - 02/07/2023 at 13:42


View all 9 components

  • kokot version 3 (hall effect switch)

    JP Gleyzes06/16/2023 at 09:08 0 comments

    The IR sensor was from time to time blinded by sun...

    I simply replaced it by a hall effect switch.

    I choosed a 3.3V chip with the reference SS49E

    To connect it to the PCB and replace the IR sensor, follow these guidelines

    • short R3 with a copper wire
    • unsolder R4
    • connect the sensor as follows

    Then replace the 3D printed "wheel" by the magnet holder. You will need to glue a "diametrical magnet 6mm diameter, 2mm width"

    Note that the 4mm nut is hidden into the printed part (add a filament change on top of the nut)

    When finished the hall sensor should fly 2 to 3mm above the magnet

    The code of the project remains strictly the same and is still available on my github page

  • Kokot Android App

    JP Gleyzes03/16/2023 at 12:06 0 comments

    As the ESP32 has embeded Bluetooth Low Energy, I have coded a simple Android Application.

    In fact it is very very basic !

     With it you simply can:

    • setup your latitude/longitude (needed for a correct computation of sunrise and sunset hours)
    • setup the margin to open/close your door after sunrise/sunset
    • open or close the door manually (same behavior as the physical buttons/touchpads on the board)
    • log board status

    I must admit that there is a caveat with this app... it only works when the ESP32 is not sleeping and when your are in close range to the board (10 to 20m max).

    But it does the job !

    Source code and .apk files are available on my github kokot project here

  • Kokot PCB version2

    JP Gleyzes02/13/2023 at 14:51 0 comments

    PCBWay is a Chineese PCB manufacturer. PCBWay has specialized in PCB prototype, small and medium batch production. It was founded in 2014, and are constantly growing. With over 15 years’ professional experiences and advanced manufacturing capabilities of their factories, in the past 4 years, their products have been well marketed in 150 countries and used by 250,000 clients around the world.

    PCBWay contacted me end of january and proposed to sponsor my project.

    I indeed rerouted my PCB to have a much nicer double sided design. Then I ordered a batch production. Ordering was very simple: just drop your gerber files into their Quick Order page.

    Then use the online Gerber viewer to check your pcb.

    When satisfied click on the order button and a few days later you get the awaited parcel. Shipment was incredibly fast, parcel arrived at home (France) less than 6 days after ordering!

    Here is the video for the unboxing:

  • Open/close calibration : the "rotary encoder"

    JP Gleyzes02/07/2023 at 16:30 0 comments

    The very classical way to determine "opened" and "closed" postions of the door is to add "home switches" to the door.

    One would be at the bottom and the second at the top of the door.

    Well I started with this solution and soon discovered that the chicken are not "clean" birds so that the floor of the coop is often full of "straw" (not to say shit !)

    Placing home switches into the coop was not a very good idea.

    Instead adding a "rotary encoder" to the shaft has a lot of advantages :

    • no flying wires
    • no electronic part with contacts which could rust of oxydize
    • good precision
    • possibility of detecting blockages of the door

    I thus made a simple wheel with 8 slots. The wheel rotates in front of an IR sensor and sends "pulses" to the ESP32 inside an interrupt routine

    This routine is quite tricky as it has to take into account signal "bouncing" when the slot goes from dark to light...

    But the software implementation is finally very very simple !

    void IRAM_ATTR optical_ISR()    //IR sensor interrupt routine
      if ((millis() - IRtimeout) > 250)
        IRtimeout = millis();
        if (chickenStatus == opening) tops++;     
        else tops--;
        //Serial.println( tops);

     A simple timeout is added into the interrupt... if the signal bounces faster than 250ms, it will be considered as noise, and only the first pulse will be counted.

    Remember that we expect a motor turning at 10 rotations per minute. That is 8*10 = 80 calls of the interrupt every minute... Plenty of time to debounce the switch.

     Note as well that the Serial.println(tops); is commented.... If not it may occur that the interupt wll be called a second time whie printing is not finished... and this will crash the ESP32 (guru panic!). DO NOT uncomment this line if you want a safe behavior.

    Finally here is the schematics of this sensor

    You will note that the IR Led and the phototransistor are not powered directly by the battery, but instead they are powered via a PWR pin of the ESP32. Doing this allows to switch the IR sensor off when the ESP32 is in deepsleep mode. Simply configure PWR pin as "input" and that's it, you save 20mA of the led!

    Ok we have now a way to "count the pulses" when the door opens or closes, but we do not know the absolute posiiton of this door... We have to add a "calibration procedure".

    Calibration of the door

    This calibration will require the help of the user... It must be done once when the door is installed.

    • Start with the door in closed position
    • touch or press the "Calib" button (do not release it)
    • reset the ESP32 (reset button on the lolin lite module)
    • the door will start to open
    • when in the desired "open position" release the calibration button

    That's it the door is calibrated!

    You can of course re calibrate the door any time you want, although it shouldn't be necessary as the calibration is stored into the eeprom of the ESP32 and wouldn't erase even after a power disconnection.

  • Qualifying the DC motor

    JP Gleyzes02/06/2023 at 13:12 0 comments

    To qualify the motor I designed a 3D printed motor mount.

    It's composed of a rotating pulley and two motor+shaft holders. With it,  it was easy to fix a rope and to try to pull "things".

    The conclusion are:

    • the motor can pull up to 300g with this pulley before stalling
    • a safe weight should be between 200 and 250g
    • the motor draws 40mA as specified and at full load and up to 60mA when stalling
    • operation is safe when powered at 4V instead as 3V (specs). So a fully charged Li-ion battery can be used.

View all 5 project logs

Enjoy this project?



peter.guns wrote 04/15/2024 at 21:31 point

Hi, thanks for sharing your wonderful project !

I would like to make your Kokot chicken coop door controller, but I can't find the .apk file to install the App. I think, it's not in the .zip-file. Is it possible to upload it ? Thanks in advance ! Peter.

  Are you sure? yes | no

JP Gleyzes wrote 04/16/2024 at 07:36 point

Oups you are right... My mistake is corrected now:

  Are you sure? yes | no

paulvdh wrote 03/22/2023 at 14:01 point

Quite nice, mechanical projects with motors are surprisingly difficult to get them to work reliably. But I do not really understand the "low energy" part.

With a rolling door you may have trouble with critters pushing it aside and still get in.

But to further reduce the amount of battery energy needed, you can extend the winch axle, wind a second cord around it and use a counter weight of the same weight as the door. (or have a thicker axle on that side and a lower weight counterbalance)

Because it 's completely balanced now, your motor runs near idle current (as long as nothing gets stuck) You can also use a thicker winch axle so the motor runs for a shorter time.

If you want to use a solar panel, then combine it with smart charging. Batteries do not like a lot of charge cycles. so monitor the battery and do not charge it at all as long as it's got more the about 40% energy. Then wait for sunny or at least bright day to charge the battery.

  Are you sure? yes | no

JP Gleyzes wrote 03/22/2023 at 16:20 point

Yes the counter weight is indeed a way to further reduce the power consumption. But at the "price" of a more complex mechanics

Regarding the battery charge, your idea is good but would complexify the schematics to add this logic into the MCU.

18650 Li-Ion batteries are quite robust. My charging circuitry is at low current and power drawn from the battery is so low that it will stay charged most of the time. (which is not the best for a battery but who cares !). I did apply the KISS principle "Keep It Simple and Stupid" !

  Are you sure? yes | no

Chris Tacklind wrote 02/15/2023 at 17:12 point

Fun project.  I hacked one together using whatever was the least effort.  This leaves me pondering the "best way".  

High on my list is the notion that the "work" required to lift the door (=mGh) is significant.  You could try to get it back with regen, but that would be a lot of trouble.  

A nicer way is to just use a round door.  Rolling it side to side requires next to nothing.  A simple crank pair would do the pushing, and provide a "lock open" and "lock closed" feature.  You also get a sinusoidal motion for a soft start and close.  If you really want to show off, all of the mechanism and solar pannels could be mounted on the disk. A single pin would affix the end of the crank to the coop.  The whole thing could be laser cut.  Let me know if I can help.

  Are you sure? yes | no

JP Gleyzes wrote 02/26/2023 at 09:23 point

Right, an horizontal motion is a good option to even more decrease the power needed for the motion. But the mechanics would be more complex and thus would cost more. Also the chicken coop is not a clean place so the rolling door should not touch the bottom of the coop...

  Are you sure? yes | no

BetterAutomations wrote 02/07/2023 at 20:46 point

Do you have issues after some time running the motor after the battery has drained some? L298 has at least 2V drop. I am going for a DRV8833-based driver, about the same price but MOSFET technology instead of BJT, voltage drop is much better. 

  Are you sure? yes | no

JP Gleyzes wrote 02/07/2023 at 20:54 point

no problem at all !

This motor is so "light" that the drain on the battery is really low (60mA just before stalling the motor).

DRV8833 is a good driver but more expensive than the driver I use.

As said, the electronics is mostly sleeping all the time. I had special attention to power management and tried to "disconnect" everything I could when the ESP32 is deepsleeping.

In fact my design has a "too big" power supply. I could even decrease the battery capacity and also the solar panel (would save a few more bucks!).

  Are you sure? yes | no

BetterAutomations wrote 02/07/2023 at 21:13 point

Oh that is unexpected, they may be more expensive in France, about the same price in the US.

I was going to suggest a smaller panel as well, a 1W 5V panel at 3 hours insolation can give four days of runtime, and with many sunny days in some seasons and 2000mAh battery it should run quite well. Costs about USD$2 from eBay.

Report the battery voltage levels or at least have a daily heartbeat so the server can notify the user of a power loss. 

  Are you sure? yes | no

JP Gleyzes wrote 02/07/2023 at 21:43 point

Yes you are right... almost the same price !

2.71€ for DRV8833

2,15€ for MX1508

  Are you sure? yes | no

BetterAutomations wrote 02/07/2023 at 19:31 point

200-250g is quite light, I suppose you are using aluminum sheet? Could not find much that weighs that low which is why for maximum compatibility for the customer I switched to a 6V 37mm geared motor and two batteries, two solar panels, each charges one battery.

You might also reduce your spool size; At 10mm diameter it should be able to lift (optimistically) up to 1kg. I see the motor shaft is 4mm which means the spool needs only be 3mm larger in radius. 

Of course these suggestions only apply if you change the door material. I can see from the video it works as it is now. 

  Are you sure? yes | no

JP Gleyzes wrote 02/07/2023 at 20:37 point

The spool diameter is 12mm. As said the motor lifts up to 300g (with margin).

The door is currently a sandwich of plastic (inside) and aluminium (outside).

It is very light while remaining strong.

For heavier door, we can add a counter weight inside the coop to stay in the range 200-300g of apparent weight for the motor.

I would like to keep price as low as possible. Currently it costs 40$ including all the electronics, motor, solar panel and battery. Any change to a "bigger" configuration would lead to an automatic increase of price...

  Are you sure? yes | no

BetterAutomations wrote 02/07/2023 at 20:48 point

Yes and I can see it works for you, I have to accept a wider variety of materials which is what prompted me to change the design. I like the counter weight idea. I could not easily add that to mine but you can keep your hands on the installation. 

  Are you sure? yes | no

BetterAutomations wrote 02/07/2023 at 19:20 point

Consider using a DS3231 module instead. About the same price but far more accurate than the DS1302 because it does temperature compensation. It is I2C though, the 1302 is SPI.

  Are you sure? yes | no

JP Gleyzes wrote 02/07/2023 at 20:44 point

yep it's a good alternative.

If you are close to a wifi access point, the time is also synchronized on a daily basis.

  Are you sure? yes | no

BetterAutomations wrote 02/07/2023 at 20:49 point

Yes indeed. Also, it is a good idea to publish the local time to your server and validate it so as to alert the user if NTP on the device is not synching for some reason. I have a variance allowance of one minute. 

  Are you sure? yes | no

BetterAutomations wrote 02/07/2023 at 18:41 point

If you find rotary encoding problematic, another method is mount reed sensors at the open and closed positions. It is not perfect however, because if the open reed gets missed due to a misalignment the motor would not stop spinning and eventually break the line. I had planned to use a timer in addition to the reeds, calibrated on the first open cycle. If the timer is exceeded, stop. 

Another consideration is stopping the close if a bird is in the door. A E18-D80NK obstacle sensor costs about USD$5 but runs on 5V, so you may perhaps either use a buck converter or I plan to have two batteries, not just for the obstruction but also for better motor torque. 

  Are you sure? yes | no

JP Gleyzes wrote 02/07/2023 at 18:48 point

currently the encoder is working very well. But still under evaluation !

I had the same idea for the stepup converter if I needed to increase the motor size. But currently it seems to work !

I will also add a very simple way to detect (notify may be) that the door is blocked. The encoder will help a lot for this purpose !

  Are you sure? yes | no

BetterAutomations wrote 02/07/2023 at 19:06 point

Encoder is great for determining if the door is jammed and cannot open, but cannot detect if it will not close for some reason. That’s where reed switches and E18 obstruction detector do best.

I also chose reed switches to be able to detect a competitor’s “dumb” opener operation; SecureCoop has a sensor (motor less) option that can convert any other opener into a smart opener.

  Are you sure? yes | no

BetterAutomations wrote 02/07/2023 at 18:34 point

Very good. I have been building almost the same thing, called SecureCoop, hoping to sell later this year. I am using MicroPython and my own Python Websocket server. The rotary encoder is a nice touch. A tip: The TP4056 can overcharge batteries due to a flaw in the way the common Chinese modules are designed, and they all have this flaw. Search the web for an article, “Using the TP4056: There’s a right way, and a wrong way for safe charging Lithium Ion”. I added a P-FET, a diode, and a separate DW01A module into my design to compensate, and even with the redundant protection chip it is still very simple and inexpensive. Keep up the good work, this is a fun project! 

  Are you sure? yes | no

JP Gleyzes wrote 02/07/2023 at 18:49 point

thank you for this comment. I will look at the problem that you mention.

  Are you sure? yes | no

JP Gleyzes wrote 02/07/2023 at 19:06 point

Hi again ,

I have just read this interesting page.

It seems to me that I do not use the chip in a risky way. My design is to shut down all the electronics most of the time. The ESP32 will only draw 10 to 20µA in deepsleep. 

In these conditions the TP4056 will cut safely the charge.

An "overcherge" condition could only occur when the ESP32 is awaken and motor is running. Then the TP4056 could indeed not detect the stop of charge condition. But this would last during 10 to 20s (maximum) when door is opening. 

So IMHO there is no risk at all, the Li ion could safely handle a short overcharge (above 4.2V).

Furthermore the DW01A Battery Protector Chip should shut down the charge (over charged condition) at 4.3V if the TP4056 does not detect the end of charge.

And finally the battery I bought is a "protected" one. It has a chip circuit integrated into the cell packaging. This circuit protects the battery against common dangers, such as overcharge, over discharge, short circuit/over current, and temperature.

All this being said, I will go on with the TP4056 and all the above mentioned protections!

But thank you again for your comment

  Are you sure? yes | no

BetterAutomations wrote 02/07/2023 at 19:16 point

That is a good point about low risk of overcharge and perhaps I am being too sensitive there. The battery you bought already contains a redundant DW01A or equivalent which is almost exactly the same as I am doing, except I would be soldering mine in as an extra step. It is redundant with the one on the TP4056 but it is wired correctly. 

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates