Automatic Chicken Coop Door

I wanted a small door to open automatically (via Arduino - morning/night) to the outside world. Doing this would relieve us from worrying if the chickens were safe at night and to be able to leave the house when we wanted) This door will be located on the side of the coop and will slide open (vertically) so the girls can up & down their ladder about 18' to the ground level. (although ladders are really not needed as my chickens can fly straight up to the door without trouble)
Iíve lived with the chickens and the coop for some time now and have learned quite a bitÖ especially about their habits. This is important, because no matter how much Iíd like to automate this coop via my El Pollo Palace Networks Operations Center or the E.P.P.N.O.C. = ) (Arduino Controller) the chickens will ultimately dictate how itís made and how it will operate.

Step 1: Videos of the Arduino Chicken Coop Door

The Installed Arduino Chicken Door

How I built the Automated Chicken Coop Door

Testing the door with the Arduino

Step 2: The Photocell

Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Show All 10 Items

Note: for a nicer view of the images, parts, diagrams and code, please visit:
http://davenaves.com/blog/interests-projects/chickens/chicken-coop/arduino-chicken-door/

When I first started this coop project I wanted to use a real-time clock and an Arduino library called Time Lord, but since I was a newbie to Arduino and struggled with the implementation of Time Lord I decided to go with using a photocell resistor instead. Iím actually glad I did since chickens come home to roost based on light, (not time) and with a photocell I wonít have to worry about a real time clock resetting due to power outages or battery failure, I think it will be less prone to problems.

Photocell application and installation
I first soldered the photocell to my cable, applied heat shrink tubing and encased the connection within a 1/4 inch plastic audio connector case. I filled the casing with silicone and capped the very tip with clear plexiglass to project the photocell from the elements. then I simply drilled a hole above the coop door monitor, and finished the outside with a brass grommet.

Step 3: The Door Construction

Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door

Note: for a nicer view of the images, parts, diagrams and code, please visit:

http://davenaves.com/blog/interests-projects/chickens/chicken-coop/arduino-chicken-door/

