loading

Pictures of the previous Arduino Chicken Coop Controller and its new cousin (top).

Over the last 18 months I have been using my Arduino based Chicken Coop Controller to great success with even a few folks out there ready to build their own versions. Since that time I have had a couple of door malfunctions (jamming) and one mechanical malfunction where the connector from the motor to the spindle broke and required glueing (because the door jammed!)

During this time I have had many followers and many thanks to all those who have commented and were keen to understand more about the project. For those who are interested in building this controller I would suggest you read the original instructable which covers the whole project from inception to operation. This Instructable will only cover the electronics and the code.

The instructable brings together a number of ideas that I wanted to originally include and others have asked me to build into the future design. Thanks to all who have urged me to bring out the v2 - sorry for the long wait.

Just to remind you the main features of the original ACCC were:

  • Based on the Arduino architecture for easy prototyping and adaptation to your coop requirements
  • Uses common parts easily found at you local DIY/hardware store/shop such as cheap electric screwdrivers
  • Uses a real time clock (RTC) to maintain time even when the device is temporary disconnected from power
  • Adjusts the opening and closing times of the door according to the current month - you can set it to your own timezones
  • Provides a manual override just in case one of your lovely darlings misses sunset!
  • Provides a min and max temperature reading inside the coop from midnight so you can keep an eye on your brood's welll-being
  • A display which can be switched on and off to read out the current ACCC status and will not disturb your feathered friends sleep at night

Most of the electronic components were sourced from eBay and I estimated (2012) the electronics would cost around £35

Step 1: The New Requirements

At the end of the previous project there were a couple of rough edges I wanted to smooth out:

  • Entering the up and down times for the door was done during programming and I found this needed to be adjusted during the course of the year which meant taking my MacBook into the coop and wiring it up to the Arduino which isn't much fun in the height of winter or summer
  • The up and down times for the door needed to be calculated in minutes from midnight which meant you had to do a quick mental calculation to realise 390 on the display meant 6.30 (390/60)!
  • I though I was pretty pleased with the amount of information I managed to squeeze in the 2 row x 20 character display. However you needed to concentrate to read-off the display as it displayed current then minimum and then maximum readings within about 3 seconds!
  • The system could only cope with one time setting without summer time savings (BST) which wasn't much of a problem as long as you remembered in the summer the coop clock was always going to be an hour behind BST for the UK

Some design suggestions I didn't take on. I drew the line at given the ladies under floor heating suggested by one of my fellow instructable colleagues!!

I suppose I have taken a 'suck it and see' approach in the evolution of the design which has been good and a couple of things came to light in normal day-to-day operation:

  • It was difficult to tell from my lounge window, while I had a beer in my hand, whether the door had gone down. In particular, if it had gone down successfully
  • When I did get a fault I found the motor ran the battery flat because it kept on spinning or even worst was stalled because the rope around the spindle was tight. This almost led to a motor driver burning out
  • If the controller missed the door closed trigger when the door was going down then the motor will continue until it has unraveled all the string and would then proceed to pull the door up! Something to avoid when you are plague with foxes
  • I really wanted to adjust the door up and down times without the use of the MacBook and to use something more simpler than the keyboard in the original design
  • When I originally built the electronics I did most of it myself but since then the building blocks for an Arduino are very cheap so I decide to to use some modules such as RTC (Real Time Clock) £3 and a small Arduino development board £4. Hopefully then others might be brave and take the plunge.

Step 2: Design Changes

The first major design change was the introduction of a menu driven system using one of the available systems for the Arduino. I went for the Phi_Prompt system as I found it was very well structured, adaptable and supported a number of screen and input types, including rotary. It didn't take me long to work out how to migrate my existing code into the structure. More on about the code in the next step.

I decided to substitute the 2 row display screen for a 4 row x 20 character display. The interface uses the standard 4bit interface - although those folks who have 2 row screens with built in keyboard still can use the code but will need to adapt a few parameters so you can scroll up and down to display all 4 rows. I have programmed the back light to stay on for a set period when it enters 'run mode'. That way you can check the times are correct and the temperature probe is working ok before walking away from the coop.

