Being the conscientious folks we are, we like to make sure our chickens stay warm when it’s cold. They supply us with lots of free food, so its the least we can do. There are a few off-the-shelf devices that are able to sense temperature and change the state of a power outlet when things get too warm or cold, but where’s the fun in that? We take a lot more satisfaction from doing things ourselves (although the “we” in this sentence generally turns out to be more of an “I” when it comes to implementation.)
Long before we thought of automating chicken coops, I came across the Hobby Boards website. They seemed to have a lot of neat components that can be used to build or otherwise implement a lot of cool household things like environmental sensing of both interior and exterior conditions, sensing of arbitrary things using digital I/O ports, and control of arbitrary things using circuit relays. Once the prospect of chicken coop automation came along, it gave me a great excuse to buy some gadgetry and try things out!
There are only a few pieces involved with the chicken coop control system that I implemented:
- A computer running Linux
- One USB to 1-wire adapter
- One 8-channel IO/relay board
- Two temperature sensors
- One dual-throw relay capable of handling 120VAC at 10A (found at Radio Shack)
- One DC power adapter capable of activating the relay listed in #5
- Three power outlets and a three-gang outlet box
- Lots of wire of various types (exterior grade ethernet, telephone wire, extension cords)
- Some custom software scripts
The details of how things come together are long, tedious and boring, but I’ll give the Cliffs Notes version for those interested.
The basic physical setup puts the three outlets and the larger relay in the outlet box, which lives in the chicken coop. The three sets of outlets are wired in such a way that one pair of outlets is always on when connected to power, and the other two are controlled by the state of the relay in the outlet box. If the relay is off, one outlet is on and the other is off. If the relay is activated, the outlet that’s off turns on, and the on outlet turns off. I set things up this way so we could have the idea of a “default on” outlet and a “default off” outlet, which would let the heating lamps fall back to a sane state if the control system died. Heat lamps are plugged into the “default on” plugs in the winter and the “default off” plugs in the summer.
The larger relay in the outlet box is controlled via one of the smaller relays on the Hobby Boards relay 8-port relay board. I connected the DC power adapter in such a way that when I activate the smaller relay inside the house, it sends power through a control wire outside to the larger relay in the outlet box, which activates that relay and changes the state of the power outlets (Off to On or On to Off, depending on the outlet).
One of the temperature sensors is placed outside the chicken coop, and the other is inside. The idea behind this was to provide two perspectives on temperature level so my software could better decide whether to turn the heating lamps on or off. The heat lamps come on when either the inside or outside sensors see the temperature as being too cold, and the system turns off the lamps if the temperature inside the coop is too warm for heating.
The temperature sensors and the 8-port relay board connect to the computer via the USB to 1-wire dongle. This allows for the computer to read temperatures from the sensors and control the relays that change the power outlet states.
One of the added benefits of having all of this stuff controlled by a computer is that I can do other things with the temperature data and state of the various relays in the system. Things like graphs!
For those interested, I’ll probably be putting up a more detailed version of how things are built over at my blog – http://engi.neir.org. When that will appear is anybody’s guess.