Automated chicken coop door using an ESP32 chip and a cheap battery powered door.

Nov 11, 2024
103
311
91
Southern Ohio
I looked at a bunch of automatic coop doors, and none of them met my needs.

I realize this might be over some folks heads, but I thought I'd post it and maybe someone else will see it and it will inspire them to make it even better.

I use a server at my house called Home Assistant. https://www.home-assistant.io/

You can do all kinds of cool stuff and control just about anything that talks to the internet. I can control my TV's, IP cameras, dishwasher, etc. I have door locks on my back doors that I can control and unlock via my phone.

So I started looking into what I could do to control it with this and found the ESP32 chip. These are really cheap. I got one for $10 at a Microcenter. That, and a L298N motor controller and a bit of my time, and I have a door I can control from my server.

I bought the cheapest coop door I could find online. I just wanted the moving door and the motor.
https://www.ebay.com/itm/316056534216

The photocell eye, the motor circuit, etc got ripped out. That photocell was super touchy and a cloud going over would make it close.

This is what I started with:

1735854957918.png


At first I thought maybe I could modify that motor circuit using a wifi controlled relay. But I had no luck.

So, I went to microcenter and got the ESP32 and ordered the L298N online.

I mocked everything up first

1735855846623.png


Then once I was happy I hot glued it all in place. I would like to be able to remove and move to a different housing, as after I prove this out I'm going to upgrade to a metal housing instead of plastic.

1735855911479.png


I'm using a 5V power supply for the motor driver and USB to power the ESP32. There is an issue with the ESP32 where it won't have wifi if you power it with 5V instead of USB. So, I have to have 2 power adapters. I will fix this in the next version.

I put it all back together.

1735855984735.png


Here is the pertinent ESPHome code. I didn't get fancy yet, I just timed how long for it to open and close.
However I have some hall effect sensors on the way so I can use a magnet to detect when the door is open or close. Again, this was proof of concept, that will be in the next version.

captive_portal:

output:
- platform: ledc
id: motor_1_a
pin: GPIO2 # Pin to IN1
- platform: ledc
id: motor_1_b
pin: GPIO4 # Pin to IN2

- platform: ledc
pin: GPIO5 # Pin to EAN
id: motor_enable
frequency: 1000Hz

fan:
- platform: hbridge
id: Door_Motor
name: "Door Motor"

pin_a: motor_1_a
pin_b: motor_1_b
decay_mode: SLOW
enable_pin: motor_enable
speed_count: 100


button:
- platform: template
name: "Door Up"
on_press:
then:
- fan.turn_on:
id: Door_Motor
direction: Forward
- delay: 5s
- fan.turn_off: Door_Motor

- platform: template
name: "Door Down"
on_press:
then:
- fan.turn_on:
id: Door_Motor
direction: REVERSE
- delay: 5s
- fan.turn_off: Door_Motor


And, a video of it working:



So why would I do this?

Because now I can control my chicken coop door from anywhere. I can open it from my phone. I can open it on vacation.
And, I can automate it. I can use Home Assistant to have it open 15 minutes before today's sunrise and close 15 minutes after today's sunset.

I can use AI and the camera in my coop to detect if the coop door is closed and a chicken is moving around in the main part of the chicken house where it shouldn't be, and alert me that someone might have missed bed time.

Also because I like to do this sort of stuff. I realize its overkill.
 
I looked at a bunch of automatic coop doors, and none of them met my needs.

I realize this might be over some folks heads, but I thought I'd post it and maybe someone else will see it and it will inspire them to make it even better.

I use a server at my house called Home Assistant. https://www.home-assistant.io/

You can do all kinds of cool stuff and control just about anything that talks to the internet. I can control my TV's, IP cameras, dishwasher, etc. I have door locks on my back doors that I can control and unlock via my phone.

So I started looking into what I could do to control it with this and found the ESP32 chip. These are really cheap. I got one for $10 at a Microcenter. That, and a L298N motor controller and a bit of my time, and I have a door I can control from my server.

I bought the cheapest coop door I could find online. I just wanted the moving door and the motor.
https://www.ebay.com/itm/316056534216

The photocell eye, the motor circuit, etc got ripped out. That photocell was super touchy and a cloud going over would make it close.

This is what I started with:

View attachment 4019302

At first I thought maybe I could modify that motor circuit using a wifi controlled relay. But I had no luck.

So, I went to microcenter and got the ESP32 and ordered the L298N online.

I mocked everything up first

View attachment 4019310

Then once I was happy I hot glued it all in place. I would like to be able to remove and move to a different housing, as after I prove this out I'm going to upgrade to a metal housing instead of plastic.

View attachment 4019312

I'm using a 5V power supply for the motor driver and USB to power the ESP32. There is an issue with the ESP32 where it won't have wifi if you power it with 5V instead of USB. So, I have to have 2 power adapters. I will fix this in the next version.

I put it all back together.

View attachment 4019313

Here is the pertinent ESPHome code. I didn't get fancy yet, I just timed how long for it to open and close.
However I have some hall effect sensors on the way so I can use a magnet to detect when the door is open or close. Again, this was proof of concept, that will be in the next version.




