{"id":252,"date":"2022-05-06T02:50:03","date_gmt":"2022-05-06T02:50:03","guid":{"rendered":"https:\/\/mechied.com\/?post_type=portfolio&#038;p=252"},"modified":"2022-09-01T02:33:05","modified_gmt":"2022-09-01T02:33:05","slug":"smart-rain-barrel","status":"publish","type":"portfolio","link":"https:\/\/mechied.com\/index.php\/portfolio\/smart-rain-barrel\/","title":{"rendered":"Smart Rain Barrel"},"content":{"rendered":"\n<p>The best way for me to participate in Justine&#8217;s hobbies is to over-engineer them and her garden is no different.  To reduce the water we use to water her garden I came up with a smart water barrel that:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Can turn the pump for the barrel water on and off<\/li><li>Has four float switches to detect the barrel water level<\/li><li>Uses two valves to select barrel water or city water<\/li><li>Monitors two soil moisture sensors to determine if watering is needed<\/li><li>Connects to my <a href=\"https:\/\/www.home-assistant.io\/\" data-type=\"URL\" data-id=\"https:\/\/www.home-assistant.io\/\">Home Assistant<\/a> automation server for control and logging<\/li><li>Uses the weather forecast to postpone watering if rain is imminent<\/li><\/ul>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:33.33%\">\n<p>Here is my Friday Demo presentation about the rain barrel I gave at the beginning of Recurse Center.<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:66.66%\">\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Smart Rain Barrel\" width=\"1200\" height=\"675\" src=\"https:\/\/www.youtube.com\/embed\/8Xtu7_-1Htc?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n<\/div>\n<\/div>\n\n\n\n<p>The components are all installed in a waterproof project box.  I 3D printed brackets to hold the miscellaneous circuit boards.  I used various waterproof cable glands and cheap waterproof connectors to connect the pumps, valves, and sensors to the box.  The wiring is messy in this photo because I didn&#8217;t want to lock it down until all the programming is done.<\/p>\n\n\n\n<div class=\"wp-block-media-text alignwide is-stacked-on-mobile\"><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"500\" height=\"276\" src=\"https:\/\/mechied.com\/wp-content\/uploads\/2022\/07\/explainer-graphic-2-500x276.png\" alt=\"\" class=\"wp-image-282 size-full\" srcset=\"https:\/\/mechied.com\/wp-content\/uploads\/2022\/07\/explainer-graphic-2-500x276.png 500w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/07\/explainer-graphic-2-300x166.png 300w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/07\/explainer-graphic-2-768x424.png 768w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/07\/explainer-graphic-2-1536x848.png 1536w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/07\/explainer-graphic-2-2048x1130.png 2048w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/07\/explainer-graphic-2-400x221.png 400w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/07\/explainer-graphic-2-600x331.png 600w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/07\/explainer-graphic-2-800x442.png 800w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/07\/explainer-graphic-2-1920x1060.png 1920w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/figure><div class=\"wp-block-media-text__content\">\n<p>The communication between Home Assistant and the rain barrel controller is via MQTT &#8211; a simple messaging service for IOT devices.\u00a0 It&#8217;s very easy to do things like &#8220;send the water level&#8221; and then have Home Assistant recognize that as sensor data. The MQTT client controlling the rain barrel runs <a href=\"https:\/\/github.com\/daleshort\/smart-rain-barrel\">code I wrote in C++<\/a> running on an ESP8266 IoT board. The rain barrel controller sends periodic sensor data and listens for command messages to actuate the valves and pumps.<\/p>\n<\/div><\/div>\n\n\n\n<p>Here is the wiring for the rain barrel.<\/p>\n\n\n\n\n\t\t\n\t\t<div id=\"ep-gutenberg-content-b21ac985904643e09a6ad8275c0586cf\" class=\"ep-gutenberg-content   ep-percentage-width   ep-content-protection-disabled \">\n\t\t\t<div class=\"embedpress-inner-iframe emebedpress-unit-percent ep-doc-b21ac985904643e09a6ad8275c0586cf\"  style=\"max-width:100%\" id=\"embedpress-pdf-1651804795090\">\n\t\t\t\t<div >\n\t\t\t\t\t<div class=\"ep-embed-content-wraper\"><div class=\"position-right-wraper gutenberg-pdf-wraper\"><iframe title=\"wiring diagram\" class=\"embedpress-embed-document-pdf embedpress-pdf-1651804795090\" style=\"width:800px;height:800px; max-width:100%; display: inline-block\" src=\"https:\/\/mechied.com\/wp-admin\/admin-ajax.php?action=get_viewer&#038;file=https%3A%2F%2Fmechied.com%2Fwp-content%2Fuploads%2F2022%2F05%2Fwiring-diagram-1.pdf#key=dGhlbWVNb2RlPWRlZmF1bHQmdG9vbGJhcj10cnVlJnBvc2l0aW9uPXRvcCZwcmVzZW50YXRpb249dHJ1ZSZkb3dubG9hZD10cnVlJmNvcHlfdGV4dD10cnVlJmFkZF90ZXh0PXRydWUmZHJhdz10cnVlJmRvY19yb3RhdGlvbj10cnVlJmFkZF9pbWFnZT10cnVlJmRvY19kZXRhaWxzPXRydWUmem9vbV9pbj10cnVlJnpvb21fb3V0PXRydWUmZml0X3ZpZXc9dHJ1ZSZib29rbWFyaz10cnVlJmZsaXBib29rX3Rvb2xiYXJfcG9zaXRpb249Ym90dG9t\" frameborder=\"0\" oncontextmenu=\"return false;\"><\/iframe> <p class=\"embedpress-el-powered\">Powered By EmbedPress<\/p><\/div><\/div>\n\t\t\t\t\t\t\t<\/div>\t\t\t\n\t\t<\/div>\n\t<\/div>\n\n\n\n<p>Right now I&#8217;m just manually triggering the rain barrel to water but the next step is to implement a &#8220;water tomorrow at 6am for X amount of time&#8221; button to delay watering to an optimal time of day.&nbsp; If that goes well and I feel like I have a good handle on the sensor data I&#8217;d like to implement a &#8220;water tomorrow at 6am for X amount of time if it&#8217;s not going to rain and the soil is dry&#8221; routine.<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-2 is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"375\" height=\"500\" data-id=\"257\" src=\"https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/sensor-array-375x500.jpg\" alt=\"\" class=\"wp-image-257\" srcset=\"https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/sensor-array-375x500.jpg 375w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/sensor-array-225x300.jpg 225w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/sensor-array-768x1024.jpg 768w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/sensor-array-1152x1536.jpg 1152w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/sensor-array-1536x2048.jpg 1536w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/sensor-array-300x400.jpg 300w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/sensor-array-400x533.jpg 400w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/sensor-array-500x667.jpg 500w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/sensor-array-600x800.jpg 600w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/sensor-array-800x1067.jpg 800w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/sensor-array-scaled.jpg 1920w\" sizes=\"auto, (max-width: 375px) 100vw, 375px\" \/><figcaption>Float Sensor Array<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"375\" height=\"500\" data-id=\"256\" src=\"https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/rain-barrel-control-375x500.jpg\" alt=\"\" class=\"wp-image-256\" srcset=\"https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/rain-barrel-control-375x500.jpg 375w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/rain-barrel-control-225x300.jpg 225w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/rain-barrel-control-768x1024.jpg 768w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/rain-barrel-control-1152x1536.jpg 1152w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/rain-barrel-control-1536x2048.jpg 1536w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/rain-barrel-control-300x400.jpg 300w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/rain-barrel-control-400x533.jpg 400w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/rain-barrel-control-500x667.jpg 500w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/rain-barrel-control-600x800.jpg 600w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/rain-barrel-control-800x1067.jpg 800w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/rain-barrel-control-scaled.jpg 1920w\" sizes=\"auto, (max-width: 375px) 100vw, 375px\" \/><figcaption>Control Box Wiring<\/figcaption><\/figure>\n<\/figure>\n\n\n\n<p>The barrel is a trash can which I bought in white to match the house but turns out to be a poor color choice since algae gets enough light to grow inside.  Since it&#8217;s below the garden, there&#8217;s a sump pump inside and or this project I redid the plumbing after the pump to add the two automatic valves in a Y configuration feeding the spigot.<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-2 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/valves-rain-barrl-scaled.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"2560\" height=\"1920\" data-id=\"265\" src=\"https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/valves-rain-barrl-scaled.jpg\" alt=\"\" class=\"wp-image-265\" srcset=\"https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/valves-rain-barrl-scaled.jpg 2560w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/valves-rain-barrl-300x225.jpg 300w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/valves-rain-barrl-500x375.jpg 500w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/valves-rain-barrl-768x576.jpg 768w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/valves-rain-barrl-1536x1152.jpg 1536w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/valves-rain-barrl-2048x1536.jpg 2048w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/valves-rain-barrl-400x300.jpg 400w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/valves-rain-barrl-600x450.jpg 600w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/valves-rain-barrl-800x600.jpg 800w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/valves-rain-barrl-1920x1440.jpg 1920w\" sizes=\"auto, (max-width: 2560px) 100vw, 2560px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/full-barrel-scaled.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1920\" height=\"2560\" data-id=\"264\" src=\"https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/full-barrel-scaled.jpg\" alt=\"\" class=\"wp-image-264\" srcset=\"https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/full-barrel-scaled.jpg 1920w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/full-barrel-225x300.jpg 225w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/full-barrel-375x500.jpg 375w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/full-barrel-768x1024.jpg 768w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/full-barrel-1152x1536.jpg 1152w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/full-barrel-1536x2048.jpg 1536w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/full-barrel-300x400.jpg 300w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/full-barrel-400x533.jpg 400w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/full-barrel-500x667.jpg 500w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/full-barrel-600x800.jpg 600w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/full-barrel-800x1067.jpg 800w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image_from_ios-scaled.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1920\" height=\"2560\" data-id=\"263\" src=\"https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image_from_ios-scaled.jpg\" alt=\"\" class=\"wp-image-263\" srcset=\"https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image_from_ios-scaled.jpg 1920w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image_from_ios-225x300.jpg 225w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image_from_ios-375x500.jpg 375w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image_from_ios-768x1024.jpg 768w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image_from_ios-1152x1536.jpg 1152w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image_from_ios-1536x2048.jpg 1536w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image_from_ios-300x400.jpg 300w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image_from_ios-400x533.jpg 400w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image_from_ios-500x667.jpg 500w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image_from_ios-600x800.jpg 600w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image_from_ios-800x1067.jpg 800w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/figure>\n<\/figure>\n\n\n\n<p>Here&#8217;s what the rain barrel dashboard looks like in Home Assistant.  I created custom control panels using Home Assistant community components.<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-3 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"500\" height=\"264\" data-id=\"268\" src=\"https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image1-500x264.png\" alt=\"\" class=\"wp-image-268\" srcset=\"https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image1-500x264.png 500w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image1-300x158.png 300w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image1-768x405.png 768w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image1-1536x810.png 1536w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image1-400x211.png 400w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image1-600x316.png 600w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image1-800x422.png 800w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image1.png 1680w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image.png\"><img loading=\"lazy\" decoding=\"async\" width=\"500\" height=\"262\" data-id=\"269\" src=\"https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image-500x262.png\" alt=\"\" class=\"wp-image-269\" srcset=\"https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image-500x262.png 500w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image-300x157.png 300w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image-768x403.png 768w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image-1536x805.png 1536w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image-400x210.png 400w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image-600x314.png 600w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image-800x419.png 800w, https:\/\/mechied.com\/wp-content\/uploads\/2022\/05\/image.png 1679w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/figure>\n<\/figure>\n\n\n\n<p>One page is the controls where you can actuate the valves and turn the pump on and off.&nbsp; There&#8217;s also two commands you can send to the rain barrel to enable faster logging of the soil moisture (because I&#8217;m using an extra mechanical relay to mux the two soil moisture sensors to one analog input, I only check the soil moisture a few times an hour because otherwise the relay would have hundreds of thousands of cycles in only a few years of operation).&nbsp; The one soil moisture sensor is unplugged at the moment so the readings are screwy.&nbsp; For that matter, I&#8217;m still trying to figure out if the capacitive soil moisture sensor actually produces any useful data.&nbsp; The water level data seem reasonably well behaved after lots of averaging.<\/p>\n\n\n\n<p>The other page is a weather dashboard centered around the weather forecast for the next few days including a grid of dials that show the amount of rain and probability of the next four days.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A rain barrel that uses sensor and weather data to optimize water usage and automatically pumps water.<\/p>\n","protected":false},"author":1,"featured_media":264,"menu_order":10,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"_vp_format_video_url":"","_vp_image_focal_point":[],"footnotes":""},"portfolio_category":[9],"portfolio_tag":[],"class_list":["post-252","portfolio","type-portfolio","status-publish","format-standard","has-post-thumbnail","hentry","portfolio_category-c"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/mechied.com\/index.php\/wp-json\/wp\/v2\/portfolio\/252","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mechied.com\/index.php\/wp-json\/wp\/v2\/portfolio"}],"about":[{"href":"https:\/\/mechied.com\/index.php\/wp-json\/wp\/v2\/types\/portfolio"}],"author":[{"embeddable":true,"href":"https:\/\/mechied.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"version-history":[{"count":18,"href":"https:\/\/mechied.com\/index.php\/wp-json\/wp\/v2\/portfolio\/252\/revisions"}],"predecessor-version":[{"id":508,"href":"https:\/\/mechied.com\/index.php\/wp-json\/wp\/v2\/portfolio\/252\/revisions\/508"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mechied.com\/index.php\/wp-json\/wp\/v2\/media\/264"}],"wp:attachment":[{"href":"https:\/\/mechied.com\/index.php\/wp-json\/wp\/v2\/media?parent=252"}],"wp:term":[{"taxonomy":"portfolio_category","embeddable":true,"href":"https:\/\/mechied.com\/index.php\/wp-json\/wp\/v2\/portfolio_category?post=252"},{"taxonomy":"portfolio_tag","embeddable":true,"href":"https:\/\/mechied.com\/index.php\/wp-json\/wp\/v2\/portfolio_tag?post=252"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}