Introduction: Automatic Chicken Coop Door - Arduino Controlled.

About: Perpetual prototypist

This Instructable is for the design of an automatic chicken door with manually alterable opening and closing times. The door can be opened or closed remotely at any time.

The door is designed to be modular; the frame, door and controller can be constructed and tested in a place away from the coop and then simply bolted on the existing coop opening.

It runs off 9Vdc, so it can be powered from plugpack or a battery and solar panel to charge the battery.

It uses a solenoid to lock to the door closed and to hold the door in the open position.

Major parts include:

Arduino UNO 3.

4 digit, 7 segment LED display

RTC module

RF module

Potentiometers,

Servo motor,

6V - 12V Solenoid,

Rotary encoder with push button

The door and its frame can be made from timber scraps. The door pivots upwards around a rod (taken from a printer in my case) and is counterweighted to lessen the torque needed to raise the door.

The tools to build it include:

PC with Arduino IDE to program the Arduino,

Hammer,

Saw,

Soldering iron,

Wire cutters,

Drill,

Screw driver.

I built this automatic chicken door to save me the twice daily task of opening and closing the door in the morning and evening. Chickens are great providers of eggs, manure and entertainment, but getting up early to let them out the coop - especially in Winter - was drudgery. And then making sure I was home in time to close them in really restricted my freedom to come home late.

Chickens follow a daily routine of returning to a coop around sunset and waking up around sunrise. The times they go in and out is not exact and is influenced on the weather of the day and ambient light. Should a chicken be seen to be too late to enter after the door closed, the door can be remotely opened then closed. The door can be closed during the day should the owner need to stop broody chickens from entering.

As sunrise and sunset times vary throughout the year and depend on the latitude, any door controller needs to track the time of day, the day of the year and know the latitude of the location. This requirement can be acomplised with software or a suntracker, but in this design uses manually adjustable open and close time settings to keep things simpler.

As sunrise and set times only change by a few minutes from one day to the next, the door controller settings need only be adjusted once a week.

When an owner has a sense of their chickens' roosting routine, they can easy adjust the open and close times.

The opening time can be adjusted from 3am to 9am and the closing time from 3pm to 9pm. These times suit latitudes from 12 to 42 degrees from the equator (Darwin to Hobart in Australia) and cover the longest and shortest days of the year. .

In essence the door controller is a clock with two settable alarms with manual overide.

Step 1: Frame and Swing Door

The frame is made to be secured over the existing coop opening. The door swings upwards like a garage door. This design has the advantage over automatic doors that slide upwards or sidewards for coops where the roof slopes over the existing door or the existing opening is adjacent to a wall.

1. Remove the existing door.

2. Choose a frame size that fits over the existing opening.Two dimensions of the frame are important - the height of the frame and the width of the timber. The door swings from a horizontal pivot and the length from the pivot to the frame ("D" in diagram) is the same as the width of the timber. This means that when the door is open, the section of door above the pivot does not interfere with the coop wall.

3. Choose a material for the frame that is sturdy and weather proof. I used red-gum which proved to be sturdy but heavy. Outdoor pine would be easier to work with.

4. The door itself should be light, rigid and weather proof.

Step 2: Pivot Rod and Swing Door Sizing

The swing door dimensions should be such that the width of the door fits over the inside edges of the frame. The height of the door is smaller than the inside of the frame height.

1. Find a rod about 5mm (1/4 inch) diameter and length equal to the width of the frame.I used the rod from a dismantled printer, but threaded rod would suffice. Another source of rods are from metal clothes drying racks. A rod can be cut with a bolt cutter or hacksaw. Scrape the coating off the metal with a blade.

2. Cut two grooves into the frame at a length "D" (in diagram in previous step) from the frame top opening and a depth of the diameter of the pivot rod.

3. Find a hinge whose pin diameter is the same or slightly larger than the pivot rod. Knock the pin out with a hammer and center punch. If you don't have a center punch, use a large nail or similar pin.

By fluke, the printer rod pivot I used was a perfect fit for the first hinge that came out of my junk box.

4. The weights of the bottom section of swing door below the pivot and the top section above the pivot need to be similar to take the strain off the servo motor that opens the door. This can be achieved this with some heavy bolts and nuts that were drilled into the top section of the door.

Step 3: Servo Motor and Lifting Arms.

I used a MR-996 servo motor. It has a torque of : 9.4 kgf· cm (4.8 V ), or 11 kgf · cm (7.2 V) . This means that for a 20cm door below the pivot, the motor could lift 11kg/20 = 550g at 7.2V .

With counter weighted section above the pivot rod, the door could be heavier and/or longer. I used two large nuts and bolts as counterweights, shown in the pictures.

The servo comes with a plastic arm that fits on the servo's splined output shaft. Cut one side of this arm with a sharp knife or wire cutters.

2. The lifting arm is made of two lengths of aluminium , the upper arm is an L bracket, the lower arm a flat piece of aluminium.

Attached diagrams show how to calculate the dimensions of each arm. The resulting dimensions are based on the frame width, "d", and the position of the lifting point mounted on the door.

The upper arm has cutouts to so that the arm clears the servo motor when raising the door.

Step 4: Lock Solenoid and Door-open Support

1. A solenoid mounted on the frame serves two purposes:

a) lock the door when it is shut , and

b) prevent the door from closing once opened.

The solenoid is driven via a FET from an output of the controller. It retracts for a few seconds while the door is in the process of opening or closing.