Instead of the keyboard I decide to go for a rotary switch with very basic debouncing circuitry interfaced to an Arduino development board called a Xino. I bought some right angled connector pins and used those instead of the supplied straight ones so I I could hook up the other modules from the side. That meant I can use push hoods to connect the components and modules. Again these leads with hoods are readily available on the internet.

While I had the door out I moved a few things around and created an easily accessible enclosure for the electronics with a door. Specifically I moved the motor driver board into the housing so I could easily access it if I had too. I decide also to up rate the microswitches to something more robust as I had a couple of switch fails mainly due to the weather and cold extremes we have had recently.

Step 3: The Electronics

As I have mentioned before I decided to use modules wherever possible and to make it easier for folks to do it themselves.

I have attached the schematic on how I wired the individual modules. Please note that various pull-up resistors for the probe and switched haven't been included but I have attached the previous schematic for v1 so you can understand how they are connected.

The key modules I used were:

  • Xeno Arduino prototyping board (£3.70) which you can add an ATMega328 chip(£3.00) or the Arduino Uno (£18)
  • ATMel programmer (£5.00) which can load the boot loader and program for you
  • MicroSwitch with Roller Actuator (Micro Switch) (£1.50) x 2off
  • Female to Female Jumper Wires Ribbon Cable (£1.50)
  • 6V 8Ah AGM Sealed Lead Acid Rechargeable Battery (£16.00)
  • Trickle Charger - make your own (£3.00)
  • 5 Pin Digital Push Button Switch Rotary Encoder/ Momentary Push Switch (£2.00)
  • Tiny RTC (£3.00)
  • HD44780 2004 20x4 White Characters LCD Display Module (£6.00)
  • L298N Dual H Bridge Stepper Motor Driver Controller Board (£5.00)

     

Step 4: Menu Driven - Code

As previously mentioned I used a LCD menu system library produced by Dr Lui - this library is called PHI_Prompt. The reason for this choice is that I wanted the ability to use a simple rotary switch to select certain variables within the program and change them to a prefixed range. For example for each month I can now manually set the up and down door times using the menu system.

I am not going to go in to too much depth in terms of explaining the code just the new features - everything else is similar to the previous code in the first version.

When you open Chicken_Coop_Controller_v2 you are presented with five tabs:

  • Chicken_Coop_Controller_v2
  • Coop_Control
  • Coop_Menu
  • RTC
  • TempProbe


Chicken_Coop_Controller_v2

The main labels definitions used within the code are here including the character mapping required by the menu system. If you were to decide to opt out using a rotary switch you could use the previous LCD keyboard (analogue restore network) instead. If you read the PHI manual it explains how you can change the input and output without to much modification to the code - very cleaver.

Global variables and libraries are also defined here. The program is initialised and then the top_menu() function is called to start the system which automatically goes into 'run mode'.


Coop_Control

This is were the bulk of the control logic sits when the 'RunController' menu options is selected. The default values for the door up and down times are set. This version now works in hours and minutes - so times are set hour, minute rather than total minutes which I know did confuse folks. In this section I have also added the logic (SetFlashOn) which causes an LED to come on when the door closes correctly and flashes when there is a problem when closing and opening


Coop_Menu

Here is where the structure and configuration for the Coop_menu sits:

  • Run Controller
  • Set Time/Date
  • Set Door Time
  • Door Up
  • Door Down
  • Door Parameters
  • About

For each menu selection there is a local call function which then calls on the Coop_Control functions. This section is relatively straightforward - well I hope!

I have added a failsafe feature to the door down and up options which keeps track of how long these functions have been running. If they go beyond the set parameter (MotorFailSafe) then the motor is shut down.

RTC

This code has been significantly modified so that it works with the DS1307 library. I have also added British Summer Time (BST) conversion logic. At the top of this code I have created 7 years of when the clocks go forward and backward. When the code goes to print the time it checks whether it needs to add an hour on Standard Greenwich Mean Time (GMT). This code also prints the door close and open times and sets the current time for use elsewhere in the code.

Within this code you can also set the Coop time and date using the menu input code. You are force to set time first by rotating and clicking the hour and then minute.

TempProbe

