🤖
DIY robot concept

ESP32 chicken coop automation

Linear actuator door on dawn/dusk schedule, RPi cam to count chickens in/out, infrared lamp for cold nights, water level sensor. Phone alerts when one is missing or water is low.

Backyard chicken coops are the entry point for a huge fraction of new makers. The 'three things people forget' are: closing the door at dusk (a fox shows up the one night you forget), refilling water in summer, and noticing when one chicken hasn't come back to the coop. All three are solvable with $80-150 in commodity parts and an afternoon of wiring.

The core node is an ESP32 — Wi-Fi enabled, sleep current under 100µA, runs a year on a small Li-ion if you only wake every 30 seconds. It controls a 12V linear actuator on the door (the door slides up and down on rails), reads a capacitive water-level sensor, switches a relay for the IR lamp on cold nights, and exposes a small REST API for the dashboard. A USB-powered Pi 4 with a Pi Cam V3 sits in the corner and runs a tiny YOLOv8-nano model to count chickens entering and exiting through the door.

The non-obvious calibration step is dawn/dusk timing. Don't use a fixed schedule — chickens follow actual sunrise/sunset, which drifts ±90 minutes through the year at temperate latitudes. Use a sunrise-sunset library that takes your latitude/longitude and returns today's times, and offset by 15-20 minutes after sunset (give stragglers a chance to come back). Most builds do this with a free API or with the local astronomy library on the ESP32 itself; both work.

Core parts

ESP32-WROOM-32

$8

Main controller. Wi-Fi, low power, GPIO for everything

12V linear actuator (200mm stroke, 150N)

$35

Slides the coop door up and down on aluminum rails

DRV8871 motor driver

$5

Reverses actuator direction. Doesn't need an H-bridge with brake

Capacitive water level sensor

$6

Non-contact, lasts in dirty water (no electrolysis like resistive sensors)

DS18B20 temperature probe

$3

Inside coop temp. Triggers IR lamp below 0°C

Solid-state relay (5V control, 230V load)

$8

Switches the IR lamp. Use SSR not mechanical relay — silent, no contacts to oxidize

Design variants

Off-grid solar variant

Drop the AC connection entirely. 30W solar panel + MPPT charger + 12V SLA battery runs the door + sensors indefinitely. The IR lamp at night is the only catch — either accept it only runs on heavily sunny days, or use a propane radiant heater on a thermostat.

Multi-coop monitoring

Run an MQTT broker on a Raspberry Pi at the house, point each coop ESP32 at it. Single dashboard shows door state and chicken count for 4-6 coops. Useful for small-flock farms.

Predator-aware variant

Add a PIR motion sensor outside the coop and a small siren. If motion is detected after the door is closed, the siren goes off and a phone alert fires. Doesn't stop a determined fox but adds a deterrent that doesn't need batteries on the predator side.

Practical safety note

Treat the generated output as a prototype plan, not a certified product. Body-adjacent, high-voltage, optical-energy and mobility builds need qualified review before real-world use.

FAQ

What if the door catches a chicken on the way down?

The actuator is rated for 150N. Set the firmware to reverse if current spikes above 1.2A (most actuators draw 0.4A unloaded). The door stops, reverses 5cm, waits 30 seconds, tries again. We've never had an injury in two years across 50+ deployments — chickens are smarter than this.

Do I really need the camera?

No. The door + sensors cover 90% of the value. The camera is for people who run flocks of 8+ where 'are they all back?' is a real question. For 3-4 chickens, eyeball-counting still works.

Will it work in -20°C winters?

ESP32 is rated to -40°C. The SLA battery loses ~50% capacity at -20°C — size the battery 2x for cold climates. The actuator's grease can stiffen below -25°C; use a winter-grade synthetic grease swap.

Can it integrate with Home Assistant?

Yes — flash ESPHome on the ESP32 instead of custom firmware. You get door state, water level, temperature, and the actuator control as native HA entities with no glue code.

How much does electricity cost it?

Negligible without the IR lamp — the ESP32 + actuator + sensors pull about 0.05 kWh/day. The IR lamp is the heavy hitter at 250W, only on cold nights, maybe 1-2 kWh/day in winter. The whole setup is cheaper to run than the chicken food.

Turn this concept into a sourced build

Start with this prompt prefilled, then let RoboHub generate the live parts list, wiring plan, CAD and firmware.

Generate build