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:

Optionnal specifications

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:

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:

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. 

500 mWh under 4V would be equivalent to 125mAh of charge during one hour. Much more than needed to balance the motor comsumption. Even a small 6V 1W solar panel would be enough (and cheaper). I thus modify the Bill Of Material to take this into account!

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

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.

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:

When in activity the MCU will offer the following capabilities:


schematics and PCB

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

A first version of the PCB was made "manually" using the toner transfer method. It's a single sided PCB.

Here are the eagle files if you want to etch yours.

And a first prototype was ready for testing !


Kokot mechanics

I mounted the 3d printed parts on a piece of wood and we could start the tests.

All the parts at printed with home made PET filament with plastic bottles

As you can see I did add a rotary encoder and a IR sensor at the very end of the shaft (green wheel on the left side). This is a simple and efficient way to count the number of turns the motor makes. Thus we can "close the motion loop" knowing where is the door at any time. We will see this into more details in this log!

On this first proto the IR sensor was hot glued on the wooden base. This has also a little evolved on the final version!

And it moves !


Kokot version 2

Thanks to the success of this first prototype I decided to design a version 2 of Kokot. Most of the V1 is kept untouched but I improved both the mechanics and the electronics slightly.

Kokot new mechanics

This new mechanics is basically the same as V1 with the following improvments :

Kokot new PCB

At the very end of january, PCBWay proposed to sponsor this project. I did place the order for the new PCB and received it less than one week later!

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

Kokot Protect box

The new PCB fits perfectly into a 3D printed box. You can find all the stl files on my Thingiverse page.

Here is the PCB mounted and a detail to assemble the motor.

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

And you know what ? It works :-)


Kokot version 3 

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.

See this log for more details on how to solder the hall effect sensor.

Kokot's software

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


Licenses

Unless otherwise stated, all works presented here that are not based on software/code are subject to the Creative Common Attribution license .

The complete legal text can be found here

Unless otherwise stated, all software/code-based works presented here are subject to the GNU General Public License v3.0

The complete legal text can be found here