This code is very similar to the previous code in original controller. It reads a OneWired temperature probe and converts into a centigrade reading, then displayed and then compared with previous readings to see if it is a minimum or maximum reading. If so it is stored. The minimum and maximum readers are also then displayed

I have updated the software to run with the new Arduino 1.6.6 environment. I get one warning when it compiles but everything seems to be ok. If you have any problems drop me a line.

Step 5: In Operation

I have managed to cram all the electronics into the door assembly so there is very little for the ladies to peck at. The backlight for the display automatically turns off which can be set from one of the menu options.

In practice the rotary switch works fine but does suffer from the occasional de-bouncing which can be cured with a few resistors and capacitors. I have included a link to a good instructable for those who want pinpoint accuracy as they rotate through the menus and options.

https://www.instructables.com/id/Arduino-LCD-Metron...

The reality is I seldom take the the controller out of 'run mode' unless I want to stop my little lovelies from coming into the coop while I am doing something.


I have a thin cable coming out of the controller going to the roof where I have used a bright white 5mm LED as the door close signal and fault alarm. I sealed it in with a generous blob of silicon so to keep the damp from the pins.

I must admit I have found the options to change the down and uptime's on the fly a real time saver and the fact that it now displays the time in hours and mins is very helpful. Also it automatically adjusts for British Summer Time which means I know longer get confused as to whether the clock is right is another plus.

Probably the best feature is the flashing LED which one of my followers 'Larry' suggested is a real must. I can just peak out of my window to know if the door went down safely. When there might be a problem it flashes at me to make sure I come to the bottom of the garden to inspect which usually is a missed close door sensor trigger but because of the failsafe for the motors means the door stays down.

As ever I am happy to answer questions and I do hope you have enjoyed this instructable and it helps to stimulate your creative juices to help keep safe your feathered friends.