2. Secure a piece of timber as shown in the photo. It will be shorter than the frame width and mounted just below the pivot rod.

Step 5: The Controller

1. I used an Arduino Uno 3 as the basis of the controller. There are a total of 17 input and output pins.

2. The controller keeps time via a I2C RTC controller with battery back up. It would be preferable to have a rechargeable battery backup to save the effort of opening the contoller every year to change the RTC's battery. The time is set via a rotary controller and displayed on a 4 digit 7 segment LED. One could use a LCD and display more information such as the number of times the door opened and closed.

3. The open and close times are adjusted with 10k ohm linear potentiometers. I could have used the rotary encoder and LED display to set the open/close times, but decided it would be simpler for the user to just be able to walk up and see the times from the panel from a distance. The times need only changing every week or so.

4. A wireless RF adaptor (https://www.adafruit.com/product/1097) for the convienience of manually opening and closing from a distance. Key fob url: https://www.adafruit.com/product/1391

5. The box I chose to house the controller was on the small side, so I needed to add a smaller box to it to fit the remote receiver.

6. Fritzing diagram is attached.

Step 6: Code

The code loops around and performs the following:

1. scans the state of the panel switches,

2. reads the RTC and converts time to minutes of the day (0 to 1440).

3. reads the two analog potentiometers and converts to integer open and close times. To give a finer resolution of time settings, the open closed times are limited to between 3am-9am and 3pm-9m respectively.

4. reads the RF input to see if remote button is pressed.

5. compares the current time to the open and close time and reads the mode to determine to open or close the door.

Adding a manual open and close switch complicated the software design in that the system needed to switch between 'manual' and 'automatic, ie timed' modes. I solved this without adding another 'mode' switch by having the user press the open or close switch twice to get back to automatic mode.

A single press of the open or close button moves the controller into manual mode. There is the chance that if the door was opened after the close time, perhaps to let a late chicken into the coop, that the user would forget to set the door back to automatic mode. Thus, manual mode is signified by the LED display showing "Open" or "Close" as a reminder.

LED Display libraries I got from : https://github.com/avishorp/TM1637

Step 7: Controller Parts List

Arduino Uno 3
4-Digit 7-Segment Module

MG 996R Servo motor

1k Ohm resitor

FET : FQP30N06L. https://www.sparkfun.com/products/10213

2 x 10kOhm potentiometers (open/close set times)

Rotary Encoder with built in push button

Jumper wire

1A DC-DC converter : for Servo and solenoid

1 x SPDT toggle switch (Hour/Minute set selector)

1 x SPDT centre off momentary-off-momentary (for manual open/close)

1 x SPDT centre off (for blanking/time view/time set selector)

Solenoid: Push Pull 6-12V 10MM Stroke


Adafruit Simple RF M4 Receiver - 315MHz Momentary Type

Keyfob 2-Button RF Remote Control - 315MHz

Box

Step 8: Power Supply and Solar Panel & Battery Sizing.

1. Although the Arduino can run from 12Vdc, doing so would make it's onboard linear regulator to run hot. The servo operates better at a higher voltage (< 7.2V), so a compromise was to run the system of 9Vdc and use a DC-DC conveter to power the solenoid and servo at 6V. I guess the DC-DC converter could be done away with and the Arduino, servo motor and solenoid operate of the one same 6V (1A) supply. A 100uF capacitor would be recommended to filter out the Arduino from the servo and solenoid.

2. The controller I made drew a quiescent current of about 200mA. When the solenoid and servo were in operation, the current draw was about 1A.

The LED display can be blanked out with a switch to save battery power.

Considering that the door took about 7 seconds to open or close, and the open and close operations occurred only twice daily the 1A in the daily power consumption estimation was neglected.

It can run off a 1A 9V plug pack, but the mains and plug pack would need to be sheltered from the weather.

3. Daily energy use is calculated as 24h x 200mA = 4800mAh. A 7Ah lead acid battery with a 20W solar panel should suffice with one day autonomy in areas with an annual average of 5 hours insolation . But with more batteries and a bigger panel, there would be more days of autonomy.

I used the following online calculator to estimate battery and panel sizing:

https://www.telcoantennas.com.au/site/solar-power-...

Step 9: User Operation Instructions.

The door operates in either Automatic or Manual mode.

Automatic mode means that the door opens or closes according to the open or close time settings. Automatic mode is signified by a blank display when the display switch is set to "Blank". When the mode changes from manual to Automatic, the word 'AUTO' will flash for 200mS.

The door goes into Manual mode whenever the remote or swicth on the controller is activated. Manual mode is signified when the display shows "OPEn" or "CLSd" with the display switch is set to "Blank".

In Manual mode, the open/close time settings are ignored. It is up to the user to remember to close the door if it was manually opened, or open the door if it was manually closed, or set back to Automatic mode.

To switch back to Automatic mode, the user must press the Close button a second time if the door is already closed, or the Open button a second time if the door is already closed.

The door starts in Automatic mode at the beginning of the day (12:00am).

Step 10: Bells and Whistles

Some future improvements could include :

Wireless doorbell to signal when door opens/closes

"Stuck alarm" should the system draw the current equal to the solenoid and servo for more than 10 seconds.

Bluetooth and App to configure the controller.

Internet controlled opening and closing.

Replace LED display with LCD to show more information.

Do away with open/close time setting potentiometers and use a toggle switch and the existing rotary switch to set the open/close times.