Automatic Chicken Coop Door
by philippoMC in Circuits > Arduino
1888 Views, 11 Favorites, 0 Comments
Automatic Chicken Coop Door
Most things are explained in the video. In this article, i will go into a bit more detail on the electronics and the software.
Supplies
These are the most essential components. I dont have exact model numbers for all parts because some are just what i had laying around.
-ESP32 development module
-L298N H-bridge motor driver
-DCF77 receiver (for germany and surrounding countries)
-motor with gearbox
-LCD 1602 module with HD44780 driver
-12V power supply
-Some wires, perfboard and buttons
Electronics
Connections: The diagram shows how all components of the system interact. The pins on the ESP32 the signals are connected to are listed in the defs.h file in the software.
Main PCB: There is not much going on on the PCB. Most signals are connected directly to the ESP32. The chip in the middle is a schmitt-trigger used together with an RC network for debouncing of the buttons. This is really not necessary as it could easily be done in software.
DCF77: The time of the system is received from the DCF77 time code transmitter in germany. It transmits a pulse at 77.5 kHz every second, and the length of the pulse corresponds to either a '1' or a '0'. This data contains the date, the time and some proprietary weather information. The signal can also be received outside of germany, but it wont work in the US. If there is a WIFI signal where the system will be installed, it is certainly easier to use the ESP32s builtin WIFI module to call an NTP server. Because there were interference issues with the power supply blocking signal reception, i had to mount the antenna outside of the case to get it further away from the power supply.
Hardware
Winch: I turned the spool for the winch on the lathe. Alternatively, a 3d-printed part could also work. In the beginning there was a smaller motor on the gearbox. It didnt last long and burnt out after only a few test runs. To fix this, i took the gearbox apart and pressed the worm gear onto the shaft of a bigger motor. This had the added benefit of the new motor also having an encoder.
Thermals: The fuse box used to house all components has no holes for ventilation. This causes the internals to get quite hot in the summer. Because the 5V regulator on the motor driver would get especially hot, i stuck a heatsink on it with some thermal epoxy.
Software
Dependencies:
- Arduino time library
- DCF77 library: https://github.com/thijse/Arduino-DCF77
- LiquidCrystal_I2C library: https://github.com/johnrickman/LiquidCrystal_I2C
How it works:
After the setup, the software basically runs three finite state machines in an endless loop. There is one FSM for handling the buttons, one for handling the door and one for the display. The buttons and the motor encoder are connected to interrupts to avoid having to poll their signals at every loop. The button interrupts set a flags, which are then handled by the button FSMs for detecting short and long presses. The door FSM checks the time, controls the motor, checks the endstop and watches the motor velocity to protect the motor. Finally, the display FSM updates the displayed time every second.
When the one of the settings like the opening time is changed by the user, this change is saved to the EEPROM. This is so that the change will be remembered when the system is turned off and back on. Some of the diagnostic parameters like the drive count are also written to the EEPROM.
While opening the door, the motor drives until it finds the metal bead on the wire using the inductive sensor. Because there is no endstop at the closed end of the door, the motor drives for a fixed number of encoder steps to close the door. There are timeouts for both directions to prevent the motor from running forever or destroying itself if something should go wrong. In this case, the door goes into an error state.
The system has been running reliably for over a year now, and my parents are very happy with it.
Happy Chickens!
Thanks for reading! If you liked this project, you can vote for me in the electronics contest: https://www.instructables.com/contest/electronics/