
Chicken Coop Automation v24.6 - ESP32s2
STDChicken Coop Automation v24.6 - ESP32s2
License
:Public Domain
Description
Project updated March 31, 2025. Fixed charge not disengaging as programmed. Schematic and PCB reflect changes.
CCA - Chicken Coop Automation. Chicken coop door and life support controller. Beta 0.24.6. I'm sharing this as an idea for anyone to build their own.
Code for PlatformIO included. Debugging using native USB on Wemos ESP32-S2 board enabled.
*Do not use autogenerated BOM. It is inaccurate. See schematic.
This project (see schematic) controls chicken coop door, heat, fan,battery charge, solar charger and additional relays for future features like feed control, lights, etc.
A 20W solar panel is connected to MPPT mini charger that charges LiFePo4 battery. The battery already has balancing and protective circuitry built in.
South facing, on T-post is the South_Box sensor module containing 2 LDRs, Override reeds, reset reed and Neo RGB LED. RGB LED has a lens and faces house. The LDRs
are facing North. MPPT will also regulate ext power supply with FET protection in case solar isn't sufficient (more than 3 rainy days) or when heat or fan is needed.
Heat or Fan relays will not come on if ext power is not present (assuming AC not available). Additional 3.3V voltage regulator added for peripherals
Either H-driver or relays (reversing polarity to motor) are used to drive motor switchable by jumpers and plug. The 4 relay wiring: relay's NC contacts for one direction
as COMMONs for another in case of a software glitch (to avoid all relays at the same time and causing a short). There is an off/delay time in door operation to allow
motor to completely stop on state changes. Door limit switching done using reeds.
On cold days if temp below freezing (asterisk on LCD) the door will remain closed and heater relay will come on 24x7. If temp is below comfort (set to 40F) the heat will
come on as well, but only during the night. A fan will be started when temp is above 86F (settable on top of code) but only during the day if ext power connected.
Battery voltage is monitored - will flash purple "batt" LED on status, see table. Also, solar and ext Volt values are monitored.
Optional 2 or 4 line LCD with I2C interface can be used to display temperature, status and light level. Currently set to 2 line, modify lcd lib to adjust
for 4 line LCD. LDRs read light level 0-1023 (higher=darker), range of daylight as determined from values preset, then state of the last door activity.
OPTION: All pertinent data is sent via EspNow to home automation for monitoring.
Board can be reset anytime by holding magnets to both overrides at the same time for 5s (L and R of South_Box). Wait for white light to go out, remove magnets.
Holding magnets longer will init OTA mode indicated by orange flash, then solid white light.
* Features at glance
- LCD: show status of system, temperatures, voltages.
- RGB INDICATOR: flash and color codes to determine status of coop from outside (see bottom for more details).
- ESPNOW: send coop data to monitoring station.
- ESP OTA: hold magnets to both overrides at the same time for more than 5s (L and R of South_Box)
to reset the board to OTA mode. HOLD whole White LED will keep flashing fast, then go dark, Orange and solid White.
The LCD will show the IP for upload - this is the time to upload new FW OTA. Once uploaded the board will reset automatically and run new code.
- SOLAR MPPT: 20W solar panel, and/or EXT power brick regulation and batt charging.
- REED SENSING: door up and down door state sensed by reed switches.
- DOOR OVERRIDE: door open/close can be overriden by magnet on reed switch.
- REMOTE RESET: ESP reset by using magnets on bottom of South_Box.
- PWM or RELAY motor driving. Choose plug. Relays 1-2 = OPEN, 3-4 = CLOSE
- MOTOR RETRY: motor will try 3 cycles to close/open door if no feedback from reeds.
- TEMP MONITORING: monitor outside and inside temperatures to determine if life support (cooling/heating) is needed and controls this via relays.
- LIFE SUPPORT: Heating or Cooling (fan) relays (7-8) can be used when EXT_PWR brick is connected.
- EXPANSION: Relays 5-6 can be utilized for additional features (feed, water, lights, etc)
- LCD does not show solar volt if ext is plugged in, shows that instead
- HEAT : comes on after Twilight if temp lower than heating temp: comes on during day if door closed due to frost
- 3 MCU position options to allow for OTA updates / EspNow transmissions:
- Internal socket (for plastic enclosures),
- Side PC-LPT port with ext MCU box (for metal enclosures),
- External 2x13 header with cables and with ext MCU box (for metal enclosures)
* LCD DISPLAY FORMAT:
-----------------------------
b14.2/e19V+c *HC
i56/o22F 1320^ N
------------------------------
Line 1:
Batt(b) / Ext-Brick(e) voltage, +c || !c (charge_OK or charge_OFF_b/c_frost), * (frost), H || F (heat or fan), C (door status O/C)
Line 2:
Inside(i) / Outside(o) temperatures(F), LDR_value^ToD (D/N/T Day, Night, Twilight)
* See table below for LED flash codes.
----------------------------------------------------------------------------------------------------------
FUNCTION LIGHT/ACTION INDICATES To Do
----------------------------------------------------------------------------------------------------------
STATUS
GREEN: on SOLAR 1 Short Flash Night n/a
2 Short Flashes Evening/Morning n/a
3 Short Flashes Day n/a
BLUE: on CHARGER 1 Short Flash Night n/a
2 Short Flashes Evening/Morning n/a
3 Short Flashes Day n/a
PURPLE: BATT LOW 3 Short Flashes LOW Battery Charge battery before it runs out
WHITE: FREEZE OUT Flashes DOOR remains closed Wait until warmer or override
----------------------------------------------------------------------------------------------------------
DOOR
RED: ALARM 5 Short Flashes Door - Wrong State Check if door open during day or closed at night
GREEN: OP Constant Flashes Motor in Oper n/a
----------------------------------------------------------------------------------------------------------
CHARGE
YELLOW: ERROR 1 Short Flash Freeze = Charge OFF Too cold for batt charge, charge at home
----------------------------------------------------------------------------------------------------------
ESPnow ERROR
YELLOW: ERROR 2 Short Flashes ESPNow Failed Send Reset the board or wait for autoReset
----------------------------------------------------------------------------------------------------------
SUPPORT
ORANGE: HEAT 1 Long Flash HEAT is ON Works only if EXT PWR connected
TEAL: FAN 1 Long Flash FAN is ON Works only if EXT PWR connected
----------------------------------------------------------------------------------------------------------
POWER
NO_LIGHTS Dark No Power/MCU bad Check Power / MCU
----------------------------------------------------------------------------------------------------------
UPDATES
WHITE: OTA Constant Light Waiting for upload Reset
----------------------------------------------------------------------------------------------------------
Design Drawing

BOM


Project Members

Comment