Building my automatic coop door opener. Wifi, Open source, ~$60

detz

Chirping
5 Years
Dec 3, 2014
107
6
63
Massachusetts
I doubt I actually need an automatic door since I went overboard of the predator proofing but it helps me sleep at night and it's a fun project. My project has a few things that I have yet to see in other projects that I wanted.

  • WiFi enabled with an app so I can open/shut and check the status from my phone.
  • Alerts if certain conditions are/not met. If the door isn't open/shut by x time send me a text/email
  • Open and close are tied to the actual sunset/sunrise times +- x minutes and not light




I'm using a Raspberry Pi A+ for the main brains because it's cheap, easy to make Internet enabled and can run most Linux software without an issue. The script so far is in Python but most of it is hacked together which I'm in the process of making much more readable and easy to understand.

You can find the code I've published so far here: https://github.com/ryanrdetzel/CoopControl
Materials so far:

Raspberry Pi A+: $20
Wifi USB: $8
Sensors: $6
DC Motor: $16
Random IC/Components: $5

Would love thoughts and ideas of improvement. I need to clean up the wires and put the electronics on a pcb and inside a bod and it will be ready to go outside. I've been testing it for days and it open and closes perfectly on time and the manual override is working so if I need to keep it open or closed I can. The motor works but it's slow, takes about 20 seconds to go up and down. Better slow than fast I guess.
 
Pretty crazy stuff for a chicken coop! I would add some sort of self-locking mechanism so that when the door closes by gravity, the mechanism latches the door down. And when the string is pulled up, the mechanism unhooks. This can be done with some scraps of plywood. I don't like the idea of a string-puller model without some security against raccoons figuring out how to lift the door.
I like the idea of open and close times being specified exactly instead of depending on the vagaries of a light sensor. Although there are very good arguments to be made for using the light sensor. I did the same thing with an Arduino wired into my commercially produced Ador1 door. For the Arduino/RaspberryPi inclined, the bit of data below is accessed to decide when to open/close the door. This piece of code is actually output from a second program I downloaded and modified that does earth/solar math calculations and adds some offsets for my personal preferences, and ignores daylight savings time.

static OpenCloseTime const oc_times[365] PROGMEM = {
{7, 58, 16, 59}, // Jan 1 7:59 AM - 5:10 PM
{7, 58, 17, 0}, // Jan 2 7:59 AM - 5:11 PM
{7, 58, 17, 1}, // Jan 3 7:59 AM - 5:12 PM
{7, 58, 17, 2}, // Jan 4 7:59 AM - 5:13 PM
{7, 58, 17, 3}, // Jan 5 7:59 AM - 5:14 PM
{7, 58, 17, 4}, // Jan 6 7:59 AM - 5:15 PM
{7, 58, 17, 5}, // Jan 7 7:59 AM - 5:16 PM
{7, 57, 17, 6}, // Jan 8 7:58 AM - 5:17 PM
etc
 
nice and simple. I have built stuff using the arduino including a incubator. Haven't tried the pi yet but im planning on it.

Only one problem I would worry about is if the door was to hit a object on the way down the code for the motor would probably just carry on paying out the string as its waiting to see the reed switch. Im more of a belt and braces kinda guy so I would have to have feedback to tell the controller where the door is. This could be a simple optical encoder with a optical wheel ($4) probably run off string or fine wire that's linked to the bottom and top of the door (pulleys another $3). theres lots of other ways of sensing where the door is but that's just a example.

I used the same motor for a egg turner on a cooler incubator that I built. It had been assembled badly at the factory but after a quick fix its been running every few hours for over 2 weeks now with out a problem.
 
It's possible for something to get stuck but since it's moving slow enough I would hope if it was a chicken it would get out of the way. :) One of the alarms is if the door isn't shut/open by a certain time so I will know if this happens. The string is not perfect, I need to replace it with some fishing line or something stronger since it has already snapped once and boy does it come crashing down, it would most certainly do some damage to a little chicken neck but the chances of that are slim.

I soldered up the components and have been testing. It opens and closes perfectly so assuming I have time to get it in the case it will be installed this weekend.

Here is the log for the last 24 hours.

2015-06-08 20:49:08,550 - INFO - Door should be closed based on time
2015-06-08 20:49:08,554 - INFO - Closing door
2015-06-08 20:49:39,235 - INFO - Bottom sensor triggered
2015-06-08 20:49:39,241 - INFO - Stop door
2015-06-08 20:49:40,248 - INFO - Door is closed

2015-06-09 05:07:16,909 - INFO - Door should be open based on time
2015-06-09 05:07:16,913 - INFO - Opening door
2015-06-09 05:07:50,945 - INFO - Top sensor triggered
2015-06-09 05:07:50,952 - INFO - Stop door
2015-06-09 05:07:50,958 - INFO - Door is open



I'm not worried about a lock. The door is pretty heavy and there are no places for little claws to get in there and pull it up. On top of that my run is already pretty secure so it's not likely something will get in. It wouldn't be hard to add a lock though I just don't think I need it.
 
Very cool. I've never considered a Rasberry until now. So how do you wire the DC motor to the board, and did you have to write a program from scratch in C to control the door? Is there a tutorial/API for a 12v controller or something?

I already bought a chicken door, but I have an itch to automate something now! I'm a programmer, but not a raw C/C++guru.
 
Very cool. I've never considered a Rasberry until now. So how do you wire the DC motor to the board, and did you have to write a program from scratch in C to control the door? Is there a tutorial/API for a 12v controller or something?

I already bought a chicken door, but I have an itch to automate something now! I'm a programmer, but not a raw C/C++guru.

It's Python not C, so easier to write/test. You can see the code here:

https://github.com/ryanrdetzel/CoopControl/blob/master/server.py

The motor is controlled via n h-bridge IC, the big IC chip you can see in the screenshot. Something like this: https://www.sparkfun.com/products/315
 

New posts New threads Active threads

Back
Top Bottom