{"id":866,"date":"2015-01-09T22:20:08","date_gmt":"2015-01-10T05:20:08","guid":{"rendered":"https:\/\/inkofpark.wordpress.com\/?p=866"},"modified":"2024-09-01T19:58:46","modified_gmt":"2024-09-02T01:58:46","slug":"the-electric-henhouse","status":"publish","type":"post","link":"https:\/\/www.inkofpark.com\/?p=866","title":{"rendered":"The Electric Henhouse"},"content":{"rendered":"<p><a href=\"http:\/\/www.inkofpark.com\/wp-content\/uploads\/2015\/01\/chx_composite.jpg\"><img loading=\"lazy\" decoding=\"async\" title=\"chx_composite\" style=\"border-top:0;border-right:0;background-image:none;border-bottom:0;padding-top:0;padding-left:0;border-left:0;display:inline;padding-right:0;\" border=\"0\" alt=\"chx_composite\" src=\"http:\/\/www.inkofpark.com\/wp-content\/uploads\/2015\/01\/chx_composite_thumb.jpg\" width=\"615\" height=\"396\"><\/a><\/p>\n<p>This spring three lovely chicks joined our family, Betty, Penny, and Ginger. Ginger discovered her inner rooster in due time, and was rehomed\u2014we are not zoned for the crowing half of the species. To protect the birds from freezing during our winter travels, and to let them out at the sunrise, they have been housed in the <em>electric henhouse.<\/em> At dawn and dusk the hens are released or secured by a linear actuator, locking in heat, wind and potential predators locked out.<\/p>\n<p align=\"center\"><strong>Betty watching the installation of the electric henhouse.<\/strong><\/p>\n<p align=\"center\"><a href=\"http:\/\/www.inkofpark.com\/wp-content\/uploads\/2015\/01\/betty_looking_at_install.jpg\"><img loading=\"lazy\" decoding=\"async\" title=\"betty_looking_at_install\" style=\"border-top:0;border-right:0;background-image:none;border-bottom:0;padding-top:0;padding-left:0;border-left:0;display:inline;padding-right:0;\" border=\"0\" alt=\"betty_looking_at_install\" src=\"http:\/\/www.inkofpark.com\/wp-content\/uploads\/2015\/01\/betty_looking_at_install_thumb.jpg\" width=\"374\" height=\"312\"><\/a><\/p>\n<p>The heart of the electric henhouse is a bare-chip variant of the Arduino. It connects to a <a href=\"https:\/\/learn.adafruit.com\/ds1307-real-time-clock-breakout-board-kit\">realtime clock<\/a> with battery backup to get the time. The time, in turn, is used with calculated sunrise and sunset so the door opens at sunrise and closes shortly after sunset when the birds have settled down for the night. The <a href=\"https:\/\/www.sparkfun.com\/products\/10524\">ATMega<\/a> runs at 5 volts, and so a dual H-bridge is used to provide the linear actuator with the power it needs.<\/p>\n<p><a href=\"http:\/\/www.inkofpark.com\/wp-content\/uploads\/2015\/01\/parts_overview.png\"><img loading=\"lazy\" decoding=\"async\" title=\"parts_overview\" style=\"border-top:0;border-right:0;background-image:none;border-bottom:0;padding-top:0;padding-left:0;border-left:0;display:inline;padding-right:0;\" border=\"0\" alt=\"parts_overview\" src=\"http:\/\/www.inkofpark.com\/wp-content\/uploads\/2015\/01\/parts_overview_thumb.png\" width=\"568\" height=\"386\"><\/a><\/p>\n<p>The overall code architecture is straightforward, every second the processor checks the time. If the time is between the sunrise and sunset, tell the motor to open, otherwise close. The motor module maintains a state so that it won\u2019t try to open an open door. The linear actuator is cleverly designed, it won\u2019t strain to open when it is always open and it won\u2019t close when all the way closed.<\/p>\n<p>The only code module with much complexity is the sunrise and sunset calculation, which is an approximation based on a <a href=\"http:\/\/williams.best.vwh.net\/sunrise_sunset_algorithm.htm\">US Naval Observatory<\/a> code, with only minor modifications. I tested it by running the calculation over a series of days throughout the year and comparing with published almanac.<\/p>\n<p>I purchased two separate FTDI USB-to-serial chips to program the bare ATMega chip, and was unable to get either of them working. I followed programming instructions similar to those <a href=\"http:\/\/voidyourwarranty.wordpress.com\/2014\/08\/17\/using-arduino-as-an-isp-to-program-a-standalone-atmega-328p-including-fuses\/\">here<\/a>, and those worked every time.<\/p>\n<p align=\"center\"><strong>The linear actuator is visible at the top. It slides the door (currently open).<\/strong><\/p>\n<p><a href=\"http:\/\/www.inkofpark.com\/wp-content\/uploads\/2015\/01\/20141221-0067.jpg\"><img loading=\"lazy\" decoding=\"async\" title=\"20141221-0067\" style=\"border-top:0;border-right:0;background-image:none;border-bottom:0;float:none;padding-top:0;padding-left:0;margin-left:auto;border-left:0;display:block;padding-right:0;margin-right:auto;\" border=\"0\" alt=\"20141221-0067\" src=\"http:\/\/www.inkofpark.com\/wp-content\/uploads\/2015\/01\/20141221-0067_thumb.jpg\" width=\"562\" height=\"430\"><\/a><\/p>\n<p>You can get the code on <a href=\"https:\/\/github.com\/parkhays\/electrichenhouse\">GitHub<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This spring three lovely chicks joined our family, Betty, Penny, and Ginger. Ginger discovered her inner rooster in due time, and was rehomed\u2014we are not zoned for the crowing half of the species. To protect the birds from freezing during our winter travels, and to let them out at the sunrise, they have been housed [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-866","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.inkofpark.com\/index.php?rest_route=\/wp\/v2\/posts\/866","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inkofpark.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inkofpark.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inkofpark.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inkofpark.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=866"}],"version-history":[{"count":1,"href":"https:\/\/www.inkofpark.com\/index.php?rest_route=\/wp\/v2\/posts\/866\/revisions"}],"predecessor-version":[{"id":1255,"href":"https:\/\/www.inkofpark.com\/index.php?rest_route=\/wp\/v2\/posts\/866\/revisions\/1255"}],"wp:attachment":[{"href":"https:\/\/www.inkofpark.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=866"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inkofpark.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=866"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inkofpark.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=866"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}