Automatic Chicken Coop Door

Hello all,
I am right now in the middle of my small project to automate my Chicken Coop Door with ESPHome.
If anyone is interested, I’ll share my build with instructions later on. I tried to stay in a low budget area with it.

The Build

Two limiting switches, one at the top and one at the bottom are used, to determine the endposition of the cover. In my case I have used to Hall-Effect-Sensor with a magnet glued to the cover.
To move the cover up and down, a worm-gear motor is used, due to its selflocking feature. The motor is controlled via a L298N H-Bridge.

All parts which were needed to mount the motor, to setup the PCB and for the pulley were 3D Printed. The 3D-Modells can be found at Printables.

The Material

I got most of the material from Amazon, but Aliexpress is for sure also fine.

  1. 12V Worm Gear Motor (selflocking)
  2. Wemos D1 mini
  3. L298N H-Bridge
  4. Power Supply 12V 2A
  5. 12V to 5V Buck Converter
  6. 2x Hall Sensor A3144

Additional parts

  • jumper cables
  • at least 1mm² wires
  • break out board
  • some thin rope
  • 8x M2.5 metal inserts
  • 8x M2.5 screws

As I tried to stay in a low budget area, the material was about 30-40€.

The Schematics

The following pictures show the wiring diagram of my control unit.

ESPHome

The configuration file for ESPHome can be found here at Gists.

Following passwords must be adjusted:

api:
  encryption:
    key: "***********************************************"
  ap:
    ssid: "CoopDoor Fallback Hotspot"
    password: "***************"

For the initial setup, it’s important, to increase the timeouts as shown in the following example to a time, in which the door will close for sure. The time must be measured and with a few extra seconds entered into the global variables. In my case the time for opening and closing was different, therefore I created two different variables.

globals:
  - id: timeout_open_sec
    type: float
    restore_value: no
    initial_value: '57.0'
  - id: timeout_close_sec
    type: float
    restore_value: no
    initial_value: '45.0'

Home Assistant Automation

The automation currently takes the CoopDoor as a cover and opens it at sunrise and closes it at sunset. It’s possible to configure an offset, at sunrise and sunset, so the door doesn’t close immediately.
Furthermore, there are 2 timeouts, which must be set in ESPHome, to ensure, even when the limiting switches are not triggered, the motor will stop. This timeout is a trigger for a notification target to inform someone about it.

Installation of the Blueprint

Option 1: Direct Import (Recommended)

  1. Click the badge below to import the blueprint directly into your Home Assistant instance.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

  1. Click “Preview Blueprint” and then “Import Blueprint”.
  2. Find the Blueprint in the Blueprint-Collection.

Option 2: Manual Installation

  1. Copy the code from the .yaml file.
  2. Go to your Home Assistant config folder: /config/blueprints/automation/floo33r/.
  3. Create a file named CoopDoor.yaml and paste the code.
  4. Go to Developer ToolsYAMLReload Automations.

How to configure it

  1. Select the CoopDoor cover entity
  2. Select the timeout entity of the motor
  3. Select the Targets to be notified (either use notify groups or multiple actions)
  4. Select the desired offset for sunrise delay
  5. Select the desired offset for sunset delay

Excellent project, but I can’t see how the physical connection to the door works. Any chance of more info?

I have also completed a simlar project. I chose a linear actuator (2 wire). The brains is an esp32 that sends signals through a logic level shifter to actuate two relays - wired to enable the up/down through reverse polarity. The linear actuator has an automatic shutdown at the end of stroke either way but for safety I also have the yaml code shutting down 5 seconds after the timed stroke distance. Mine opens on sunrise and shuts 30 minutes after sunset (for those lazy chooks). I also put in place two momentary triggers so that i can control the up /down from an external controll box if required for cleaning etc.
This new setup replaces an old system that used a car aerial as the push pull mechanism. The linear actuator is much neater.
Now I’m planning a 12v light to be on at 1 hour before sunset to encourage the chooks inside (chasing the bugs attracted to the light). This light will then slowly fade over the next hour to 0.
I am also planning a camera inside and will be attempting to train the AI to recognise snakes (the large pythons at my place love small chooks) with an alert coming direct upon recognition so that the offender can be relocated.
Once I have that in place I am planning a write up for anyone that is interested.

Thanks!

The door is connected with the thin black rope (first picture) to the winch inside the wet junktion box. The winch is hidden behind the motor. This happend due to the fact, that the outlet of the junktion box only fitted the rope like this.

I was also thinking about a light do pull the chicks inside. But for now let’s see how it works out like this.

The AI thing would overcomplicate the stuff for me, because there are no snakes in my area, which are likely to snack the chicks away.