The problem
An automatic chicken coop door with light sensing and a predator lock solves a daily chore that backyard poultry keepers get wrong at exactly the wrong times: the door must open at dawn so hens can feed, and close and lock at dusk before foxes, dogs and other predators arrive. A keeper who opens the door late loses laying hours, and anyone who forgets to close it even once can lose birds overnight. The Automatic Chicken Coop Door with Light Sensing and Predator Lock (ESP32) fixes this with an ESP32 controller that reads an LDR light sensor, drives a stepper motor and lead screw to slide the door, and engages a steel latch bolt plus a motor brake once the door is shut, so the door cannot be lifted from outside. A DS3231 real-time clock keeps a schedule as a fallback when the sky is overcast, and a companion app shows door status, light level and an event log.
Most commercial coop doors use a single light threshold, which makes them flutter on cloudy mornings: the door starts to open, a cloud passes, and it closes again on birds still inside. This build avoids that with two separated thresholds and a confirmation window, so the door only moves when daylight has genuinely arrived or genuinely gone. The mechanism is deliberately mechanical rather than clever: a lead screw holds its position without power, the motor brake resists back-driving, and the latch bolt is a piece of steel, not a software state. The app is a window into the controller, not a dependency — if Wi-Fi drops, the door still opens and closes on light and schedule alone.
The LDR reads ambient light through a voltage divider into the ESP32 ADC.
How it works
The door works as a small closed loop: the LDR watches the sky, the ESP32 decides whether daylight has genuinely changed, the stepper motor and lead screw slide the door along its rails, current sensing watches for obstructions during travel, and once the door is fully shut a steel latch bolt plus the motor brake lock it against predators. A DS3231 clock runs a keeper-set schedule in parallel, so if heavy cloud keeps the light reading below the open threshold all morning, the scheduled open time still lets the birds out. The companion app only observes and commands this loop — it never sits in the middle of it, so a lost Wi-Fi connection can never strand the door open overnight. The same loop repeats every day without keeper input, and every decision it makes is recorded in the event log.
- The LDR and a fixed resistor form a voltage divider, and the ESP32 reads the divider on its 12-bit ADC (0–4095 counts, datasheet value) every 30 seconds.
- The reading is converted to an approximate lux band and compared against two separated thresholds: above 1,200 lux to open, below 500 lux to close (design targets), with the opposite threshold ignored until the confirmation window passes.
- A reading must stay past its threshold for a continuous 10-minute window (design choice) before the door moves, filtering out passing clouds, headlights and shade.
- When the open or close decision is confirmed, the ESP32 releases the latch bolt, then steps the NEMA 17 motor through the A4988 driver to drive the T8 lead screw and slide the door along its rails.
- During travel, motor current is sampled; a sharp rise above normal running current stops the door, waits 5 seconds, retries once, and if still blocked, stops and writes an obstruction entry to the event log.
- At full travel, limit switches confirm the door reached its end stop; on closing, the latch bolt slides into the frame and the driver holds the motor braked, engaging the predator lock.
- In parallel, the DS3231 clock is checked every minute: if the keeper-set schedule time arrives and the light decision has not already fired, the schedule opens or closes the door as a fallback.
- After every event, the ESP32 updates the companion app over Wi-Fi with door state, light level, lock state and a time-stamped log entry; the app can also issue open, close and override commands.
Tech stack:
- ESP32 DevKitC (dual-core, Wi-Fi)
- LDR light sensor with voltage divider
- DS3231 real-time clock module
- NEMA 17 stepper motor with A4988 driver
- T8 lead screw with 8 mm lead
- Arduino IDE with C++ firmware
- HTML, CSS and JavaScript companion app
- 12 V DC power supply with battery backup option
| Parameter | Value |
|---|---|
| Controller | ESP32 DevKitC, dual-core up to 240 MHz (datasheet value) |
| Light sensor | LDR in voltage divider, ESP32 12-bit ADC, 0–4095 counts (datasheet value) |
| Open threshold | 1,200 lux (design target) |
| Close threshold | 500 lux (design target) |
| Confirmation window | 10 minutes continuous past threshold (design choice) |
| Real-time clock | DS3231, ±2 ppm accuracy, 0 °C to +40 °C (datasheet value) |
| Motor | NEMA 17 stepper, 1.8° step angle (datasheet value) |
| Lead screw | T8, 8 mm lead (design target) |
| Door travel | Approximately 30 cm (design target) |
| Door cycle time | Approximately 20–30 seconds (expected) |
| Power supply | 12 V DC, approximately 2 A (design target) |
| Backup battery | 12 V sealed lead-acid or 3-cell Li-ion, approximately 12.6 V fully charged (optional, design target) |
| Limit sensing | 2 mechanical end-stop switches (design target) |
Project features
The Automatic Chicken Coop Door combines four capabilities that matter most to a keeper: dawn/dusk light sensing that only acts on confirmed daylight change, a predator lock that pairs a steel latch bolt with a motor brake so the shut door cannot be lifted from outside, obstruction sensing that stops the door instead of trapping a bird, and a schedule fallback plus companion app so the door still works on overcast days and the keeper can always see what it did and why. Together these cover the whole job — sensing, moving, locking and reporting — without depending on the keeper remembering anything at dusk. Each capability answers a failure keepers actually report: doors that flutter on cloudy mornings, doors raccoons learn to lift, birds caught in closing doors, and overcast mornings that leave flocks locked inside.
- [Dawn/dusk light sensing with hysteresis] An LDR reads ambient light through a voltage divider into the ESP32's 12-bit ADC, and the door opens only above 1,200 lux and closes only below 500 lux (design targets), each held for a 10-minute confirmation window so a passing cloud never triggers the door.
- [Predator lock] Once the door is fully shut, a steel latch bolt slides into the frame and the stepper driver holds the motor braked, so the door cannot be lifted or slid open from outside by raccoons, dogs or foxes.
- [Obstruction sensing] Motor current is monitored during travel; a sudden rise stops the door, retries once, and if still blocked, stops and logs the event instead of forcing the door onto a bird in the doorway.
- [RTC schedule fallback] A DS3231 real-time clock (datasheet accuracy ±2 ppm) holds keeper-set open and close times, so the door still runs on schedule when heavy cloud keeps light below the open threshold all morning.
- [Companion schedule/control app] A single-page web app served by the ESP32 shows door status, live light level, lock state and an event log, and lets the keeper open or close the door, change thresholds and edit the schedule.
- [Manual override] A physical push-button and an app override hold the door in position for cleaning and inspection days, with the override clearly shown in the app so it is never left on by accident.
- [Power-failure behaviour] The lead screw is self-holding, so a power cut leaves the door exactly where it was; on power return the controller re-reads light and clock before moving anything. (Optional: 12 V battery backup keeps the controller and one door cycle running.)
- [Event log] Every open, close, obstruction stop, override and schedule run is time-stamped from the RTC and kept in the app log, giving the report real operational evidence.
What is included
- Complete door mechanism: wooden door panel, aluminium rails, T8 lead screw, NEMA 17 motor and latch bolt assembly
- ESP32 controller board with LDR sensor, DS3231 RTC, A4988 driver and end-stop switches, fully wired
- C++ firmware with light-sensing, hysteresis, obstruction sensing, schedule fallback and event logging
- Companion schedule/control web app served from the ESP32
- Wiring diagram and assembly guide with threshold-calibration procedure
- Project report PDF (background, sensor theory, mechanism design, methodology, testing)
- PPT presentation for final review
- Viva Q&A preparation document (LDR characteristics, hysteresis, stepper control, RTC accuracy, locking mechanics)
Limitations & prerequisites
- The LDR measures relative brightness, not calibrated lux: thresholds are set by calibration against the install site's sky, and a sensor mounted in shade reads differently from one in open sky.
- Heavy overcast can keep light below the 500 lux close threshold all day; the schedule fallback covers this, but it must be set to realistic local dawn/dusk times.
- The lock resists lifting and sliding from outside, but it is not a security product: a determined human with tools can defeat any wooden coop door.
- Obstruction sensing uses motor current, which varies with door friction and temperature; the trip level must be tuned during the build, and very light obstructions (a single feather) may not trip it.
- Wi-Fi range limits the app to the home network; there is no cloud control, so the keeper cannot operate the door from away from home.
- Battery backup, where fitted, covers approximately 1–2 door cycles plus controller standby (expected); it is not sized for multi-day outages.
- The door panel is sized for a standard small coop opening of approximately 30 cm travel; larger openings need a longer screw and rails, quoted separately.
Frequently Asked Questions
How does the door know when it is dawn or dusk?
The door decides from light, not from a fixed clock time. An LDR measures ambient brightness, and the ESP32 opens the door only after light stays above 1,200 lux for 10 continuous minutes, and closes it only after light stays below 500 lux for 10 minutes. The two separated thresholds plus the confirmation window stop passing clouds from triggering the door, and a DS3231 clock schedule acts as a fallback on heavily overcast days.
What stops a predator from opening the door at night?
The shut door is held by two independent things, not one. A steel latch bolt slides into the frame once the door reaches its end stop, and the stepper driver holds the motor braked, so the lead screw cannot be back-driven. A lead screw only moves when the motor turns it, so lifting or sliding the door from outside meets the bolt, the brake and the screw together. The door panel itself is wood, so this is predator resistance, not a security rating.
What happens if a chicken is standing in the doorway when the door closes?
The door stops instead of forcing its way shut. Motor current is monitored during travel, and a sharp rise — the signature of the door meeting resistance — stops the motor, waits 5 seconds, retries once, and if still blocked, stops and writes an obstruction entry to the event log. The keeper sees the failed close in the app and can clear the doorway and retry from the app or the manual button.
Does the door still work if the Wi-Fi goes down?
Yes, completely. The ESP32 makes every open, close and lock decision locally from the LDR and the DS3231 clock, so the door keeps opening at dawn and locking at dusk with no network at all, and the app is only a window into the controller plus a remote control. If Wi-Fi drops, the door keeps running on light and schedule exactly as before; only the app view and remote commands are unavailable until the network returns.
How is the light sensor calibrated for a real coop?
Calibration is done at the install site, not assumed from a datasheet. The keeper watches the app's live light reading at real dawn and dusk for a few days, then sets the open and close thresholds around the readings that matched birds actually leaving and returning. The report documents the calibration procedure and the readings from the demo build, so the viva discussion can show the thresholds as site-tuned values rather than guessed numbers.
Is this project suitable for a final-year project?
Yes — for IoT, Embedded Systems and Electronics programs. It combines sensor interfacing, actuator control, real-time clock scheduling, power management and a companion web app in one working prototype, with a mechanism (lead screw plus latch) that gives the viva a physical system to examine, not just a screen. The hysteresis and obstruction-sensing decisions give the report genuine engineering reasoning to defend.
Components & software requirements
- ESP32 DevKitC (dual-core, Wi-Fi)
- LDR light sensor with voltage divider
- DS3231 real-time clock module
- NEMA 17 stepper motor with A4988 driver
- T8 lead screw with 8 mm lead
- Arduino IDE with C++ firmware
- HTML, CSS and JavaScript companion app
- 12 V DC power supply with battery backup option
Delivery information
Built-to-order project. Delivery timeline is shared after order confirmation based on current queue.
Support terms
Complete documentation, setup guide, and viva preparation included. Support for setup and explanation provided.
Download free synopsis (PDF)
Enter your name and WhatsApp number — the synopsis PDF downloads immediately. We may send occasional project updates on WhatsApp; no spam.