Project: Chicken Coup Door Build & Automation

Way back in November my brother in law and I built a sliding door for his chicken coup (the door opens to the run he built over the summer). The idea was that we’d build a door that slid up and down easily and attach a motor that was controlled by a micro controller (Arduino / NetDuino) board to open it at sunrise and shut it at sunset. The door was constructed of simple 2×4’s with a 1×4 back brace pocket screwed onto the 2×4’s. We routed a 3/8 inch slot in the vertical 2×4’s  3/4  of an inch from the back edge (leaving room for the back brace). We then used a piece of 1/4 inch thick board for the door to slide in and out. We did not slot the bottom to avoid dirt/snow/other buildup. Here is how the door turned out:

Kelly has had the door on the coup for a few months now opening it manually when it’s time to let them out and closing it when it’s time to go in so now it’s time to get moving on the automation part. To do this I selected an Arduino Uno (though almost any arduino would work) as the microcontroller. I opted for the Arduino vs a Netduino because of the cost savings and lack of need for more advanced options like networking that the Netduino makes really easy. Since CodePlex is shutting down, I’ve opted to start this project in GitHub instead.

Other Supplies:

  • Motor Controller (Crib Notes: http://arduinotronics.blogspot.com/2015/01/sainsmart-l298n-motor-controller.html)
  • Motor (Right angle shaft seemed easier to mount in the box, gear reduction is nice)
  • Sunrise/Sunset Calculator
  • Set Screw Shaft Coupler (.250′ to 6mm), 1/4″ bore set-screw tube roller (to wind string on), 1/4″ stainless steel D-Shafting (3″ length) from Servo City
  • i2c Temperature / Humidty sensor: (though probably switch to a simpler DS18B20 so I can measure the temp outside the enclosure easily)
  • Button
  • i2C real time clock with battery backup

We’ll also use a 6x6x4 PVC electrical junction box to house the project and a couple LED’s.

 

Base loop functionality:

  • Check what day/time it is
  • Check the cached day / sunrise/sunset value
    • If the day has changed or the sunrise/sunset value is empty generate a new sunrise sunset value
  • Compare sunrise / sunset and open/close status
    • If the door needs opening call openDoor which checks the temperature and if warm enough raises the door and illuminates the “Door Up” light
    • if the door needs closing call closeDoor which lowers the door and illuminates the “Door Down” light
  • listen for button input

Upon pushing the button:

  • If the door is open, close it and illuminate the “Door Down” light
  • If the door is closed, open it and illuminate the “Door Up” light

Calibration:

We’ll also need to calibrate the door opener occasionally. Because this should only happen a handful of times we’re going to store the calibration data in the EEPROM in position 1 and 2 as a number of full seconds the motor must run to make it go all the way up or all the way down. Calibration sequence will go as follows:

  • There are no numbers in EEPROM / You’ve entered calibration mode by holding the button down
  • illluminate “Door Up” light and activate motor up
  • wait for button press (timeout after logical amount of time)
    • upon button press pause for 2 seconds
    • Door is now index’d at the top of it’s position
  • Illuminate “Door Down”, begin timer and motor down
    • Upon button press (signaling door is all the way down), store number of seconds ran as time to lower
  • Pause for 2 seconds
  • Illuminate “Door  Up”, begin timer and motor up
    • Upon button press (signaling door is all the way up), store number of seconds ran as time to raise
  • Flash door up / Door down lights for 2 seconds indicating calibration complete
  • Illuminate door up and fall back to main loop

 

That’s the basics, which I think lets me skip having any sort of display outside of the