Perhaps a camera with frigate could tell you how many chickens are in the yard or the coop.
I’ve run a similar coop set up for a few years. For a while I used solar voltage as a “daylight” measure to determine when to close them in. Was too variable (uk weather).
I eventually settled for sun angle as the door-close trigger. This has turned out to be more reliable, and you can fine-tune it with sun elevation angle.
Nick.
sun:
latitude: 52.4
longitude: -1.7
id: sunid
on_sunset:
- elevation: -1°
then:
- switch.turn_off: doorg
- switch.turn_off: doorc
i first was also thinking about using the sun, but this doesn’t includes heavy dark clouds at wich it gets earlier dark and chickens react on the real brightness to go home or not.
The LDR variant works fine since 2013, the first controlunit was with a arduino328…
i don’t need that timer for light detection not more, i tried to pass by with a tourch and it doesnt rect so fast. Even it would detect a bit of light and the door opens, it also closes in 30sec. if dark.
So working very good!
here some more pics :
here a screenshot of HomeAssistant:
and the temperatures:
funny thing is the cyan line, normally for the watertemp, but the sensor is still lying on the floor and a chicken sleeps on it!
and here the 360degree cam:
If nobody has some good ideas for the circuit and pcb, i will start making a nice pcb layout with good connectors and a 3D printed case. I dont think a LCD is useful and there are no more IOs left on the ESP
(i also dont know if the chicken can read a LCD)
Sounds like you don’t need this anymore.
But could you create a template binary sensor for the light threshold, and use a delayed_on filter for the time lag?
Then add your on_press actions?
is there not a possibility to add a delay in lambda instead of a template_sensor?
Maybe, but the delayed_on is “good for debouncing”, which sounded like a good fit for your use case?
If you prefer/need to do a countdown timer, I’ve had success adapting the approach from this project.
i am using delay filter for debouncing of the open/closed-switches, but a debouncing for the LDR is not really needed, more a delay of 30min after it gets dark.
Right I thought delayed on/off might be good for the car headlights you mentioned.
But if you’ve got a solution then all good!
The car-headlight problem is no problem anymore, i found out if a car passes by the LDR delivers a voltage of 0.01 to 0.03V on analog Input, but the turn on voltage is >0.15V so it won’t open the door if i car passes.
but i would like to have a 30min delay if voltage of LDR is below 0.02V, just in case one of the chicken is still outside and misses the “we-now-go-all-inside-time” .
i had a look at your Irrigation Controller but i am wondering why it is so complicated to use a simple timer…
there must be a easier way to get a delay of 30min i think…
after have running the new system i found out one bad thing:
If the esp restarts (because of missing power or after a fw update) when the door is opened,
it won’t work anymore!
Reason is:
binary_sensor:
- platform: gpio
pin:
number: 00
inverted: true
mode:
input: true
pullup: true
name: "stall_klappe_auf"
id: "Stall_Klappe_auf"
filters:
- delayed_on: 10ms
- delayed_off: 10ms
The switch for “door-open” is connected to GPIO0 and when this is set to LOW if the esp restarts, the esp goes into programming-mode! So i have to swap an GPIO output wiht the door-open-input.
Everything else is running very well!
That’s not a chicken coop, that’s a chicken HOTEL!