And, a video of it working:



So why would I do this?

Because now I can control my chicken coop door from anywhere. I can open it from my phone. I can open it on vacation.
And, I can automate it. I can use Home Assistant to have it open 15 minutes before today's sunrise and close 15 minutes after today's sunset.

I can use AI and the camera in my coop to detect if the coop door is closed and a chicken is moving around in the main part of the chicken house where it shouldn't be, and alert me that someone might have missed bed time.

Also because I like to do this sort of stuff. I realize its overkill.
This is something I think I'm going to try. I might look into a thermostat that connects to Home Assistant as well to control the door opening in the morning. That and to control a switch that turns on or off a power strip with a heater based on temperature.
 
This is something I think I'm going to try. I might look into a thermostat that connects to Home Assistant as well to control the door opening in the morning. That and to control a switch that turns on or off a power strip with a heater based on temperature.

There are tons of zigbee or Zwave thermometer and other sensors.

I have Zwave for stuff that I can't plug in, eg, my door locks are zwave. garage door tilt sensor is zwave.

But for stuff I can plug in that doesn't have to move, I use a wifi based solution. a ESP32 chip with a BME280 sensor is like $5 to build, and everyone has tons of USB power adapters to run them off of. https://www.aliexpress.us/item/3256804341669591.html
 
Amazing!!!!! I’m jealous! no way I could ever do that (I just had to use google docs for the first time today and I was mind blown with how complicated it was🤣) me and anything techy does not mix. My brain can’t comprehend it
 
There are tons of zigbee or Zwave thermometer and other sensors.

I have Zwave for stuff that I can't plug in, eg, my door locks are zwave. garage door tilt sensor is zwave.

But for stuff I can plug in that doesn't have to move, I use a wifi based solution. a ESP32 chip with a BME280 sensor is like $5 to build, and everyone has tons of USB power adapters to run them off of. https://www.aliexpress.us/item/3256804341669591.html
Do you happen to have a list of parts for the coop door controller? I want to try and build one of these.
 
Do you happen to have a list of parts for the coop door controller? I want to try and build one of these.

Sure.

So I used an ESP32 chip.

There are tons of versions of it out there and any of them will work. I think I used a C3 version, if I'm not mistaken. But here is a link to amazon to a 3 pack.

https://www.amazon.com/ESP-WROOM-32-Development-Microcontroller-Integrated-Compatible/dp/B08D5ZD528

An L298N Motor Driver
https://www.amazon.com/BOJACK-H-Bridge-Controller-Intelligent-Mega2560/dp/B0C5JCF5RS

You only need one, and you only need half of it. It can drive 2 motors, but I just used one side.

You'll need a USB power supply, like a cell phone charger, to power the ESP32. You'll also need a 5V power supply to power the L298N because the 5V output on the ESP32 doesn't supply enough amperage for the motor on the coop door.

For wire I just cut up a few pieces of cat5e and used that, I have a 1000 foot spool I've been working on for years.

I'd recommend getting a development board for the ESP32, it'll make putting things together a lot easier and not require soldering.
https://www.aliexpress.us/item/3256804292242591.html
 
Sure.

So I used an ESP32 chip.

There are tons of versions of it out there and any of them will work. I think I used a C3 version, if I'm not mistaken. But here is a link to amazon to a 3 pack.

https://www.amazon.com/ESP-WROOM-32-Development-Microcontroller-Integrated-Compatible/dp/B08D5ZD528

An L298N Motor Driver
https://www.amazon.com/BOJACK-H-Bridge-Controller-Intelligent-Mega2560/dp/B0C5JCF5RS

You only need one, and you only need half of it. It can drive 2 motors, but I just used one side.

You'll need a USB power supply, like a cell phone charger, to power the ESP32. You'll also need a 5V power supply to power the L298N because the 5V output on the ESP32 doesn't supply enough amperage for the motor on the coop door.

For wire I just cut up a few pieces of cat5e and used that, I have a 1000 foot spool I've been working on for years.

I'd recommend getting a development board for the ESP32, it'll make putting things together a lot easier and not require soldering.
https://www.aliexpress.us/item/3256804292242591.html
I'm going to go ahead and see if I can get all of the necessary things. Which 5v power supply do you use?
 
I'm going to go ahead and see if I can get all of the necessary things. Which 5v power supply do you use?

Um...I reached into my big bag of old power supply bricks that I keep around and looked for one that put out 5 volts. Then cut the end off and used a multimeter to figure out which wire was + and which was -.

Do you have a Home Assistant server setup? You'll need that to use ESPHome. https://www.home-assistant.io/

https://esphome.io/
 
Um...I reached into my big bag of old power supply bricks that I keep around and looked for one that put out 5 volts. Then cut the end off and used a multimeter to figure out which wire was + and which was -.

Do you have a Home Assistant server setup? You'll need that to use ESPHome. https://www.home-assistant.io/

https://esphome.io/
I don't have either set up, so this will be my first time setting them up. I plan to install it on a PC that's running as a NAS and Immich server.
 

New posts New threads Active threads

Back
Top Bottom