Automatic Chicken Door

tiiiim

Member
So, I finally got my backside into gear and completed the project!

Background
We keep some chickens in the back garden, inside a sizable run. The hen house is situated inside this run, and has a small opening with a door. This must be closed at night to prevent predators (if they managed to get inside the run) from gaining access to the chickens - sleepy chickens are very docile and easy pickings for any predator.

I live in an urban area in the UK, and the main predators are foxes and cats.

Design Overview
  • This chicken door incorporates a linear actuator to horizontally slide the existing door of the hen house.
  • The door opens just after dawn and closes just after dusk – these times are automatically determined by two light sensors in the chicken run.
  • There is a switch (‘close switch’) at the far end of the hen house which is pushed shut when the door is closed, enabling the control box to determine correct movement of the actuator.
  • A motion sensor attached to the hen house detects movement at night and prevents the door from opening until the area has been checked by a human.
  • An indicator box is positioned outside of the chicken run, and displays the current door status via three coloured lights.

I created a user manual for the parents/sister (as I'm now back at Uni). This will provide much more info and can be directly downloaded from http://www.tiiiim.com/temp/picaxe/Chicken_Door_User_Manual_V1.pdf. The circuit diagrams can also be found at the end of this manual.

Code/PICAXES
There are two code files attached. The first is for the main control box which uses a 28X1, whilst the second is for the indicator box which uses an 08M to drive some indicator LEDs. There is a simple flow chart available in the User Manual which describes what the code does for non-PICAXE people.

Any questions just ask!
 

Attachments

XLSERVICE

New Member
Great project..

How do you know the chickens are all in the house when the door is closed for the night.. Do the chickens just know when to goto bed?

Cheers
Alan
 

tiiiim

Member
How do you know the chickens are all in the house when the door is closed for the night.. Do the chickens just know when to goto bed?
Simple answer: you don't. But all the chickens that we've had, including the current ones, all go to bed before sunset. In fact, our current ones are pushing on a bit with age, so they go to bed about 30 mins before sunset, and the door closes about 15 minutes after sunset so there's about a 45 minute leeway. This door has no way of checking whether the chickens are in the house or not when it closes.

So yes, the chickens know when to go to bed!
 

geoff07

Senior Member
timing feature

Great project, everyone with chickens needs this! I have had a commercial product that shuts the pop-hole for several years now and it is great. No going out in the rain. I even wrote an article about it for Practical Poultry a couple of years ago.

I would like to suggest an upgrade to your project, however. If you don't want the fox to get the hens at 0500 in the summer, when they are let out at dawn and the fox is hungry, incorporate some form of timing that keeps the door shut until people are up and about, say 0730, if dawn is before that. One way to do this without an RTC might be by counting sleep cycles, 'midnight' being halfway between dusk and dawn.

It is uncanny the way they put themselves to bed shortly before the door closes.
 

tiiiim

Member
I would like to suggest an upgrade to your project, however. If you don't want the fox to get the hens at 0500 in the summer, when they are let out at dawn and the fox is hungry, incorporate some form of timing that keeps the door shut until people are up and about, say 0730, if dawn is before that. One way to do this without an RTC might be by counting sleep cycles, 'midnight' being halfway between dusk and dawn.
Good idea, but I wanted to stay away from actual timing in this project due to the differences in dawn/dusk times throughout the seasons. The above idea requires some sort of user interaction every day/week to increase/decrease the counter, whilst I just wanted something which you can place and forget about!

I guess one way of delaying the opening time is by setting the dawn light threshold higher, but the chickens get fairly vocal if they're not let out when they want!!
 

Buzby

Senior Member
One way to do this without an RTC might be by counting sleep cycles, 'midnight' being halfway between dusk and dawn.
This is exactly how some 'dusk to midnight' lights work. It takes them 24 hours to learn when dawn and dusk are, then after that they just time X/2 hours from dusk to switch the light off at midnight. No user input required, and they recalibrate every cycle.
 

tiiiim

Member
This is exactly how some 'dusk to midnight' lights work. It takes them 24 hours to learn when dawn and dusk are, then after that they just time X/2 hours from dusk to switch the light off at midnight. No user input required, and they recalibrate every cycle.
So it uses the midnight value from the night before? Sounds good (isn't it like a 1 minute difference anyway within 24 hours....)!! But, in this chicken door case, the time at which 0730hrs occurs is always the same, but the time at midnight is always different ==> the time between midnight and 0730hrs is constantly changing - could this be accounted for within code without a lookup table?

To be honest, it'd just be way easier to set the whole thing up on a mechanical timer which only switches on at 0730hrs - it'd be bright enough by then for the sensors to detect dawn and the door to open...
 

Buzby

Senior Member
Is half way between 'dusk to dawn' always at the same time ?. If so, just add 7.5 hours to the calculated 'midnight'.

Try http://aa.usno.navy.mil/data/docs/RS_OneYear.php to work out if 'calculated midnight' is always the same as 00:00 in your part of the world.

Or, use the table above to find the right 'chicken times' for different months, then put them in an EEPROM lookup table, triggered from the 'calculated midnight'. ( You don't need to 'know' the months, just use the measured length of daylight to estimate the time of year. )

There's always more than one way to skin a cat.
 
Last edited:

tiiiim

Member
So I've just got back from Uni, and I thought I'd update on how the project has been operating so far - an extended life assessment of sorts...!

Overview
The long and short of it is that the door is still going strong, opening at dawn and closing at dusk.

Problems
The problems encountered during the year have been minimal. They include:
  • System freezing - this has happened only twice in the last 9 months, and was quickly corrected by power-cycling the system. I'm pretty sure the freeze was due to powercuts overnight, and possible spikes as a result - not sure though
  • Close switch unreliable - The physical switch used to detect that the door has properly closed is not really up to the outdoors job. It is basically two metal prongs which are squished together when the door is closed. Unfortunately, sometime during winter these metal prongs oxidised thus no longer conducting, and from then until now the Picaxe has never actually known the door to be properly closed. Physically the door was closed, but because the switch wasn't, the Picaxe would continually try to activate the linear actuator to re-close the door. However, because the linear actuator has an internal switch when the arm is at full length, nothing actually happens: in effect, the Picaxe was just arming and disarming a relay throughout the night.

Cost
Using one of those socket power meter thingys, I calculate that the system uses 1p of energy per day, so for an entire year the system costs £3.65 to run. Maintenance is practically nil.

Thoughts
  • Throughout its life, the system has not once caught an intruder. Hopefully, this is because an intruder hasn't yet managed to get into the run! This kinda makes the idea of the automatic door slightly useless, but I guess it's there just in case.
  • Because the system runs - in the first instance - off a 12VDC power source, the entire system could be powered by a 12V car battery, topped up by a solar panel. However, the payback period would be decades...

I think that's it. Bit boring, but hopefully some might be interested to see that a Picaxe is capable of operating over the long term in (slightly) hostile environments with next-to-no problems!
 

fernando_g

Senior Member
Actually tiiiim, a very interesting showcase project.

I believe that these type of projects were precisely what Rev-Ed had in mind when they decided to launch the PICAXE line.

One question: how do you exactly check light levels? In your schematic, the LDRs are connected from the analog inputs to ground via a resistor, instead of the usual potential divider.
 
Last edited:

tiiiim

Member
Actually tiiiim, a very interesting showcase project.

I believe that these type of projects were precisely what Rev-Ed had in mind when they decided to launch the PICAXE line.
Thanks, I hope it's useful to someone!

One question: how do you exactly check light levels? In your schematic, the LDRs are connected from the analog inputs to ground via a resistor, instead of the usual potential divider.
You got me there: that's a mistake in the schematic - the real thing does use a potential divider, as far as I'm aware: as much as possible I used the Picaxe manual examples when constructing the different circuit sections, and as the manual recommends a potential divider, I'm pretty sure that's what I used!
 
Top