As you can see, the door construction is fairly straightforward. I began framing out the door with 2 x 2s, capped with 2x4s and screwed everything together with 1/2 inch galvanized deck screws. The door itself is a 1/8 inch birch, sandwiching in OSB plywood door locks ~and in the pictures (below)~ is the 1/8th inch acrylic. Note: I have since swapped out the acrylic with more 1/8 inch birch because I cracked the acrylicÖ being too rough with all the testing. =(

I cut 1/2 inch grooves into the backsides of the 2x2s so the door could slide easily. I gave myself enough room for 1/4' of play. You can see in the pictures Iíve also rubbed a bar of soap over the edges all moving parts to ensure that they will move freely. If youíre taking on this project Iím assuming you have basic carpentry skills and can simply take a look at the pictures below to come up with similar ideas to build your own. ( which of course is my way of saying I didnít do a great job documenting this exact process with plans or dimensions) =)

Step 4: The Door Reed Switches

Automatic Chicken Coop Door

Note: for a nicer view of the images, parts, diagrams and code, please visit:
http://davenaves.com/blog/interests-projects/chickens/chicken-coop/arduino-chicken-door/

At first I was going to use micro switches for this build, but after testing them I felt they would wear out over time, being mechanical-type switches. So instead I chose to use Reed Switches, which are essentially magnets that when you get close in proximity throw an electromagnetic field thereby becoming a switch with open or closed values. ( high/low | 0/1)

Step 5: The Chicken Door Motor

Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Show All 12 Items

Note: for a nicer view of the images, parts, diagrams and code, please visit:
http://davenaves.com/blog/interests-projects/chickens/chicken-coop/arduino-chicken-door/

I chose a 25 RPM model, but you can certainly buy a different speed (just not *too* fast)

That main images is the motor I purchased. Hereís a saved search of a DC 24V 25 RPM 6mm Dia Shaft Magnetic Gearbox Electric Motor 37mm at Amazon

Step 6: The Chicken Door Installation

Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Show All 19 Items

Note: for a nicer view of the images, parts, diagrams and code, please visit:
http://davenaves.com/blog/interests-projects/chickens/chicken-coop/arduino-chicken-door/

Step 7: Parts Used for the Arduino Automated Chicken Door

Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Show All 8 Items

Note: for a nicer view of the images, parts, diagrams and code, please visit:
http://davenaves.com/blog/interests-projects/chickens/chicken-coop/arduino-chicken-door/

(my affiliate links)


Arduino MEGA 2560 Board R3 - by Arduino

(The Arduino Micro Controller to control the entire coop, including the door)

NEOMART L298N Stepper Motor Driver Controller Board Module - by Tontec

(The board that controls the motor)

DFGB37RG-136i Cylinder Shape DC 24V Speed 20 RPM Geared Motor - by Amico

The motor it self (make sure to pick a motor that isn't too fast. I chose the 20rpm model)

White Inbuilt Type Alarm Contacts Door Window Reed Switch - by Amico

(The Reed Switches (magnetic) which signals when to start/top the motor)

20pcs Photo Light Sensitive Resistor Photoresistor Optoresistor 5mm GM5539 5539 - by sunkee-E

(The Photocell that continually reads light levels. In this project, it's instructed to read ever 10mins)

10k Ohm Resistors - 1/4 Watt - 5% - 10K (25 Pieces) - by E-Projects

(10k resistors for the photocell and the reed switches - refer to wiring diagram)

BB830 Solderless Plug-in BreadBoard, 830 tie-points, 4 power rails - by BusBoard Prototype Systems

(To connect all devices and wiring. Tip: apply hot glue to wired connections on breadboard once set)

Polycom SoundPoint IP Universal AC Power Supply 24V DC - by Polycom Inc.

(power supply for 24v motor)

Wall Adapter Power Supply - 9V DC 650mA - by NKC Electronics

(power supply for arduino)

Acrylic Sheet, Transparent Clear, 0.08" Thickness, 12" Width, 24" Length - by Small Parts

(To cover door's internal workings...prevents dust, shavings, feathers, etc.)

Step 8: Chicken Coop Door Status LED

Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door
Automatic Chicken Coop Door

I wanted to give myself a quickie visual aid on the exterior of the coop so I could just take a peek outside and see if the coop door was open or closed.

Pretty simple:

I just used 2 LED (1- red, 1- green) and inserted them into the little globe of one of my extra motion sensors. Filled it with silicone and installed on the exterior of the coop:

Drilled 3/4" hole

Chiseled out the square part edge

Wired it up

Coded it up

Voila... insta-visual aid!

Arduino Chicken Coop Door LEDs Status:

Green: indicating the door is closed and chickens are safely inside. This is what I see when I look outside at the coop.

Red: indicating danger: the door is open and chickens are out.

Red: (flashing) indicating danger: the door is stuck and open. Essentially, the code checks to see if both topSwitch and bottomSwitch circ

Arduino chicken coop door status LED (red, indicating danger: the door is open and chickens are out)

uits are open and if so, blink.

Step 9: Wiring Diagram for the Automatic Chicken Coop Door

Automatic Chicken Coop Door

Note: for a nicer view of the images, parts, diagrams and code, please visit:
http://davenaves.com/blog/interests-projects/chickens/chicken-coop/arduino-chicken-door/

Notes about wiring of the L298N Stepper Motor Driver Controller Board Module to the Motor:

The board is indeed the l298n (the one in the pic might look different b/c i broke a couple of them while testing - but itís definitely the same modelÖ sometimes suppliers send the same product but with different layouts)


There are actually 8 wires in total to make the board/motor work (I used only 1 motor - motor b)

On mine:

5v (from arduino)

gnd (from arduino)

enab (to enable the motor b)

int1 (direction 1 - up)

int2 (direction2 - down)

24 v in to l298n board (vms)

24v gnd in to l298n board (gnd)

motor b out + (24 volts to motor)

motor b out - (gnd)

Hereís a closeup of the fritzing diagram:http://davenaves.com/blog/wp-content/uploads/Arduino-Automatic-Chicken-Coop-Door-Fritzing-Project1-1024-997.png

Hope it helps

Step 10: The Arduino Code for the Automatic Chicken Coop Door

Automatic Chicken Coop Door

Note: for a nicer view of the images, parts, diagrams and code, please visit:
http://davenaves.com/blog/interests-projects/chickens/chicken-coop/arduino-chicken-door/

Insider info
To hopefully save you some time, Iíll let you in on the trick that FINALLY got this door to work with the light levels, debouncing the switches and *the chickens*. (as youíll see in the code) Check the light levels every 10 minutes to avoid the readings bouncing back and forth between dark/twilight/light during those dawn/dusk minutes. Then, when "dark" is reached (for me i chose >= 0 && debounce the switches > stop. Then do the opposite for morning. Iím sure there are different, maybe more efficient methods, but this code has been running flawlessly for a while now and Iím feeling confident enough to go out at night without worrying about predators. Although I still somehow find a reason to check the ChickenCam from time to time. (currently waiting for my new servo motors and night vision web cam to arrive in the mail)

// libraries

// libraries

#include // load the SimpleTimer library to make timers, instead of delays & too many millis statements
#include // load the onewire library

/* (before running the sketch, remove spaces before and after the above ">" "= 0 && photocellReading = 4 && photocellReading = 125 ) { photocellReadingLevel = '3'; Serial.print(" Photocel Reading Level:"); Serial.println(" - Light"); } } //debounce bottom reed switch void debounceBottomReedSwitch() { //debounce bottom reed switch bottomSwitchPinVal = digitalRead(bottomSwitchPin); // read input value and store it in val delay(10); bottomSwitchPinVal2 = digitalRead(bottomSwitchPin); // read input value again to check or bounce if (bottomSwitchPinVal == bottomSwitchPinVal2) { // make sure we got 2 consistant readings! if (bottomSwitchPinVal != bottomSwitchState) { // the switch state has changed! bottomSwitchState = bottomSwitchPinVal; } Serial.print (" Bottom Switch Value: "); // display "Bottom Switch Value:" Serial.println(digitalRead(bottomSwitchPin)); // display current value of bottom switch; } } // debounce top reed switch void debounceTopReedSwitch() { topSwitchPinVal = digitalRead(topSwitchPin); // read input value and store it in val delay(10); topSwitchPinVal2 = digitalRead(topSwitchPin); // read input value again to check or bounce if (topSwitchPinVal == topSwitchPinVal2) { // make sure we got 2 consistant readings! if (topSwitchPinVal != topSwitchState) { // the button state has changed! topSwitchState = topSwitchPinVal; } Serial.print (" Top Switch Value: "); // display "Bottom Switch Value:" Serial.println(digitalRead(topSwitchPin)); // display current value of bottom switch; } } // stop the coop door motor void stopCoopDoorMotorB(){ digitalWrite (directionCloseCoopDoorMotorB, LOW); // turn off motor close direction digitalWrite (directionOpenCoopDoorMotorB, LOW); // turn on motor open direction analogWrite (enableCoopDoorMotorB, 0); // enable motor, 0 speed } // close the coop door motor (motor dir close = clockwise) void closeCoopDoorMotorB() { digitalWrite (directionCloseCoopDoorMotorB, HIGH); // turn on motor close direction digitalWrite (directionOpenCoopDoorMotorB, LOW); // turn off motor open direction analogWrite (enableCoopDoorMotorB, 255); // enable motor, full speed if (bottomSwitchPinVal == 0) { // if bottom reed switch circuit is closed stopCoopDoorMotorB(); Serial.print(" Coop Door Closed - no danger"); } } // open the coop door (motor dir open = counter-clockwise) void openCoopDoorMotorB() { digitalWrite(directionCloseCoopDoorMotorB, LOW); // turn off motor close direction digitalWrite(directionOpenCoopDoorMotorB, HIGH); // turn on motor open direction analogWrite(enableCoopDoorMotorB, 255); // enable motor, full speed if (topSwitchPinVal == 0) { // if top reed switch circuit is closed stopCoopDoorMotorB(); Serial.print(" Coop Door open - danger!"); } } void doCoopDoor(){ if (photocellReadingLevel == '1') { // if it's dark if (photocellReadingLevel != '2') { // if it's not twilight if (photocellReadingLevel != '3') { // if it's not light debounceTopReedSwitch(); // read and debounce the switches debounceBottomReedSwitch(); closeCoopDoorMotorB(); // close the door } } } if (photocellReadingLevel == '3') { // if it's light if (photocellReadingLevel != '2') { // if it's not twilight if (photocellReadingLevel != '1') { // if it's not dark debounceTopReedSwitch(); // read and debounce the switches debounceBottomReedSwitch(); openCoopDoorMotorB(); // Open the door } } } } // ************************************** the loop ************************************** void loop() { // polling occurs coopTimer.run(); doCoopDoor(); }

Lessons Learned

What I've learned about the door, Arduino, light and construction:
  • Best to check the light levels every 10 minutes to avoid the readings bouncing back and forth between dark/twilight/light during those dawn/dusk minutes
  • Test your door with your chickens to see if any of them like to hang outside after hours
  • Testing the actual light values outside is very important (many variables involved: light from neighbor's house, clouds, internal/external coop lights etc.)
  • Debouncing of your switches within your Arduino code is important (door will jump around and fail as electronic readings vary greatly by the millisecond)
  • Reach out for help on the Arduino Forums before pulling out your hair. (be nice, do your homework and ask very specific questions)
  • I changed from micro-switches to reed switches (magnets) because I didn't want the mechanics of the micro-switches to fail over time What I've learned about the chickens:
  • Keeping on a light within the coop can keep chickens outside longer (I think b/c the ambient light shines outside) And that's important when it comes to automating this door, so they won't get accidentally locked out.
  • They can jump and fly (high and far)
  • They love to roost in safety at night, but want nothing more than to get OUT as soon as it's light out
  •  
     

    Tag cloud

    make build easy simple arduino making homemade solar laser printed portable cheap mini building custom cardboard wooden create super lego turn paracord chocolate your paper light intel