<p>Great instructable and thanks for posting.I have finally finished this project and it <br>has been up and running for about 2 weeks now without issue.This is the first significant Arduino project <br>I have done and I have learned a lot through it.The main modifications I made related to the <br>instructable were:</p><p>-Added 433MHz transmitter to send sensor/temp data <br>wirelessly and eliminated the status LED</p><p>-Added a 433MHz receiver,Arduino and ethernet shield in my <br>house to receive sensor data and post to https://thingspeak.com/channels/30092 <br>for online/remote monitoring.</p><p>-Used 4 reed switches, two at each location (door up/down) <br>for improved weatherproof sensors and as a fail-safe if any one sensor <br>fails.This required using an Arduino <br>Pro Mini clone for an additional 2 inputs.</p><p>-Tweaked code for DST so that both the time and up/down times <br>are adjusted based on DST.Since where I <br>am at DST is usually mid month and I wanted to insure the up/down times where <br>always correct.</p><p>-For the auto-locking mechanism I didn't use the circular <br>wood piece on a string to engage/disengage the lock as in my initial trials it <br>would bind on the locks and not work properly due to my geometry/friction.Instead of trying to work this out I just <br>attached the line directly to the inner portion locks as I saw on some other <br>designs, eliminating any chance of binding.</p>
<p>HELLO BS617,</p><p> It sounds like you have a 2 door coop system and that's what I'm working on. You have allot of the same hardware I am currently putting together for my Automatic Coop doors. Can I have a copy of your code? I am new to Arduino and code building and have a number of questions on how to include all of my hardware in one program to use. Can you send me a link to my email please. I would really appreciate it. I know this thread is old but you seem to have what I have been looking for. Thank you in advance. Neal Email: <a href="mailto:Nealbopper@yahoo.com" rel="nofollow">Nealbopper@yahoo.com</a></p>
Hi BS617<br><br>follow this link and it will take you to my latest software which works with 1.81 IDE. All the best - Robot-Chicken<br><br>https://www.instructables.com/id/Chicken-Coop-Controller-V4-Software-Update/
<p>Thanks for the update. I did have to update the libraries you mentioned as well to work with the IDE I was using. The door worked without any serious issue for about 1.5 years in Ohio weather, but now it is dormant until we get more chickens. </p>
First of all what a superb job you have done! You must be really chuffed with your work. Really like the extensions you have done to it using ThingSpeak which I have used on other projects.<br><br>Regarding the door I eventual took the two locks off mine as I realised there was no way a fox could get their paws under the door. I left the round piece though as this allowed the motors to slightly overrun but keeping the string taught.<br><br>I think you should take credit for creating chicken coop controller V3. Write it up and submit your work I am sure people would like to know in detail what you did.<br><br>Hope your chickens have many years of safe roosting!!
<p>Hi,</p><p>Thanks for this excellent tutorial. I am just teaching myself the workings of Arduinos and how to code them and am just about to get chickens so your project has really got me excited! I was wondering a couple of things; not having used an lcd with an Arduino before could you give me the connection details as I can't work it out. Also do I need to compile your different sketches into one sketch to upload to the ic? Sorry for the questions but I haven't done anything as complex with Arduino before.</p><p>Cheers</p><p>James</p>
<p>Many thanks James for your kind comments. You can find the wiring (Schematic) on my previous Instructable on Step 5. There is a ACCC schematic attached to this section.</p><p>When you expand the zipped sketch folder and open it under the arduino development environment all of the sketches should appear as tabs and when you go to compile all of the sketches compile into one upload. Hope this is helpful and feel free to email me via instructables</p>
<p>thanks robot chicken, you are a legend! also this reply has cleared up a few questins I was bothering other users with , my aplogies to whoever I was bugging. My motto is I know nothing... therefore willingness to learn should follow, fingers crossed.</p>
<p>Thanks for the great instuctable. All the bugs have been worked out and it has been in service for about a week now. So far everything all is good.</p>
<p>Hi Jeff, I love the simplicity of your design, looks like it should work with no mess, no frills, no hiccups? is it though few weeks later? if so I would love for you to share your design and step by step instructions if you dont mind with list of materials or where you sourced them like that thread bobbin? also the hinged project box is pretty neat, which boards did you use to fit into it so snuggly? cheers</p>
<p>Nice Job Jeff glad it is up and running</p>
<p>Hi Robot chicken,</p><p>I have been looking at your designed for a while now and we &quot;opened &quot; our coop in August. Our chickens don't wander free but I still would like to build this automated door.</p><p>I have ordered many of the parts yesterday but one difficulty I have is the board itself, you refer to the Arduino XINO and can't find these in the US. I have an Arduino Mega2560. I am trying to figure out how some of the ports you use relate to that board. The 2560 is an extended version of the Uno, basically more ports. Looking at various drawings online the 2560 has the the same ports but I confused where to find them. Your schematics are great but I have a hard time cross referencing them.</p><p>Is there any insight you could share here?</p><p>Thanks in advance,</p><p>Peter</p>
<p>I'm not sure the answer to your question, but I do have to ask why would you sacrifice an arduino mega just to have it sitting in your coop conrolling this project? You can get a cheap nano clone off ebay for under $3, or sainsmart uno for about $8.00 and save your mega for future projects.</p>
<p>that is a good question, I will do that. I have made progress, I received most of the parts and got the LCD screen to work last night. Working on the temperature sensor now. I am still waiting on the ATM programmer. I don't completely understand its function but I am learning on the way. This is one of those situations where I start with a complex project and have to learn all the parts in between. </p><p>Thank you</p><p>Peter</p>
https://m.instructables.com/id/Automatic-Chicken-Coop-Door-2/<br>Here is a coop door made for the mega, the code is much simpler than the robot chicken version and it uses a photo sensor so no messing with settings and it automatically adjusts to the seasonal light. I am waiting for all my electronic parts to show up from china, but in the mean time I have been tinkering with the code to display the current photocell reading on an LCD and allow you to select the threshold limits for daylight or night. Also a manual override as well as RTC mode instead of based off light are some features I am considering adding.
<p>Hi cmperos, yes! I was waiting for someone to say light sensor rather than tinkering with time settings! Tell me when it works and I'd love to know exactly how you did it if you have a step by step. I'm new to arduino and microcontrollers so I have no idea where to sink my teeth in. I know &quot;what&quot; I want to achieve basically, but not &quot;how&quot; to achieve it! I'm a pretty deft hand especially when it comes to woodworking and carpentry so I imagine mechanically I will fairly easily get that side of things sussed but electronics, phew! I have so much to learn but I'm very intriguid, very interested and very willing to learn. I have been using Linux and Rapberry pi since 2009 so I'm not unfaniliar to the commandline but each language is not without its differences, again willing to learn, where do I start please. Thanks a million in advance. </p>
<p>hi Peter</p><p>Sorry for the delay and hopefully not too late. For cheapness you can use the Arduino Uno board - RC</p>
<p>I too found this problem. Thanks for the link and I have now managed to get it to compile again in 1.6.1</p>
<p>Thanks RC, </p><p>I can now compile:-)</p>
<p>I running 1.6.5 and I can not make it compile. Could you uploade the code m&acute;with the new syntax?</p><p>Thanks.</p>
Hi Kaastrup<br><br>I need to check out the changes to the libraries since 1.01. Bear with me once I have it working I will send it up to be downloaded. I think the problem is in the menu library I took from someone else - RobotChicken
<p>I am on 1.7.7 and have compile issues as well. I am working on fixing and will post when figured out. I would prefer to update than to use 1.6.1. Let me know if you have solved.</p>
<p>Thanks for the update RC! I had some RTC issues in addition to the phi_prompts/interfaces updated libraries. I was using a newer DS1307 lib and had to make some changes to allow it to compiles. </p><p>Errors were related to RTC not defined in scope. So, I went to the Chicken_Controller_V3.ino and added the following after the pinout definitions:</p><p> DS1307 RT = DS1307();</p><p>This had errors on its own so I had to replace &quot;RTC.&quot; with &quot;RT.&quot; across the other .ino files and it fired right up. </p><p>I am posting in the event someone else has a similar experience.</p>
<p>Thanks for the instructable. I am new to <br>arduiono/electronics so this is my first &quot;big&quot; project. I am in the <br>infancy of the project and the first thing I tried was gathering the libraries <br>and compiling the sketch. This is where I ran into my first issue and figured I <br>would post the solution I found in case it helps someone else having issues <br>compiling the project. Basically in one of the latest Arduino IDEs (I'm using <br>1.6.1) the syntax for PROGMEM changed. From searching I found that a forum <br>thread that I believe is by the author of the phi_prompts library. <a href="http://forum.arduino.cc/index.php?topic=299928.0" rel="nofollow">http://forum.arduino.cc/index.php?topic=299928.0</a>. Follow the solution in the tread for <br>Chicken_Coop_Control_V2.ino, Coop_menu.ino and in the library phi_prompts.cpp <br>(just follow the error list to find the exact locations). Now on to the next <br>phase.</p>
voil&agrave; !! merci
<p>Great intstructable! I am trying to use your code as a jumping off point for my own project. You are the only person I found who has successfully used a rotary encoder with Dr Liu's Phi Interfaces/Phi Prompts. I have an arduino mega 2560, lcd, rtc, and rotary encoder breadboarded and loaded with your code. I'm running into a problem when I try to add the push button function. The button acts as though its is being continually depressed. I've been going over this for many hours and cannot figure out why this is happening. I have tried connecting the button to different pins. The button circuit is fine (I've checked it with other code). Did you have any problems with this? </p>
Hi Kevin<br><br>The only real problem I had was the rotary jumping the menu options because I didn't use an RC circuit to smooth out the encoder transitions.<br><br>Have you tried using another switch or another push switch to check the logic? You could also add a pull-up resistor to make sure when the switch is released the input pin goes back to 5v. I think you can set the ports to use their own internal resistor depending which board you use.<br><br>Hope this helps - RC
<p>fantastic project. I am having trouble connecting the RTC and coop controller sketches. Was wondering if you could give me some pointers</p>

About This Instructable

10,601views

75favorites

License:

Bio: I am consultant who spends his spare time dreaming up stuff and reading other people's great ideas. I have a growing family and a ... More »
More by Robot-Chicken:Chicken Coop Controller v4 Software Update Chicken Coop Controller v2 Software Update Arduino Chicken Coop Controller 
Add instructable to: