{"id":566,"date":"2024-05-22T04:59:02","date_gmt":"2024-05-22T04:59:02","guid":{"rendered":"https:\/\/kiphaynes.com\/?p=566"},"modified":"2025-08-28T15:33:24","modified_gmt":"2025-08-28T15:33:24","slug":"home-assistant-esphome-smart-chicken-manchen","status":"publish","type":"post","link":"https:\/\/kiphaynes.com\/?p=566","title":{"rendered":"Home Assistant + ESPHome Smart Chicken MancHEN"},"content":{"rendered":"\n<p>When Covid hit, we decided to join the chicken revolution. Mind you, this was not my idea. So one day I came home to 8 baby chicks in the garage. Of course, Theresa wanted some sort of chicken hut in the yard, so, not wanting to be outdone by our neighbors, I applied myself to building the mancHEN. Complete with shutters, water and power!<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"820\" src=\"https:\/\/kiphaynes.com\/wp-content\/uploads\/MANCHEN-1024x820.jpg\" alt=\"\" class=\"wp-image-575\" srcset=\"https:\/\/kiphaynes.com\/wp-content\/uploads\/MANCHEN-1024x820.jpg 1024w, https:\/\/kiphaynes.com\/wp-content\/uploads\/MANCHEN-300x240.jpg 300w, https:\/\/kiphaynes.com\/wp-content\/uploads\/MANCHEN-768x615.jpg 768w, https:\/\/kiphaynes.com\/wp-content\/uploads\/MANCHEN.jpg 1305w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>After some thought, I figured it would be fun to make it a smart chicken house, so we could monitor temperature, humidity and have a operational automatic door, as well as a streaming video feed, all controlled by the open source Home Assistant.<br><br><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"668\" src=\"https:\/\/kiphaynes.com\/wp-content\/uploads\/image-1024x668.png\" alt=\"\" class=\"wp-image-573\" srcset=\"https:\/\/kiphaynes.com\/wp-content\/uploads\/image-1024x668.png 1024w, https:\/\/kiphaynes.com\/wp-content\/uploads\/image-300x196.png 300w, https:\/\/kiphaynes.com\/wp-content\/uploads\/image-768x501.png 768w, https:\/\/kiphaynes.com\/wp-content\/uploads\/image.png 1084w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"283\" src=\"https:\/\/kiphaynes.com\/wp-content\/uploads\/NodeMCU-300x283.jpg\" alt=\"\" class=\"wp-image-567\" style=\"width:350px;height:auto\" srcset=\"https:\/\/kiphaynes.com\/wp-content\/uploads\/NodeMCU-300x283.jpg 300w, https:\/\/kiphaynes.com\/wp-content\/uploads\/NodeMCU.jpg 751w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/figure><\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"557\" src=\"https:\/\/kiphaynes.com\/wp-content\/uploads\/Schematic-1024x557.jpg\" alt=\"\" class=\"wp-image-568\" srcset=\"https:\/\/kiphaynes.com\/wp-content\/uploads\/Schematic-1024x557.jpg 1024w, https:\/\/kiphaynes.com\/wp-content\/uploads\/Schematic-300x163.jpg 300w, https:\/\/kiphaynes.com\/wp-content\/uploads\/Schematic-768x417.jpg 768w, https:\/\/kiphaynes.com\/wp-content\/uploads\/Schematic.jpg 1332w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p>I started with a NodeMCU board (<a href=\"https:\/\/www.amazon.com\/gp\/product\/B081CSJV2V\/\">ESP8266 NodeMCU<\/a>) as the main controller. It has wifi and enough GPIO&#8217;s to integrate with the motor driver, door stops and the environmental sensors. It also is very easy to code using <a href=\"https:\/\/esphome.io\/\">ESPHome.<\/a><br>Concerning the door, I started out using a servo motor, but it was not powerful enough to lift the wood door, so I ended up using door stop sensors. <br><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"479\" src=\"https:\/\/kiphaynes.com\/wp-content\/uploads\/PXL_20220424_011250817-1024x479.jpg\" alt=\"\" class=\"wp-image-576\" srcset=\"https:\/\/kiphaynes.com\/wp-content\/uploads\/PXL_20220424_011250817-1024x479.jpg 1024w, https:\/\/kiphaynes.com\/wp-content\/uploads\/PXL_20220424_011250817-300x140.jpg 300w, https:\/\/kiphaynes.com\/wp-content\/uploads\/PXL_20220424_011250817-768x359.jpg 768w, https:\/\/kiphaynes.com\/wp-content\/uploads\/PXL_20220424_011250817-1536x718.jpg 1536w, https:\/\/kiphaynes.com\/wp-content\/uploads\/PXL_20220424_011250817.jpg 1658w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"657\" height=\"473\" src=\"https:\/\/kiphaynes.com\/wp-content\/uploads\/image-1.png\" alt=\"\" class=\"wp-image-577\" srcset=\"https:\/\/kiphaynes.com\/wp-content\/uploads\/image-1.png 657w, https:\/\/kiphaynes.com\/wp-content\/uploads\/image-1-300x216.png 300w\" sizes=\"auto, (max-width: 657px) 100vw, 657px\" \/><figcaption class=\"wp-element-caption\">Buttons for manually opening and closing the door<\/figcaption><\/figure>\n\n\n\n<p>Here are the sensors and controllers used in the project<\/p>\n\n\n\n<p><a href=\"https:\/\/www.amazon.com\/gp\/product\/B081CSJV2V\/\">ESP8266 NodeMCU<\/a><br><a href=\"https:\/\/www.amazon.com\/gp\/product\/B07K9KPDNV\">12 Volt Motor<\/a><br><a href=\"https:\/\/www.amazon.com\/gp\/product\/B00TK0X03U\">Standard Motor Bracket<\/a><br><a href=\"https:\/\/www.amazon.com\/gp\/product\/B07C4YJK42\">Pulley<\/a><br><a href=\"https:\/\/www.amazon.com\/gp\/product\/B01DKC2GQ0\">DHT11 Temp and Humidity Sensor<\/a><br><a href=\"https:\/\/www.amazon.com\/gp\/product\/B099K8DWVV\">L298N Motor Drive Controller<\/a><br><a href=\"https:\/\/www.amazon.com\/gp\/product\/B0735BP1K4\">Magnetic Door Stop Switches<\/a><br><a href=\"https:\/\/www.amazon.com\/WMYCONGCONG-Waterproof-Momentary-Button-Switch\/dp\/B07VFRQWZC\/\">Metal Push Button Switches<\/a> (For manual operation)<br><a href=\"https:\/\/www.amazon.com\/gp\/product\/B0145OQXCK\">Amcrest RTSP Camera<\/a> (for live stream into home assistant)<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-video\"><video controls poster=\"https:\/\/kiphaynes.com\/wp-content\/uploads\/MANCHEN.jpg\" src=\"https:\/\/kiphaynes.com\/STUFF\/door.mp4\"><\/video><\/figure>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"552\" src=\"https:\/\/kiphaynes.com\/wp-content\/uploads\/allthestuff-1024x552.jpg\" alt=\"\" class=\"wp-image-569\" srcset=\"https:\/\/kiphaynes.com\/wp-content\/uploads\/allthestuff-1024x552.jpg 1024w, https:\/\/kiphaynes.com\/wp-content\/uploads\/allthestuff-300x162.jpg 300w, https:\/\/kiphaynes.com\/wp-content\/uploads\/allthestuff-768x414.jpg 768w, https:\/\/kiphaynes.com\/wp-content\/uploads\/allthestuff.jpg 1346w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p>And the ESPHome Code: Note that I have endstops at the top and bottom of the door, as well as timings in case the stops are missed. This is entered as a yaml config file in the ESP home plugin in Home Assistant:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>esphome:\n  name: chickenhouse2\n  platform: ESP8266\n  board: nodemcuv2\n\n# Enable logging\nlogger:\n\n# Enable Home Assistant API\napi:\n\nota:\n  password: \"xxxxx\"\n\nwifi:\n  ssid: \"ChickenNet\"\n  password: \"xxxx\"\n  use_address: 192.168.0.221\n  manual_ip:\n    static_ip: 192.168.0.221\n    gateway: 192.168.0.1\n    subnet: 255.255.255.0\n\n\nweb_server:\n  port: 80\n\nsensor:\n  - platform: dht\n    pin: D1\n    temperature:\n      name: \"My Temperature\"\n    humidity:\n      name: \"My Humidity\"\n    update_interval: 10s\n    model: DHT11\n    \n# Switches for motor control\nswitch:\n  - platform: gpio\n    pin: D4\n    name: \"MotorDriver1\"\n    id: motordriver1\n    # Use interlocking to keep at most one of the two directions on\n    interlock: &amp;interlock_group &#91;motordriver1, motordriver2]\n    # If ESP reboots, do not attempt to restore switch state\n    restore_mode: always off\n    \n  - platform: gpio\n    pin: D3\n    name: \"MotorDriver2\"\n    id: motordriver2\n    interlock: *interlock_group\n    restore_mode: always off\n\n#Sensors for door stops\nbinary_sensor:\n  - platform: gpio\n    pin:\n      number: D2\n      mode: INPUT_PULLUP\n    id: door_open_sensor\n    internal: True\n    on_press:\n      then:\n        - logger.log: \"Open Door Sensor Triggered\"\n    \n  - platform: gpio\n    pin:\n      number: D5\n      mode: INPUT_PULLUP\n    id: door_closed_sensor\n    internal: True\n    on_press:\n      then:\n        - logger.log: \"Close Door Sensor Triggered\"\n  - platform: gpio\n    pin:\n      number: D6\n      mode: INPUT_PULLUP\n    id: open_button\n    internal: True\n    on_press:\n      then:\n        - logger.log: \"open_button Pushed\"\n        - cover.open: chicken_door\n  - platform: gpio\n    pin:\n      number: D7\n      mode: INPUT_PULLUP\n    id: close_button\n    internal: True\n    on_press:\n      then:\n        - logger.log: \"close_button Pushed\"\n        - cover.close: chicken_door\ncover:\n  - platform: endstop\n    name: \"Chicken Door\"\n    id: chicken_door\n\n    open_action:\n      - logger.log: \"Open Requested\"\n      - switch.turn_off: motordriver2\n      - switch.turn_on: motordriver1\n    open_duration: 0.15min\n    open_endstop: door_open_sensor\n\n    close_action:\n      - logger.log: \"Close Requested\"\n      - switch.turn_off: motordriver1\n      - switch.turn_on: motordriver2\n    close_duration: 0.9min\n    close_endstop: door_closed_sensor\n\n    stop_action:\n      - switch.turn_off: motordriver1\n      - switch.turn_off: motordriver2\n    max_duration: 0.10min\n    <\/code><\/pre>\n\n\n\n<p>Also, in order to stream the RTSP camera, we add the camera info to Home Assistant&#8217;s config.yaml:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>amcrest:\n  - host: 192.168.0.236\n    username: admin\n    password: xxxxxx\n    name: MancHenCam<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/kiphaynes.com\/wp-content\/uploads\/IMG_20211030_160810-1024x768.jpg\" alt=\"\" class=\"wp-image-579\" srcset=\"https:\/\/kiphaynes.com\/wp-content\/uploads\/IMG_20211030_160810-1024x768.jpg 1024w, https:\/\/kiphaynes.com\/wp-content\/uploads\/IMG_20211030_160810-300x225.jpg 300w, https:\/\/kiphaynes.com\/wp-content\/uploads\/IMG_20211030_160810-768x576.jpg 768w, https:\/\/kiphaynes.com\/wp-content\/uploads\/IMG_20211030_160810-1536x1152.jpg 1536w, https:\/\/kiphaynes.com\/wp-content\/uploads\/IMG_20211030_160810.jpg 2000w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>When Covid hit, we decided to join the chicken revolution. Mind you, this was not my idea. So one day I came home to 8 baby chicks in the garage. Of course, Theresa wanted some sort of chicken hut in the yard, so, not wanting to be outdone by our neighbors, I applied myself to<\/p>\n<p><span class=\"xf__dots\">&#8230;<\/span><a class=\"xf__more xf__button\" href=\"https:\/\/kiphaynes.com\/?p=566\">Read More<\/a><\/p>\n","protected":false},"author":2,"featured_media":583,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-566","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","xf__entry"],"_links":{"self":[{"href":"https:\/\/kiphaynes.com\/index.php?rest_route=\/wp\/v2\/posts\/566","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kiphaynes.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kiphaynes.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kiphaynes.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/kiphaynes.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=566"}],"version-history":[{"count":7,"href":"https:\/\/kiphaynes.com\/index.php?rest_route=\/wp\/v2\/posts\/566\/revisions"}],"predecessor-version":[{"id":614,"href":"https:\/\/kiphaynes.com\/index.php?rest_route=\/wp\/v2\/posts\/566\/revisions\/614"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kiphaynes.com\/index.php?rest_route=\/wp\/v2\/media\/583"}],"wp:attachment":[{"href":"https:\/\/kiphaynes.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=566"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kiphaynes.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=566"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kiphaynes.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=566"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}