Kokot: a low energy chicken coop door

Kokot is an Automatic chicken coop door which helps to keep your chickens safe by working on sunrise and sunset hours…
7
12
0
606
updated March 12, 2025

Description

PDF

Kokot is an Automatic chicken coop door which helps 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.

All the design is shared (open hardware and open source) on my hackaday project : https://hackaday.io/project/189482-kokot-a-low-energy-chicken-coop-door

The PCB can be ordered at PCBWay although I do have a few spares available: https://www.pcbway.com/project/shareproject/Kokot_a_low_energy_chicken_coop_door_cba5ca2c.html

Everything is printed with free and strong PET filament made from plaxtic bottles : https://hackaday.io/project/185196-pullstruder-from-plastic-bottle-to-pet-filament

 

Specifications

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 
  • the door MUST be able to work without internet (however a smartphone is needed for initialization of the system only once !)
  • kokot could monitor temperature and humidity into the coop (not implemented in the software)

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 

 

 

Hardware

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 500g.cm. 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 at 4V.

daily power consumption : P = UxI = 4 x 60/1000 = 240 mW during 1 minute.. not a lot !

The Li Ion battery was given for 3400mAh but would realistically store not more than 2000mAh

So this battery should last 2000*60/240 minutes = 500 minutes before being empty... That is 500 days if used 1 minute per day.

To avoid this "power outage" after 500 days we can add a small solar panel.

I had on my bench a cheap 6V 2W model 

Even in case of bad weather, this panel panel could provide a little output to charge the battery (let say 500 mW).

Let's assume a poor sunny location with 1 hour of daylight...  We should get much more energy than needed to charge the battery. 

 

 

The charger itself will be a cheap TP4056 module:

It can charge a single Li-ion and has undervoltage, overvoltage and current protection which is perfect for battery safety.

TP4056 has the following features

  • Constant Current / Constant voltage charging method.
  • C/10 Charge termination.
  • 2.9V trickle charge threshold (for deeply discharged batteries).
  • Upper charge stop voltage : 4.2V.
  • Soft start inrush current limit.
  • Automatic recharge (keeps batteries optimally charged when connected to a charger).

We have now a fully qualified setup with a motor, a battery and a solar charger to keep the door running during years. Let's now add a brain to this door !

A brain for Kokot

Kokot's brain will be a ESP32 microcontroller.

It can be programmed using Arduino IDE

This MCU can go into deepsleep mode.

If you put your ESP32 in deep sleep mode, it will reduce the power consumption (in the range of 10 µA). Having your ESP32 in deep sleep mode means cutting with the activities that consume more power while operating, but leave just enough activity to wake up the processor when something interesting happens.

This feature is perfect for Kokot as we plan to wake up the MCU twice a day nominally and when the user wants for manually opening/closing the door. A deepsleeping MCU is thus perfect provided we take also care of disconnecting all the actuators/sensors when the system is sleeping.

When sleeping the MCU will do almost nothing but:

  • wait for the morning an evening hours to open/close the door
  • wait for the user to push a button (or touch a touch pad) to wake up the MCU

When in activity the MCU will offer the following capabilities:

  • get internet time via WIFI, store it into the Real Time Clock (in case no internet is available)
  • alternatively get the time from your smartphone via Bluetooth Low Energy and strore it into the real time clock
  • compute sun rize and sunset hours depending on your location and the local time
  • move the door if needed
  • check homing positions of the door to stop motion
  • optionnaly mesure temperature and humidity
  • optionnaly send them to Thingspeak IoT site
  • go to sleep

schematics and PCB

Most of the electronics is based on internet available DIY modules. The schematics are thus extremely simple.

PCBWay proposed to sponsor this project. 

Kokot is also published on PCBWay shared projects pages. If you want to have them produce the PCB simply go to this page : Kokot PCB V2 at PCBWay

Kokot mechanics

 

This V2 mechanics has the following improvments :

  • a ball bearing is added to the motor shaft
  • the IR sensor is directly mounted on the PCB (to avoid manual wiring and soldering...)
  • a "light cover" is added to protect the IR sensor from sunlight when calibrating
  • a protection box is also added

 

 

Note that a ball bearing is now there to avoid friction on the shaft. On the motor axis, everything is assembled with M4 nuts inserted into the 3D printed parts.

Installation into the coop is as simple as it could be!

A simple string and that's is

 

Kokot version 3 

Unfortunately, It occured that the IR sensor may be blinded by sun and triggers false interrupts... thus leading to lost of calibration of opened and closed positions...

To correct this problem I simply replaced the IR sensor by a hall effect switch.

PCB and code are unchanged.

 

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's software

All the code is open source and is available on Github. You will find there:

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 you are in close range to the board (10 to 20m max).

But it does the job !

Librairies used 

I used a few librairies that you will have to install before compiling using the manage libraries menu

#include <TimeLib.h>          //https://github.com/PaulStoffregen/Time

#include <SolarCalculator.h> //https://github.com/jpb10/SolarCalculator

#include <ArduinoJson.h>          //https://github.com/bblanchon/ArduinoJson

#include <ESP32MX1508.h> //https://github.com/ElectroMagus/ESP32MX1508

#include <Ds1302.h> //https://docs.arduino.cc/libraries/ds1302/

 

TimeLib and SolarCalculator are respectively used to handle time into ESP32 and NTP and to compute the  sunrise and sunset hours

ArduinoJson is there to encode/decode JSON format

ESP32MX1508 to handle the motor

DS1302 to drive the real time clock module

Open/close calibration : the "rotary encoder"

 

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 the magnet to fly in front of the hall sensor and count the pulses 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.

 

Print Settings

Printer Brand:

Prusa

Printer: 

i3 MK2S

Rafts:

No

Supports: 

No

Resolution:

.3mm

Infill: 

20

Filament: none PET green plastic bottle

 

 

 

Category: Pets

Tags



Model origin

The author marked this model as their own original creation. Imported from Thingiverse.

License