<?xml-stylesheet type="text/xsl" href="https://community.element14.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>(Semi)Automated Plant Irrigation System</title><link>/challenges-projects/project14/mixing-electronics-water/b/blog/posts/semi-automated-plant-irrigation-system</link><description>Semi-automated Plant Irrigation System
Summary
This is an automated system for watering my olive tree.
 
The main components are:

A soil moisture sensor
A 10 gallon bucket of water with a water level sensor
An Adafruit Feather HUZZAH ESP8266 m...</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: (Semi)Automated Plant Irrigation System</title><link>https://community.element14.com/challenges-projects/project14/mixing-electronics-water/b/blog/posts/semi-automated-plant-irrigation-system</link><pubDate>Sat, 06 Oct 2018 17:10:18 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:0371e654-77cf-4f8a-aa66-5fe74a98db0a</guid><dc:creator>korn</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;I noticed you used a peristaltic pump. any reason for that choice? I usually only consider them for accurate dosing when used with a stepper motor. That &amp;#39;s a regular brushed motor.....&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I usually choose what I have on hand or what I can get cheap. I&amp;#39;ve used a few Marine wash down and bilge pumps.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I even got a couple of these diaphragm pumps: &lt;a class="jive-link-external-small" href="http://www.goldmine-elec-products.com/prodinfo.asp?number=G21177A" rel="nofollow ugc noopener" target="_blank" title="http://www.goldmine-elec-products.com/prodinfo.asp?number=G21177A"&gt;G21177A - (Pkg 2) Low Price 12VDC Flojet Pump&lt;/a&gt; &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;they need special fittings but that&amp;#39;s easy to make...&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=4238&amp;AppID=193&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: (Semi)Automated Plant Irrigation System</title><link>https://community.element14.com/challenges-projects/project14/mixing-electronics-water/b/blog/posts/semi-automated-plant-irrigation-system</link><pubDate>Fri, 05 Oct 2018 17:55:44 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:0371e654-77cf-4f8a-aa66-5fe74a98db0a</guid><dc:creator>korn</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Looks like a nice project. I bought the exact same sensor. sorry to hear it failed.&amp;nbsp; I think I&amp;#39;ll solder some 1/4in copper tubing to mine and place it in a weatherproof box with just the new legs sticking out..&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I have a couple of 55 gal drums on my gutter downspout. I wanted to do something similar but never had the time. I even tried to convince a friend to try it with a jug from the water cooler. I use a regular wash-down pump to supply a standard garden hose sprinkler. It still a manual thing.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;we talked about so many options like a i2c light or UV seniors to make sure it doesn&amp;#39;t start up in bright sunlight. &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;then we said rain sensor to make sure if it starts raining it will shut off water.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;now i think a sensor monitor that checks that the sensor readings vary every day is another feature..&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I may never build mine but its nice to see your progress...&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=4238&amp;AppID=193&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: (Semi)Automated Plant Irrigation System</title><link>https://community.element14.com/challenges-projects/project14/mixing-electronics-water/b/blog/posts/semi-automated-plant-irrigation-system</link><pubDate>Thu, 04 Oct 2018 18:49:47 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:0371e654-77cf-4f8a-aa66-5fe74a98db0a</guid><dc:creator>urkraft</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Bad news: The &lt;a class="jive-link-external-small" href="https://www.kjell.com/no/produkter/elektro-og-verktoy/arduino/moduler/luxorparts-jordfuktmaler-p87941" rel="nofollow ugc noopener" target="_blank"&gt;soil hygrometer&lt;/a&gt; which i used in this project has stopped working. It still gives a signal which no longer changes (has been at 183 for the past 4 days), but it turns out that the metal layer on the prongs which is buried in the soil has corroded away. Good thing that i noticed the strange behavior and investigated further before my olive tree died! Very sad. I was aware of the danger of using this cheap sensor at an early stage, but - unfortunately - i cannot afford a better solution. Am very curious about the &lt;a class="jive-link-external-small" href="http://www.vegetronix.com/Products/VH400/" rel="nofollow ugc noopener" target="_blank"&gt;Vegetronix VH400&lt;/a&gt;, but it is expensive - especially after the shipping charges and customs fees to Norway. Anyway - i guess that puts an end of this project. I hoped to make a pcb board and enclosure eventually. The sketch should also be modified to log the watering intervals and the amount of water that was used - possibly with other relevant data (at least temperature and humidity).&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;-raymond&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=4238&amp;AppID=193&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: (Semi)Automated Plant Irrigation System</title><link>https://community.element14.com/challenges-projects/project14/mixing-electronics-water/b/blog/posts/semi-automated-plant-irrigation-system</link><pubDate>Tue, 27 Feb 2018 19:52:25 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:0371e654-77cf-4f8a-aa66-5fe74a98db0a</guid><dc:creator>urkraft</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Here is a very cool irrigation system that i found recently that you may find interesting: &lt;a class="jive-link-external-small" href="https://www.hackster.io/walwode/herb-box-eco-system-7c51b3?utm_source=Hackster.io+newsletter&amp;amp;utm_campaign=b29bbeb1f6-EMAIL_CAMPAIGN_2017_07_26&amp;amp;utm_medium=email&amp;amp;utm_term=0_6ff81e3e5b-b29bbeb1f6-142246741&amp;amp;mc_cid=b29bbeb1f6&amp;amp;mc_eid=b63122b943" target="_blank"&gt;https://www.hackster.io/walwode/herb-box-eco-system-7c51b3?utm_source=Hackster.io+newsletter&amp;amp;utm_campaign=b29bbeb1f6-EMAIL_CAMPAIGN_2017_07_26&amp;amp;utm_medium=email&amp;amp;utm_term=0_6ff81e3e5b-b29bbeb1f6-142246741&amp;amp;mc_cid=b29bbeb1f6&amp;amp;mc_eid=b63122b943&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;-raymond&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=4238&amp;AppID=193&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: (Semi)Automated Plant Irrigation System</title><link>https://community.element14.com/challenges-projects/project14/mixing-electronics-water/b/blog/posts/semi-automated-plant-irrigation-system</link><pubDate>Thu, 22 Feb 2018 19:10:30 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:0371e654-77cf-4f8a-aa66-5fe74a98db0a</guid><dc:creator>urkraft</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Status update 22feb2018:&lt;/p&gt;&lt;p&gt;Unfortunately it appears that the soil hygrometer that i have been using does not appear to be accurate or reliable. Since it appeared to be widely used in Arduino projects that are published i just assumed that it was a good choice - or at least good enough. But my experience with it so far indicates otherwise. Already while i was documenting the project i began noticing posts/discussions by others who were havving issues with them. Here are a few customer evaluations at amazon.com:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Nope STAY AWAY. Corroded within days in SC soil.&lt;/li&gt;&lt;li&gt;&lt;span&gt;Had these for a little over a month and the PC board probes have been in the dirt for a little over a week. Pulled one out to see how it was faring (as the board signaled &amp;quot;dry conditions&amp;quot;, which it wasn&amp;#39;t), and the traces were almost gone. My well water is slightly acidic (approx. 6.8 to 6.9 pH) with many dissolved solids making it seem unlikely to be the reason the traces have been eaten away in such a short period of time. With the rapid deterioration, it would seem likely my plants would have died before their third watering. Very poor engineering. Disappointed. Now I have to wonder how much lead is in the solder covering the copper traces and how I can still utilize the rest of the circuits.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;Did not last. I know you get what you pay for but I wouldn&amp;#39;t have thought that after 1 day of use the probes corroded.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;Awful quality. Corroded away very quickly. I wouldn&amp;#39;t suggest buying them from long term watering/soil readings.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;As others have stated, the quality of the probe is inferior. After only a few days of use the metal on probes has come off.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;The readings are all over the place. I tried two at the same time in a cup of water and both sensors had different readings and they were off by more than 15%. Also noticed that over time, the reading gradually declines. Very inconsistent!&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;Ok if you have a short term project to mess around with but they fail pretty fast, The copper corrodes and the reading values go crazy.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;really inaccurate and inconsistant. There is now way I could automate my watering because this sensor is really more of a toy or learning device but really won&amp;#39;t work well in a true control system.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span&gt;My experience with this sensor is consistent with these evaluations - and my conclusions likewise. I noticed quite early that the readings were erratic - both from the digital pin as well as the analog. My application displays the values on the OLED display and the values are varying constantly. &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span&gt;Today i decided to change my approach in order to get more stable readings. I would in essence make two changes:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;span&gt;Only take readings once each second.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;Put the readings in a 16 position ring buffer and use the averages of the last 16 readings after each reading.&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span&gt;I decided to make a little sketch to test the code on another Arduino. I have 2 soil hygrometers, so i could play around with the code while making actual readings with the sensor dipped in water. What i observed was that the readings are less erratic - as expected - but even though the sensor is submerged in water (which should represent totally saturated soil that cannot possibly get more saturated) the values have been drifting quite a bit. After running the code for about an hour it appears to be quite stable around 491, but there is still a little bit of drifting going on. I do not understand why there should be any drifting at all when the sensor prongs are submerged in water, but it is. It wouldn&amp;#39;t be too bad though if that was the worst of it, but the fact that the copper will corrode pretty quickly is totally unacceptable.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span&gt;Here is the code that i have been using to test this:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:3ef06e6b-9b7d-4651-b12d-db8be7f5e991:type=c_cpp&amp;amp;text=%2F*+%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A+*++Ring+Buffer%3A%0A+*++%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A+*++Program+for+testing+use+of+ring+buffer+for+averaging+soil+hygrometer+readings%0A+*++%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A+*%2F%0A%0A%0Aconst+int+HYGROMETER_READINGS_SIZE+%3D+16%3B%0Aconst+unsigned+long+SECOND+%3D+1000UL%3B%0A%0A%0Aint+hygrometerReadings%5B16%5D+%3D+%7B0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%7D%3B%0Aint+hygroReading%3D+0%3B%0Aint+hygroReadingPos+%3D+0%3B%0Aint+hygroReadingTotal+%3D+0%3B%0A%0A%0Aunsigned+long+lastReadingTime+%3D+millis%28%29%3B%0Aunsigned+long+thisReadingTime%3B%0A%0A%0Avoid+setup%28%29+%7B%0A++Serial.begin%289600%29%3B%0A++delay%28100%29%3B%0A%0A%0A%7D%0A%0A%0Avoid+loop%28%29+%7B%0A++thisReadingTime+%3D+millis%28%29%3B%0A++if+%28%28thisReadingTime+-+lastReadingTime%29+%3E%3D+SECOND%29+%7B%0A++++lastReadingTime+%3D+thisReadingTime%3B%0A++++Serial.println%28getHygrometerReading%28%29%29%3B%0A++%7D%0A%7D%0A%0A%0Aint+getHygrometerReading%28%29+%7B%0A++%0A++hygroReadingTotal+-%3D+hygrometerReadings%5BhygroReadingPos%5D%3B%0A++hygrometerReadings%5BhygroReadingPos%2B%2B%5D+%3D+hygroReading+%3D+analogRead%28A0%29%3B%0A++if+%28hygroReadingPos+%3D%3D+HYGROMETER_READINGS_SIZE%29+%7B%0A++++hygroReadingPos+%3D+0%3B%0A++%7D%0A++hygroReadingTotal+%2B%3D+hygroReading%3B%0A++return+%28hygroReadingTotal+%2F+HYGROMETER_READINGS_SIZE%29%3B%0A%7D]&lt;/p&gt;&lt;div&gt;&lt;/div&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;The last few days i have been looking for an alternative sensor to use, but have not been successful. In chapter 10 of his book &amp;quot;Arduino Projects for Dummies&amp;quot;, Brock Craft documents his project for building an automated garden. There he builds his own soil hygrometer using galvanized finishing nails, plaster of paris, wires, and some clear vinyl tube. Although his sensor appears to be much more durable than the ones i have been experimenting with, i have seen a few posts where people who use similar sensors say that it holds moisture much longer than soil does and therefore is not reliable. I plan to keep looking, but the only real alternatives that i have found are either based only on giving visual indicators or much more expensive than someone in my economical circumstances can afford.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Even though testing indicates that the soil hygrometer sensor being used is nothing more than a toy i decided to implement the code that i used for testing it (above) in the system code. Here is the updated sketch that i am now using in the Arduino Uno for the irrigation system:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:3ef06e6b-9b7d-4651-b12d-db8be7f5e991:type=c_cpp&amp;amp;text=%2F**********************************************************************************************%0A*+Program+for+semi-automated+irrigation+using+Arduino+Uno%0A*+%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A*+%0A*+Summary%3A%0A*+--------%0A*+%0A*+The+main+components+of+the+system+are%3A%0A*+%0A*+-+An+Arduino+Uno+%28hereafter+referred+to+as+%E2%80%9CUno%E2%80%9D%29+which+controls+everything%0A*+-+A+9V+DC+1A+power+adapter+for+the+Uno%0A*+-+An+ESP-01+WiFi+module+which+is+used+to+facilitate+messaging%0A*+-+A+FC-28+soil+hygrometer+%28moisture+sensor%29+for+detecting+humidity+in+soil%0A*+-+A+water+level+switch+NC+mounted+on+a+float+for+detecting+when+the+water+reservoir+is+empty%0A*+-+A+Keyes+KY-040+rotary+encoder+is+used+to+adjust+threshold+values+used+by+the+sketch%0A*+-+A+0.96%22+128+x+64+pixel+OLED+graphical+display+used+to+display+status+information%0A*+-+A+peristaltic+water+pump+to+pump+water+from+the+water+reservoir+to+the+soil%0A*+-+A+12V+DC+1A+power+adapter+for+the+water+pump%0A*+-+A+10+gallon+bucket+of+water+%28water+reservoir%29%0A*+-+A+potted+plant+to+water%0A*+%0A*+Operation%3A%0A*+%0A*+The+two+sensors+%28soil+hygrometer+and+water+level+switch%29+are+connected+to+inputs+of+the+Uno+%0A*+%28A0+and+D11+respectively%29+and+the+water+pump+is+controlled+by+an+output+signal+%28D10%29+from+%0A*+the+Uno.+Two+LED%E2%80%99s+are+controlled+by+output+signals+from+the+Uno+and+are+used+as+status+%0A*+indicators%3A%0A*+%0A*+-+Red++%3A+%28D13%29+Lit+to+indicate+that+the+soil+is+dry+enough+to+warrant+watering%0A*+-+Blue+%3A+%28D12%29+Lit+to+indicate+that+the+water+reservoir+is+empty+%28requires+a+refill+of+water%29%0A*+%0A*+A+0.96%22+128+x+64+piksel+OLED+graphical+display+is+also+used+to+display+status+information%0A*+and+to+adjust+threshold+levels+for+turning+the+water+pump+on+and+off.+It+uses+the+Uno%27s+I2C+%0A*+interface+%28A5%28SCL%29+and+A4%28SDA%29%29.%0A*+%0A*+A+Keyes+KY-040+rotary+encoder+is+used+together+with+the+OLED+display+to+adjust+the+threshold+%0A*+values+used+by+the+script.+It+uses+the+D2+through+D5+pins+as+input.+The+system+goes+into+%0A*+adjustment+modus+when+the+knob+is+depressed.+The+user+can+then+scroll+through+the+items+which%0A*+can+be+adjusted.+The+item+to+calibrate+is+choosen+by+depressing+the+switch+once+more+when+it+%0A*+displayed.+This+causes+the+system+to+display+the+current+value+being+used+for+that+item.+The%0A*+user+can+then+increase+the+value+by+turning+the+knob+clockwise+%28whereupon+the+displayed+value+%0A*+increases%29+or+counter+clockwise+%28whereupon+the+displayed+value+decreases%29.+To+choose+the+%0A*+displayed+value+the+user+must+depress+the+knob+-+whereupon+the+system+also+exits+adjustment+%0A*+mode+and+commenses+to+use+the+new+values.%0A*+%0A*+There+are+three+criteria+which+all+have+to+be+met+in+order+to+turn+on+the+pump+%28and+water+%0A*+the+plant%29%3A%0A*+%0A*+1%29++There+must+be+water+in+the+reservoir%0A*+2%29++The+soil+moisture+reading+in+the+soil+must+be+greater+than+a+specified+high+threshold+%0A*+++++value+%28indicating+the+soil+is+too+dry%29%0A*+3%29++A+specified+minimum+amount+of+time+must+have+elapsed+since+the+pump+was+last+turned+off+%0A*+++++while+watering+%28but+not+if+this+was+due+to+entering+adjustment+modus%29.%0A*+++++%0A*+Any+one+of+the+following+criteria+will+cause+the+pump+to+be+turned+off%3A%0A*+%0A*+-+No+water+left+in+the+water+reservoir%0A*+-+The+moisture+reading+of+the+soil+is+lower+than+a+specified+low+threshold+value+%0A*+++%28indicating+the+soil+has+been+irrigated+sufficiently.+This+criteria+also+triggers+the+%0A*+++timer+which+keeps+track+of+the+amount+of+time+that+has+elapsed+since+the+pump+was+turned+%0A*+++off%29.%0A*+-+the+pump+has+been+on+continually+for+at+least+MAX_PUMP_ON_TIME+milliseconds.%0A*+-+%28only+temporarily%29+entering+adjustment+modus%0A*+++%0A*+Basically%2C+the+Uno+just+goes+in+a+loop+checking+the+criteria+above+and+taking+action+%0A*+when+necessary.+Each+loop+iteration+takes+approximately+20-30+seconds+to+complete.+If%2C%0A*+however+the+knob+of+the+rotary+encoder+is+depressed+and+this+is+detected%2C+the+function%0A*+for+adjustment+modus+is+called+and+normal+operation+is+not+resumed+until+after+returning%0A*+from+the+function.+Before+the+adjustment+function+is+called+the+water+pump+and+on+time+%0A*+timer+are+both+stopped+if+the+pump+is+on.+Both+are+then+resumed+upon+returning+from+the%0A*+adjustment+function.%0A*+%0A*+Notes%3A%0A*+%0A*+GPIO+ESP_WATER_EMPTY+is+used+to+signal+to+the+ESP-01+that+the+water+reservoir+is+empty+%0A*+%28via+the+GP0+pin+of+the+ESP-01%29.+The+ESP-01+is+configured+to+use+its+GPIO0+as+an+input.+A+LOW+%0A*+signal+on+this+pin+will+trigger+the+sendMessage%28FILL_RESERVOIR_URL%29+function+on+the+ESP-01.+%0A*+This+function+invokes+a+PHP+script+on+my+Raspberry+Pi+server+via+a+HTTP+GET+request.+The%0A*+paramater+it+uses+indicates+which+script+to+invoke.+This+one+%28FILL_RESERVOIR_URL%29+results%0A*+in+an+e-mail+being+sent+to+me+informing+me+that+the+water+reservoir+is+empty.+The+ESP-01%0A*+also+calls+this+function+with+CONNECT_SUCCESS_URL+as+the+parameter+from+its+setup%28%29+function.+%0A*+The+resulting+e-mail+informs+me+that+the+the+ESP-01+has+successfully+connected+to+the+WiFi+%0A*+and+it+also+reminds+me+that+any+custom+thresholds+need+to+be+re-entered+%28since+this+e-mail%0A*+will+only+be+sent+whenever+the+ESP-01+restarts+%3D%3E+the+Uno+has+also+been+restarted.%0A*+%0A*+Future+features+to+impliment%3A%0A*+%0A*+-+replace+Uno+with+custom+design+%28with+ability+to+reprogram+by+attaching+adequate%0A*+++IO+interface%29%0A*%2F%0A%23include+%0A%23include+%0A%23include+%3Cadafruit_gfx.h%3E%0A%23include+%3Cadafruit_ssd1306.h%3E%0A%0A%0A%23define+OLED_RESET+4%0AAdafruit_SSD1306+display%28OLED_RESET%29%3B%0A%0A%0A%23define+NUMFLAKES+10%0A%23define+XPOS+0%0A%23define+YPOS+1%0A%23define+DELTAY+2%0A%0A%0A%0A%0A%23define+LOGO16_GLCD_HEIGHT+16+%0A%23define+LOGO16_GLCD_WIDTH++16+%0A%23if+%28SSD1306_LCDHEIGHT+%21%3D+32%29%0A%23error%28%22Height+incorrect%2C+please+fix+Adafruit_SSD1306.h%21%22%29%3B%0A%23endif%0A%0A%0A%2F%2F%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A%2F%2F+encoder+stuff%0A%2F%2F%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A%23define+ENCODER_CLK+2%0A%23define+ENCODER_DT+3%0A%23define+ENCODER_SW+4%0A+%0Aint+encoderCounter+%3D+0%3B+%0Aint+encoderClkState%3B%0Aint+encoderClkLastState%3B++%0Aint+encoderSwLastState%3B%0Aint+encoderSwState%3B%0Aint+encoderPosition+%3D+0%3B%0A%0A%0A%2F%2F+I%2FO%0Aconst+int+DRY_LED+%3D+13%3B++%2F%2F+%28Output%29+used+to+indicate+what+pump+status+should+be+ON+%28set+HIGH%29+when+the+pump+should+be+on%0Aconst+int+PUMP+%3D+10%3B+%2F%2F+%28Output%29+used+to+turn+the+pump+on+%28set+HIGH%29+and+off+%28set+LOW%29%0Aconst+int+WATER_EMPTY_LED+%3D+12%3B++%2F%2F+%28Output%29+used+to+indicate+if+the+reservoir+is+empty+%28set+HIGH+%3D%3E+ON%29%0Aconst+int+WATER_LEVEL+%3D+11%3B++%2F%2F+%28Input%29+used+to+detect+if+there+is+water+in+the+reservoir+%28HIGH%29+or+if+it+is+empty+%28LOW%29%0Aconst+int+ESP_WATER_EMPTY+%3D+9%3B++%2F%2F+%28Output%29+used+to+signal+the+ESP-01+that+the+water+reservoir+is+empty+%28set+LOW+%3D%3E+empty%29%0A%0A%0A%2F%2F+A0+%3A+ADC+%28Analog+Input%29+used+to+read+soil+humidity%3A+high+value+%3D%3E+dry%2C+low+value+%3D%3E+wet+%0A%2F%2F+Max+value+is+approx.+1018+-+bone+dry%0A%2F%2F+Min+value+is+approx.+530+-+drowning+in+water%0Aconst+unsigned+long+MINIMUM_TIME+%3D+1000UL+*+60UL+*+60UL+*+24UL%3B+%2F%2F+minimum+time+that+must+transpire+between+irrigation+%281+day%29%0A%2F%2Fconst+unsigned+long+MINIMUM_TIME+%3D+60UL+*+1000UL%3B+%2F%2F+minimum+time+that+must+transpire+between+irrigation+%28only+for+testing%29%0Aconst+unsigned+long+MAX_PUMP_ON_TIME+%3D+1000UL+*+60UL+*+15UL%3B+%2F%2F+maximum+time+pump+can+be+turned+on+for+%2815+minutes%29%0A%2F%2Fconst+unsigned+long+MAX_PUMP_ON_TIME+%3D+60UL+*+1000UL%3B+%2F%2F+maximum+time+pump+can+be+turned+on+for+%28only+for+testing%29%0A%0A%0A%2F%2F%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A%2F%2F+VARIABLES%0A%2F%2F%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A%0A%0A%2F%2F+timing%0Aunsigned+long+lastIrrMillis+%3D+0UL%3B%0Aunsigned+long+currentMillis+%3D+0UL%3B%0Aunsigned+long+pumpOnMillis+%3D+0UL%3B%0A%0A%0Aunsigned+long+lastReadingTime+%3D+millis%28%29%3B%0Aunsigned+long+thisReadingTime%3B%0A%0A%0A%2F%2F+soil+moisture+reading%0Aint+pumpOnThresh+%3D+200%3B++%2F%2F+Turn+on+the+pump+when+ADC+input+value+%3E%3D+this+value%0Aint+pumpOffThresh+%3D+190%3B+%2F%2F+Turn+off+the+pump+when+ADC+input+value+%3C%3D+this+value+%28and+do+not+trun+on+again+for+at+least+a+day%29%0Abool+pumpIsOn+%3D+false%3B%0Aint+moisture+%3D+800%3B+%2F%2F+previous%0Aint+waterLevel%3B%0A%0A%0Aconst+int+HYGROMETER_READINGS_SIZE+%3D+16%3B%0Aconst+unsigned+long+SECOND+%3D+1000UL%3B%0A%0A%0Aint+hygrometerReadings%5B16%5D+%3D+%7B0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%7D%3B%0Aint+hygroReading%3D+0%3B%0Aint+hygroReadingPos+%3D+0%3B%0Aint+hygroReadingTotal+%3D+0%3B%0A%0A%0A%2F%2Fint+tmpMoisture+%3D+0%3B++%2F%2F++new+%28temporary%29%0A%0A%0Aint+displayLine+%3D+0%3B%0Aconst+int+DISPLAY_LINE_INCREASE+%3D+8%3B%0Aconst+int+DISPLAY_LINE_MAX+%3D+32%3B%0A%0A%0A%2F%2F%3D%3D%3D%3D%3D%3D%0A%2F%2F+SETUP%0A%2F%2F%3D%3D%3D%3D%3D%3D%0A%0A%0Avoid+setup%28%29+%7B%0A++%2F%2F+initialize+Serial%0A++Serial.begin%289600%29%3B%0A++delay%28100%29%3B%0A%0A%0A++Serial.println%28%22Soil+moisture+sensor%22%29%3B%0A%0A%0A++%2F%2F+initialize+IO%0A++pinMode%28WATER_LEVEL%2C+INPUT_PULLUP%29%3B%0A++%0A++pinMode%28PUMP%2C+OUTPUT%29%3B%0A++digitalWrite%28PUMP%2C+LOW%29%3B%0A++pumpIsOn+%3D+false%3B%0A++%0A++pinMode%28DRY_LED%2C+OUTPUT%29%3B%0A++digitalWrite%28DRY_LED%2C+LOW%29%3B%0A++%0A++pinMode%28WATER_EMPTY_LED%2C+OUTPUT%29%3B%0A++digitalWrite%28WATER_EMPTY_LED%2C+LOW%29%3B%0A%0A%0A++pinMode%28ENCODER_CLK%2C+INPUT%29%3B%0A++pinMode%28ENCODER_DT%2C+INPUT%29%3B%0A++pinMode%28ENCODER_SW%2C+INPUT%29%3B%0A++%0A++%2F%2F+by+default%2C+we%27ll+generate+the+high+voltage+from+the+3.3v+line+internally%21+%28neat%21%29%0A++display.begin%28SSD1306_SWITCHCAPVCC%2C+0x3C%29%3B++%2F%2F+initialize+with+the+I2C+addr+0x3C+%28for+the+128x32%29%0A++%2F%2F+init+done%0A++%0A++display.setTextSize%281%29%3B%0A++display.setTextColor%28WHITE%29%3B%0A%0A%0A++pinMode%28ESP_WATER_EMPTY%2C+OUTPUT%29%3B%0A++digitalWrite%28ESP_WATER_EMPTY%2C+HIGH%29%3B%0A%7D%0A%0A%0Avoid+loop%28%29+%7B%0A++%2F%2F+rotary+encoder+stuff%0A++encoderSwState+%3D+digitalRead%28ENCODER_SW%29%3B%0A++if+%28%28encoderSwLastState+%3D%3D+encoderSwState%29+and+%28encoderSwState+%3D%3D+false%29%29+%7B%0A++++unsigned+long+deltaTime%3B%0A++++if+%28pumpIsOn%29+%7B%0A++++++deltaTime+%3D+millis%28%29+-+pumpOnMillis%3B%0A++++++digitalWrite%28PUMP%2C+LOW%29%3B%0A++++%7D%0A++++chooseMenu%28%29%3B%0A++++if+%28pumpIsOn%29+%7B%0A++++++pumpOnMillis+%3D+millis%28%29+-+deltaTime%3B%0A++++++digitalWrite%28PUMP%2C+HIGH%29%3B%0A++++%7D%0A++++delay%281000%29%3B%0A++%7D%0A%0A%0A++%2F%2Firrigation+stuff%0A++waterLevel+%3D+readInput%28WATER_LEVEL%29%3B++%2F%2F+read+water+level%0A++if+%28waterLevel+%3D%3D+LOW%29+%7B++%2F%2F+water+reservoir+is+empty%0A++++digitalWrite%28PUMP%2C+LOW%29%3B+%2F%2F+turn+off+pump%0A++++pumpIsOn+%3D+false%3B%0A++++digitalWrite%28WATER_EMPTY_LED%2C+HIGH%29%3B+%2F%2F+turn+on+LED+indicator%0A++++digitalWrite%28ESP_WATER_EMPTY%2C+LOW%29%3B++%2F%2F+signal+ESP-01+to+send+e-mail+informing+water+reservoir+is+empty%0A++++%2F%2F+Serial.println%28%22The+water+reservoir+is+empty+%3D%3E+fill+it+up%21%22%29%3B%0A++%7D+else+%7B%0A++++digitalWrite%28WATER_EMPTY_LED%2C+LOW%29%3B+%2F%2F+turn+off+LED+indicator%0A++++digitalWrite%28ESP_WATER_EMPTY%2C+HIGH%29%3B++%2F%2F+signal+ESP-01+that+water+reservoir+contains+water%0A++%7D%0A%0A%0A++thisReadingTime+%3D+millis%28%29%3B%0A++if+%28%28thisReadingTime+-+lastReadingTime%29+%3E%3D+SECOND%29+%7B%0A++++lastReadingTime+%3D+thisReadingTime%3B%0A++++moisture+%3D+getHygrometerReading%28%29%3B%0A++++if+%28moisture+%3E%3D+pumpOnThresh%29+%7B%0A++++++digitalWrite%28DRY_LED%2C+HIGH%29%3B++%2F%2F+turn+on+LED+indicator%0A++++++if+%28pumpIsOn%29+%7B%0A++++++++currentMillis+%3D+millis%28%29%3B%0A++++++++if+%28%28pumpOnMillis+%3D%3D+0%29+or+%28%28currentMillis+-+pumpOnMillis%29+%3E%3D+MAX_PUMP_ON_TIME%29+or+%28currentMillis+%3C+pumpOnMillis%29%29+%7B%0A++++++++++digitalWrite%28PUMP%2C+LOW%29%3B+%2F%2F+turn+pump+off%0A++++++++++pumpIsOn+%3D+false%3B%0A++++++++++lastIrrMillis+%3D+millis%28%29%3B%0A++++++++%7D%0A++++++%7D+else+%7B++%2F%2F+pump+is+off%0A++++++++currentMillis+%3D+millis%28%29%3B%0A++++++++if+%28%28lastIrrMillis+%3D%3D+0%29+or+%28currentMillis+-+lastIrrMillis+%3E%3D+MINIMUM_TIME%29%29+%7B%0A++++++++++if+%28waterLevel+%3D%3D+HIGH%29+%7B%0A++++++++++++digitalWrite%28PUMP%2C+HIGH%29%3B++%2F%2F+turn+on+pump%0A++++++++++++pumpIsOn+%3D+true%3B%0A++++++++++++pumpOnMillis+%3D+millis%28%29%3B%0A++++++++++%7D+else+%7B%0A++++++++++++%2F%2F+Serial.println%28%22but+no+water+in+reservoir%21%22%29%3B%0A++++++++++%7D%0A++++++++%7D+else+%7B%0A++++++++++%2F%2F+Serial.println%28%22but+not+enough+time+has+passed+since+last+irrigation.%22%29%3B%0A++++++++%7D%0A++++++%7D%0A++++%7D+else+if+%28moisture+%3C%3D+pumpOffThresh%29+%7B%0A++++++digitalWrite%28DRY_LED%2C+LOW%29%3B+%2F%2F+turn+off+LED+indicator%0A++++++if+%28pumpIsOn%29+%7B%0A++++++++digitalWrite%28PUMP%2C+LOW%29%3B+%2F%2F+turn+off+pump%0A++++++++pumpIsOn+%3D+false%3B%0A++++++++lastIrrMillis+%3D+millis%28%29%3B++%2F%2F+update+lastIrrMillis+in+preparation+for+MINIMUM_TIME+criteria+calculation%0A++++++%7D+else+%7B%0A++++++++%2F%2F+Serial.println%28%22The+soil+moisture+level+is+high+and+the+water+pump+is+already+off.%22%29%3B%0A++++++%7D%0A++++%7D+else+%7B%0A++++++%2F%2F+Serial.println%28%22The+soil+moisture+level+is+adequate+%3D%3E+no+action+needed.%22%29%3B%0A++++%7D%0A++%7D%0A++display.clearDisplay%28%29%3B%0A++display.setCursor%280%2C+0%29%3B%0A++display.print%28%22PumpOnTres%3A+%22%29%3B%0A++display.print%28pumpOnThresh%29%3B%0A++display.setCursor%280%2C+8%29%3B%0A++display.print%28%22Value%3A+%22%29%3B%0A++display.print%28moisture%29%3B%0A++if+%28pumpIsOn%29+%7B%0A++++display.print%28%22+%28ON%29%22%29%3B%0A++%7D+else+%7B%0A++++display.print%28%22+%28OFF%29%22%29%3B%0A++%7D%0A++display.setCursor%280%2C+16%29%3B%0A++display.print%28%22PumpOffTres%3A+%22%29%3B%0A++display.print%28pumpOffThresh%29%3B%0A++display.setCursor%280%2C+24%29%3B%0A++if+%28waterLevel+%3D%3D+LOW%29+%7B%0A++++display.print%28%22Bucket+is+empty.%22%29%3B%0A++%7D+else+%7B%0A++++display.print%28%22Bucket+has+water.%22%29%3B%0A++%7D%0A++display.display%28%29%3B%0A%7D%0A%0A%0Aint+readInput%28int+input%29+%7B%0A++int+millisStep+%3D+20%3B%0A++int+reading%3B%0A++for%28int+readings+%3D+3%3B+readings%3B+readings--%29+%7B%0A++++reading+%3D+debounce%28digitalRead%28input%29%29%3B%0A++++delay%28millisStep%29%3B%0A++%7D%0A++return+reading%3B%0A%7D%0A%0A%0Aint+debounce+%28int+SampleA%29+%7B%0A++static+int+SampleB+%3D+0%3B%0A++static+int+SampleC+%3D+0%3B%0A++static+int+LastDebounceResult+%3D+0%3B%0A++LastDebounceResult+%3D+LastDebounceResult+%26+%28SampleA+%7C+SampleB+%7C+SampleC%29+%7C+%28SampleA+%26+SampleB+%26+SampleC%29%3B%0A++SampleC+%3D+SampleB%3B%0A++SampleB+%3D+SampleA%3B%0A++return+LastDebounceResult%3B%0A%7D%0A%0A%0Avoid+chooseMenu%28%29+%7B%0A++char*+menu%5B%5D+%3D+%7B%22Change+PumpOnTres%22%2C+%22Change+PumpOffTres%22%7D%3B%0A++int+menuLen+%3D+2%3B%0A++bool+skipIt+%3D+true%3B%0A++int+pos+%3D+0%3B%0A%0A%0A++display.clearDisplay%28%29%3B%0A++display.setCursor%280%2C+0%29%3B%0A++display.print%28%22Choose+menu%3A%22%29%3B%0A++display.setCursor%280%2C+8%29%3B%0A++display.print%28menu%5Bpos%5D%29%3B%0A++display.setCursor%280%2C+16%29%3B%0A++display.print%28%22press+dial%22%29%3B%0A++display.setCursor%280%2C+24%29%3B%0A++display.print%28%22to+set.%22%29%3B%0A++display.display%28%29%3B%0A++delay%28200%29%3B%0A++%0A++%2F%2F+Reads+the+initial+state+of+the+ENCODER_SW%0A++encoderSwLastState+%3D+false%3B%0A++%2F%2Fdelay%2880%29%3B%0A++encoderSwState+%3D+digitalRead%28ENCODER_SW%29%3B%0A%0A%0A++while+%28%21%28%28encoderSwLastState+%3D%3D+encoderSwState%29+and+%28encoderSwState+%3D%3D+false%29%29%29+%7B%0A++++encoderSwLastState+%3D+encoderSwState%3B%0A++++encoderSwState+%3D+digitalRead%28ENCODER_SW%29%3B%0A++++%0A++++encoderClkState+%3D+digitalRead%28ENCODER_CLK%29%3B%0A++++if+%28encoderClkState+%21%3D+encoderClkLastState%29+%7B%0A++++++if+%28%21skipIt%29+%7B%0A++++++++if+%28digitalRead%28ENCODER_DT%29+%21%3D+encoderClkState%29+%7B%0A++++++++++pos%2B%2B%3B%0A++++++++++pos+%25%3D+menuLen%3B%0A++++++++%7D+else+%7B%0A++++++++++pos--%3B%0A++++++++++if+%28pos+%3C+0%29+%7B%0A++++++++++++pos+%3D+menuLen+-+1%3B%0A++++++++++%7D%0A++++++++%7D%0A++++++++display.clearDisplay%28%29%3B%0A++++++++display.setCursor%280%2C+0%29%3B%0A++++++++display.print%28%22Choose+menu%3A%22%29%3B%0A++++++++display.setCursor%280%2C+8%29%3B%0A++++++++display.print%28menu%5Bpos%5D%29%3B%0A++++++++display.setCursor%280%2C+16%29%3B%0A++++++++display.print%28%22press+dial%22%29%3B%0A++++++++display.setCursor%280%2C+24%29%3B%0A++++++++display.print%28%22to+set.%22%29%3B%0A++++++++display.display%28%29%3B%0A++++++%7D%0A++++++skipIt+%3D+%21skipIt%3B%0A++++%7D%0A++++encoderClkLastState+%3D+encoderClkState%3B%0A++%7D%0A++display.clearDisplay%28%29%3B%0A++display.setCursor%280%2C+0%29%3B%0A++display.print%28%22Choose+menu%3A%22%29%3B%0A++display.setCursor%280%2C+8%29%3B%0A++display.print%28menu%5Bpos%5D%29%3B%0A++display.setCursor%280%2C+16%29%3B%0A++display.print%28%22menu+chosen.%22%29%3B%0A++%2F%2F+display.setCursor%280%2C+24%29%3B%0A++%2F%2F+display.print%28onThresh%29%3B%0A++display.display%28%29%3B%0A++delay%281000%29%3B%0A++if+%28pos+%3D%3D+0%29+%7B%0A++++pumpOnThresh+%3D+getEncoderData%28%22PumpOnTres%22%2C+pumpOnThresh%29%3B%0A++%7D+else+if+%28pos+%3D%3D+1%29+%7B%0A++++pumpOffThresh+%3D+getEncoderData%28%22PumpOffTres%22%2C+pumpOffThresh%29%3B%0A++++%2F%2F+pumpOffThresh+%3D+setLowThresh%28%29%3B%0A++%7D%0A%7D%0A%0A%0Aint+getEncoderData%28char*+theParam%2C+int+startPos%29+%7B%0A++bool+skipIt+%3D+true%3B%0A++%2F%2F+int+onThresh+%3D+pumpOnThresh%3B%0A%0A%0A++display.clearDisplay%28%29%3B%0A++display.setCursor%280%2C+0%29%3B%0A++display.print%28%22Change+%22%29%3B%0A++display.print%28theParam%29%3B%0A++display.print%28%22%3A%22%29%3B%0A++display.setCursor%280%2C+8%29%3B%0A++display.print%28startPos%29%3B%0A++display.setCursor%280%2C+16%29%3B%0A++display.print%28%22press+dial%22%29%3B%0A++display.setCursor%280%2C+24%29%3B%0A++display.print%28%22to+set.%22%29%3B%0A++display.display%28%29%3B%0A++delay%28200%29%3B%0A++%0A++%2F%2F+Reads+the+initial+state+of+the+ENCODER_SW%0A++encoderSwLastState+%3D+false%3B%0A++encoderSwState+%3D+digitalRead%28ENCODER_SW%29%3B%0A%0A%0A++while+%28%21%28%28encoderSwLastState+%3D%3D+encoderSwState%29+and+%28encoderSwState+%3D%3D+false%29%29%29+%7B%0A++++encoderSwLastState+%3D+encoderSwState%3B%0A++++encoderSwState+%3D+digitalRead%28ENCODER_SW%29%3B%0A++++%0A++++encoderClkState+%3D+digitalRead%28ENCODER_CLK%29%3B%0A++++if+%28encoderClkState+%21%3D+encoderClkLastState%29+%7B%0A++++++if+%28%21skipIt%29+%7B%0A++++++++if+%28digitalRead%28ENCODER_DT%29+%21%3D+encoderClkState%29+%7B%0A++++++++++if+%28startPos+%3C+1023%29+%7B%0A++++++++++++startPos%2B%2B%3B%0A++++++++++%7D%0A++++++++%7D+else+%7B%0A++++++++++if+%28startPos+%3E+0%29+%7B%0A++++++++++++startPos--%3B%0A++++++++++%7D%0A++++++++%7D%0A++++++++display.clearDisplay%28%29%3B%0A++++++++display.setCursor%280%2C+0%29%3B%0A++++++++display.print%28%22Change+%22%29%3B%0A++++++++display.print%28theParam%29%3B%0A++++++++display.print%28%22%3A%22%29%3B%0A++++++++display.setCursor%280%2C+8%29%3B%0A++++++++display.print%28startPos%29%3B%0A++++++++display.setCursor%280%2C+16%29%3B%0A++++++++display.print%28%22press+dial%22%29%3B%0A++++++++display.setCursor%280%2C+24%29%3B%0A++++++++display.print%28%22to+set.%22%29%3B%0A++++++++display.display%28%29%3B%0A++++++%7D%0A++++++skipIt+%3D+%21skipIt%3B%0A++++%7D%0A++++encoderClkLastState+%3D+encoderClkState%3B%0A++%7D%0A++display.clearDisplay%28%29%3B%0A++display.setCursor%280%2C+0%29%3B%0A++display.print%28%22Change+%22%29%3B%0A++display.print%28theParam%29%3B%0A++display.print%28%22%3A%22%29%3B%0A++display.setCursor%280%2C+8%29%3B%0A++display.print%28startPos%29%3B%0A++display.setCursor%280%2C+16%29%3B%0A++display.print%28theParam%29%3B%0A++display.print%28%22+set+to%22%29%3B%0A++display.setCursor%280%2C+24%29%3B%0A++display.print%28startPos%29%3B%0A++display.display%28%29%3B%0A++delay%281000%29%3B%0A++return+startPos%3B%0A%7D%0A%0A%0Aint+getHygrometerReading%28%29+%7B%0A++%0A++hygroReadingTotal+-%3D+hygrometerReadings%5BhygroReadingPos%5D%3B%0A++hygrometerReadings%5BhygroReadingPos%2B%2B%5D+%3D+hygroReading+%3D+analogRead%28A0%29%3B%0A++if+%28hygroReadingPos+%3D%3D+HYGROMETER_READINGS_SIZE%29+%7B%0A++++hygroReadingPos+%3D+0%3B%0A++%7D%0A++hygroReadingTotal+%2B%3D+hygroReading%3B%0A++return+%28hygroReadingTotal+%2F+HYGROMETER_READINGS_SIZE%29%3B%0A%7D]&lt;/p&gt;&lt;div&gt;&lt;/div&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I only just compiled it and uploaded it to the Uno, but it appears to be functioning as expected and the soil humidity data appears much less erratic than previously.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;-raymond&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=4238&amp;AppID=193&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: (Semi)Automated Plant Irrigation System</title><link>https://community.element14.com/challenges-projects/project14/mixing-electronics-water/b/blog/posts/semi-automated-plant-irrigation-system</link><pubDate>Sun, 18 Feb 2018 13:30:21 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:0371e654-77cf-4f8a-aa66-5fe74a98db0a</guid><dc:creator>urkraft</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Here is a short video of the present irrigation system:&lt;/p&gt;&lt;p&gt;&lt;span id="3dbdcc25_c309_4019_b39f_3186bfbdb9ee"&gt;&lt;span&gt;[View:https://players.brightcove.net/1362235890001/NkxiVJdjx_default/index.html?videoId=5736028845001:740:466]&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;-raymond&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=4238&amp;AppID=193&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: (Semi)Automated Plant Irrigation System</title><link>https://community.element14.com/challenges-projects/project14/mixing-electronics-water/b/blog/posts/semi-automated-plant-irrigation-system</link><pubDate>Sat, 17 Feb 2018 22:13:29 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:0371e654-77cf-4f8a-aa66-5fe74a98db0a</guid><dc:creator>urkraft</dc:creator><slash:comments>0</slash:comments><description>Status 17feb2018:&lt;p&gt;&lt;br /&gt;rats nest view of the breadboard installation of the irrigation system at my olive plant&lt;span&gt;[View:/resized-image/__size/620x465/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-0371e654-77cf-4f8a-aa66-5fe74a98db0a/3513.contentimage_5F00_192843.jpg:620:465]&lt;/span&gt;&lt;/p&gt;Summary&lt;p&gt;Experienced a few problems that i had to fix, so it has taken longer than i planned to complete all the items on my to do list from yesterday. However, i believe that everything is now working as well as can be expected considering that the 3.3v pin from the Uno does not deliver enough current for the load that it is supplying in this project. Anyone attempting to duplicate this project should be aware of this and the fact that you will probably have to make several attempts at restarting the ESP-01 before it actually manages to connect to the WiFi. As i mentioned a few days ago, it would be much cheaper and simpler to implement this project using a Raspberry Pi Zero W (which i hope to have the opportunity to attempt sometime in the near future).&lt;/p&gt;How it Works&lt;p&gt;This is described in the comments at the beginning of the Uno sketch. Supplementary information concerning the ESP-01 is documented in the comments at the beginning of the ESP-01 sketch.&lt;/p&gt;Schematic Diagram&lt;p&gt;&lt;br /&gt;Schematic drawing of Arduiino Uno based irrigation system&lt;span&gt;[View:/resized-image/__size/620x267/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-0371e654-77cf-4f8a-aa66-5fe74a98db0a/8304.contentimage_5F00_192844.jpg:620:267]&lt;/span&gt;&lt;/p&gt;(theoretical) Breadboard Layout&lt;p&gt;&lt;span&gt;[View:/resized-image/__size/620x376/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-0371e654-77cf-4f8a-aa66-5fe74a98db0a/3404.contentimage_5F00_192845.jpg:620:376]&lt;/span&gt;&lt;/p&gt;ESP-01 Sketch&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:3ef06e6b-9b7d-4651-b12d-db8be7f5e991:type=c_cpp&amp;amp;text=%2F********************************************************************************************************%0A+*+Program+for+ESP-01+used+in+semi-automated+irrigation+system%0A+*+%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A+*+%0A+*+Summary%3A%0A+*+--------%0A+*+%0A+*++This+sketch+is+used+to+sends+emails+by+running+appropriate+PHP+scripts+%28the+URL+parameter+used%29+%0A+*++triggered+via+HTTP+GET+requests+to+a+HOST.%0A+*++%0A+*++One+script+is+triggered+by+the+setup%28%29+function+after+%0A+*++the+ESP-01+establishes+a+WiFi+connection+to+MY_SSID.+That+e-mail+informs+the+recipient+that+it+has%0A+*++successfully+established+the+WiFi+connection+and+that+the+default+threshold+values+are+being+used+%0A+*++by+the+Arduino+Uno+to+control+the+water+pump.%0A+*++%0A+*++The+other+script+is+triggered+by+a+LOW+signal+on+the+GPIO0+pin+%28which+is+configured+as+an+input%29.%0A+*++The+e-mail+that+this+script+sends+informs+the+recipient+that+the+water+reservoir+is+empty.+After%0A+*++triggering+the+script+the+sketch+waits+for+PAUSE_AFTER_RESERVOIS_EMPTY_EMAIL_SENT+before+continuing.%0A+*++%0A+*++The+sketch+uses+the+onboard+blue+LED+%28GPIO2%29+to+indicate+status+during+the+WiFi+connection+process.%0A+*++It+flashes+the+LED+until+a+connection+is+made.+If+no+connection+is+made+after+MAX_CONNECT_ATTEMPTS%0A+*++it+turns+the+LED+on+for+10+seconds+before+exiting+the+script.%0A+*%2F%0A%0A%0A%23include+%0A%0A%0Aconst+char*+MY_SSID+%3D+%22********%22%3B+%2F%2F+replace+with+the+SSID+you+would+like+to+connect+to%0Aconst+char*+PASSWORD+%3D+%22********%22%3B+%2F%2F+replace+with+the+SSID+password%0A%0A%0AIPAddress+staticIP%28192%2C+168%2C+1%2C+46%29%3B+%2F%2F+replace+with+static+IP+address+to+use+for+ESP-01+device%0AIPAddress+gateway%28192%2C+168%2C+1%2C+1%29%3B+%2F%2F+replace+with+gateway+IP+address+for+the+SSID%0AIPAddress+subnet%28255%2C+255%2C+255%2C+0%29%3B%0A%0A%0Aconst+int+MAX_CONNECT_ATTEMPTS+%3D+5%3B+%2F%2F+maximum+attempts+to+make+to+connect+the+ESP-01+to+the+wifi+PA%0Aconst+int+MAX_WAIT_FOR_CONNECT_CYCLES+%3D+40%3B+%2F%2F+2+cycles+%3D+approx.+1+sec%0Aconst+unsigned+long+PAUSE_AFTER_RESERVOIS_EMPTY_EMAIL_SENT+%3D+1000UL+*+60UL+*+60UL+*+24UL%3B+%2F%2F+one+day%0A%0A%0Aconst+String+HOST+%3D+%22192.168.1.45%22%3B++%2F%2F+replace+with+your+server+IP+address%0Aconst+int+HTTP_PORT+%3D+80%3B%0Aconst+String+FILL_RESERVOIR_URL+%3D+%22%2FfillReservoir.php%22%3B++%2F%2F+script+that+sends+me+email+warning+that+water+reservoir+is+empty%0Aconst+String+CONNECT_SUCCESS_URL+%3D+%22%2FconnectSuccess.php%22%3B+%2F%2F+script+that+sends+me+email+informing+of+successful+wifi+connect%0A%0A%0Aconst+int+RESERVOIR+%3D+0%3B++%2F%2F+IO+pin+to+use+as+input+for+signalling+that+the+the+water+reservori+is+empty+%28LOW+%3D%3E+empty%29%0Aconst+int+BLUE_LED+%3D+2%3B+++%2F%2F+IO+pin+to+use+for+blinking+the+blue+onboard+LED+to+signal+status+%28HIGH+%3D%3E+off%29%0A%0A%0Aint+reservoirLevel+%3D+HIGH%3B++%2F%2F+used+to+store+water+reservoir+status+%28LOW+%3D%3E+empty%29%0Aint+ledStatus+%3D+HIGH%3B+%2F%2F+used+to+store+onboard+blue+LED+status+%28HIGH+%3D%3E+off%29%0Abool+wifiIsConnected+%3D+false%3B+%2F%2F+used+to+store+wifi+connection+status+%28false+%3D%3E+not+connected%29%0A%0A%0Avoid+setup%28%29+%7B%0A++delay%2810000%29%3B+++%2F%2F+long+delay+here+to+make+sure+signals+have+stabilized+before+continuing%0A++Serial.begin%28115200%29%3B++%0A++Serial.println%28%29%3B%0A++delay%28100%29%3B++%0A%0A%0A++pinMode%28BLUE_LED%2C+OUTPUT%29%3B%0A++digitalWrite%28BLUE_LED%2C+ledStatus%29%3B%0A++%0A++WiFi.mode%28WIFI_STA%29%3B++%2F%2F+configure+ESP-01+to+operate+as+a+wifi+station%0A++wifiConnect%28%29%3B%0A++for+%28int+i+%3D+MAX_CONNECT_ATTEMPTS%3B+i+%3E+0%3B+i--%29+%7B%0A++++if+%28wifiIsConnected+%3D+wifiConnect%28%29%29+%7B++%2F%2F+connected%21+%3D%3E+no+need+to+continue+trying+to+connect%0A++++++break%3B%0A++++%7D%0A++%7D%0A++if+%28%21wifiIsConnected%29+%7B%0A++++digitalWrite%28BLUE_LED%2C+LOW%29%3B%0A++++delay%2810000%29%3B%0A++++exit%281%29%3B%0A++%7D%0A++%0A++delay%28100%29%3B++%0A++sendMessage%28CONNECT_SUCCESS_URL%29%3B%0A++delay%28500%29%3B++%0A++pinMode%28RESERVOIR%2C+INPUT%29%3B%0A++delay%28100%29%3B%0A%7D++%0A++%0Avoid+loop%28%29+%7B%0A++if+%28LOW+%3D%3D+%28reservoirLevel+%3D+digitalRead%28RESERVOIR%29%29%29+%7B%0A++++sendMessage%28FILL_RESERVOIR_URL%29%3B%0A++++delay%28PAUSE_AFTER_RESERVOIS_EMPTY_EMAIL_SENT%29%3B%0A++%7D+else+%7B%0A++++delay%285000%29%3B%0A++%7D%0A%7D%0A%0A%0Avoid+sendMessage%28String+URL%29+%7B%0A++WiFiClient+client%3B++%0A++++%0A++if+%28%21client.connect%28HOST%2C+HTTP_PORT%29%29+%7B++%0A++++%2F%2FSerial.println%28%22connection+failed%22%29%3B++%0A++++return%3B++%0A++%7D++%0A++++%0A++client.print%28String%28%22GET+%22%29+%2B+URL+%2B+%22+HTTP%2F1.1%5Cr%5Cn%22+%2B++%0A+++++++++++++++%22Host%3A+%22+%2B+HOST+%2B+%22%5Cr%5Cn%22+%2B+++%0A+++++++++++++++%22Connection%3A+close%5Cr%5Cn%5Cr%5Cn%22%29%3B++%0A++delay%28500%29%3B++%0A%7D%0A%0A%0Abool+wifiConnect%28%29+%7B%0A++bool+wifiConnected+%3D+false%3B%0A%0A%0A++WiFi.begin%28MY_SSID%2C+PASSWORD%2C+13%2C+ap_mac%2C+true%29%3B%0A++WiFi.config%28staticIP%2C+gateway%2C+subnet%29%3B%0A++for+%28int+i+%3D+MAX_WAIT_FOR_CONNECT_CYCLES%3B+i+%3E+0+%3B+i--%29+%7B+%2F%2F+wait+for+20+seconds+to+be+connected%0A++++Serial.print%28%22Connection+status%3A+%22%29%3B%0A++++Serial.println%28WiFi.status%28%29%29%3B%0A++++if+%28wifiConnected+%3D+%28WiFi.status%28%29+%3D%3D+3%29%29+%7B++%2F%2FWL_CONNECTED%29%29+%7B%0A++++++wifiConnected+%3D+true%3B%0A++++++break%3B%0A++++%7D%0A++++delay%28500%29%3B%0A++++if+%28ledStatus+%3D%3D+HIGH%29+%7B%0A++++++ledStatus+%3D+LOW%3B%0A++++%7D+else+%7B%0A++++++ledStatus+%3D+HIGH%3B+%0A++++%7D%0A++++digitalWrite%28BLUE_LED%2C+ledStatus%29%3B%0A++%7D%0A++ledStatus+%3D+HIGH%3B%0A++digitalWrite%28BLUE_LED%2C+ledStatus%29%3B%0A++WiFi.printDiag%28Serial%29%3B%0A++return+wifiConnected%3B%0A%7D]&lt;/p&gt;&lt;div&gt;&lt;/div&gt;Arduino Uno Sketch&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:3ef06e6b-9b7d-4651-b12d-db8be7f5e991:type=c_cpp&amp;amp;text=%2F**********************************************************************************************%0A*+Program+for+semi-automated+irrigation+using+Arduino+Uno%0A*+%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A*+%0A*+Summary%3A%0A*+--------%0A*+%0A*+The+main+components+of+the+system+are%3A%0A*+%0A*+-+An+Arduino+Uno+%28hereafter+referred+to+as+%E2%80%9CUno%E2%80%9D%29+which+controls+everything%0A*+-+A+9V+DC+1A+power+adapter+for+the+Uno%0A*+-+An+ESP-01+WiFi+module+which+is+used+to+facilitate+messaging%0A*+-+A+FC-28+soil+hygrometer+%28moisture+sensor%29+for+detecting+humidity+in+soil%0A*+-+A+water+level+switch+NC+mounted+on+a+float+for+detecting+when+the+water+reservoir+is+empty%0A*+-+A+Keyes+KY-040+rotary+encoder+is+used+to+adjust+threshold+values+used+by+the+sketch%0A*+-+A+0.96%22+128+x+64+pixel+OLED+graphical+display+used+to+display+status+information%0A*+-+A+peristaltic+water+pump+to+pump+water+from+the+water+reservoir+to+the+soil%0A*+-+A+12V+DC+1A+power+adapter+for+the+water+pump%0A*+-+A+10+gallon+bucket+of+water+%28water+reservoir%29%0A*+-+A+potted+plant+to+water%0A*+%0A*+Operation%3A%0A*+%0A*+The+two+sensors+%28soil+hygrometer+and+water+level+switch%29+are+connected+to+inputs+of+the+Uno+%0A*+%28A0+and+D11+respectively%29+and+the+water+pump+is+controlled+by+an+output+signal+%28D10%29+from+%0A*+the+Uno.+Two+LED%E2%80%99s+are+controlled+by+output+signals+from+the+Uno+and+are+used+as+status+%0A*+indicators%3A%0A*+%0A*+-+Red++%3A+%28D13%29+Lit+to+indicate+that+the+soil+is+dry+enough+to+warrant+watering%0A*+-+Blue+%3A+%28D12%29+Lit+to+indicate+that+the+water+reservoir+is+empty+%28requires+a+refill+of+water%29%0A*+%0A*+A+0.96%22+128+x+64+piksel+OLED+graphical+display+is+also+used+to+display+status+information%0A*+and+to+adjust+threshold+levels+for+turning+the+water+pump+on+and+off.+It+uses+the+Uno%27s+I2C+%0A*+interface+%28A5%28SCL%29+and+A4%28SDA%29%29.%0A*+%0A*+A+Keyes+KY-040+rotary+encoder+is+used+together+with+the+OLED+display+to+adjust+the+threshold+%0A*+values+used+by+the+script.+It+uses+the+D2+through+D5+pins+as+input.+The+system+goes+into+%0A*+adjustment+modus+when+the+knob+is+depressed.+The+user+can+then+scroll+through+the+items+which%0A*+can+be+adjusted.+The+item+to+calibrate+is+choosen+by+depressing+the+switch+once+more+when+it+%0A*+displayed.+This+causes+the+system+to+display+the+current+value+being+used+for+that+item.+The%0A*+user+can+then+increase+the+value+by+turning+the+knob+clockwise+%28whereupon+the+displayed+value+%0A*+increases%29+or+counter+clockwise+%28whereupon+the+displayed+value+decreases%29.+To+choose+the+%0A*+displayed+value+the+user+must+depress+the+knob+-+whereupon+the+system+also+exits+adjustment+%0A*+mode+and+commenses+to+use+the+new+values.%0A*+%0A*+There+are+three+criteria+which+all+have+to+be+met+in+order+to+turn+on+the+pump+%28and+water+%0A*+the+plant%29%3A%0A*+%0A*+1%29++There+must+be+water+in+the+reservoir%0A*+2%29++The+soil+moisture+reading+in+the+soil+must+be+greater+than+a+specified+high+threshold+%0A*+++++value+%28indicating+the+soil+is+too+dry%29%0A*+3%29++A+specified+minimum+amount+of+time+must+have+elapsed+since+the+pump+was+last+turned+off+%0A*+++++while+watering+%28but+not+if+this+was+due+to+entering+adjustment+modus%29.%0A*+++++%0A*+Any+one+of+the+following+criteria+will+cause+the+pump+to+be+turned+off%3A%0A*+%0A*+-+No+water+left+in+the+water+reservoir%0A*+-+The+moisture+reading+of+the+soil+is+lower+than+a+specified+low+threshold+value+%0A*+++%28indicating+the+soil+has+been+irrigated+sufficiently.+This+criteria+also+triggers+the+%0A*+++timer+which+keeps+track+of+the+amount+of+time+that+has+elapsed+since+the+pump+was+turned+%0A*+++off%29.%0A*+-+the+pump+has+been+on+continually+for+at+least+MAX_PUMP_ON_TIME+milliseconds.%0A*+-+%28only+temporarily%29+entering+adjustment+modus%0A*+++%0A*+Basically%2C+the+Uno+just+goes+in+a+loop+checking+the+criteria+above+and+taking+action+%0A*+when+necessary.+Each+loop+iteration+takes+approximately+20-30+seconds+to+complete.+If%2C%0A*+however+the+knob+of+the+rotary+encoder+is+depressed+and+this+is+detected%2C+the+function%0A*+for+adjustment+modus+is+called+and+normal+operation+is+not+resumed+until+after+returning%0A*+from+the+function.+Before+the+adjustment+function+is+called+the+water+pump+and+on+time+%0A*+timer+are+both+stopped+if+the+pump+is+on.+Both+are+then+resumed+upon+returning+from+the%0A*+adjustment+function.%0A*+%0A*+Notes%3A%0A*+%0A*+GPIO+ESP_WATER_EMPTY+is+used+to+signal+to+the+ESP-01+that+the+water+reservoir+is+empty+%0A*+%28via+the+GP0+pin+of+the+ESP-01%29.+The+ESP-01+is+configured+to+use+its+GPIO0+as+an+input.+A+LOW+%0A*+signal+on+this+pin+will+trigger+the+sendMessage%28FILL_RESERVOIR_URL%29+function+on+the+ESP-01.+%0A*+This+function+invokes+a+PHP+script+on+my+Raspberry+Pi+server+via+a+HTTP+GET+request.+The%0A*+paramater+it+uses+indicates+which+script+to+invoke.+This+one+%28FILL_RESERVOIR_URL%29+results%0A*+in+an+e-mail+being+sent+to+me+informing+me+that+the+water+reservoir+is+empty.+The+ESP-01%0A*+also+calls+this+function+with+CONNECT_SUCCESS_URL+as+the+parameter+from+its+setup%28%29+function.+%0A*+The+resulting+e-mail+informs+me+that+the+the+ESP-01+has+successfully+connected+to+the+WiFi+%0A*+and+it+also+reminds+me+that+any+custom+thresholds+need+to+be+re-entered+%28since+this+e-mail%0A*+will+only+be+sent+whenever+the+ESP-01+restarts+%3D%3E+the+Uno+has+also+been+restarted.%0A*+%0A*+Future+features+to+impliment%3A%0A*+%0A*+-+replace+Uno+with+custom+design+%28with+ability+to+reprogram+by+attaching+adequate%0A*+++IO+interface%29%0A*%2F%0A%23include+%0A%23include+%0A%23include+%3Cadafruit_gfx.h%3E%0A%23include+%3Cadafruit_ssd1306.h%3E%0A%0A%0A%23define+OLED_RESET+4%0AAdafruit_SSD1306+display%28OLED_RESET%29%3B%0A%0A%0A%23define+NUMFLAKES+10%0A%23define+XPOS+0%0A%23define+YPOS+1%0A%23define+DELTAY+2%0A%0A%0A%0A%0A%23define+LOGO16_GLCD_HEIGHT+16+%0A%23define+LOGO16_GLCD_WIDTH++16+%0A%23if+%28SSD1306_LCDHEIGHT+%21%3D+32%29%0A%23error%28%22Height+incorrect%2C+please+fix+Adafruit_SSD1306.h%21%22%29%3B%0A%23endif%0A%0A%0A%2F%2F%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A%2F%2F+encoder+stuff%0A%2F%2F%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A%23define+ENCODER_CLK+2%0A%23define+ENCODER_DT+3%0A%23define+ENCODER_SW+4%0A+%0Aint+encoderCounter+%3D+0%3B+%0Aint+encoderClkState%3B%0Aint+encoderClkLastState%3B++%0Aint+encoderSwLastState%3B%0Aint+encoderSwState%3B%0Aint+encoderPosition+%3D+0%3B%0A%0A%0A%2F%2F+I%2FO%0Aconst+int+DRY_LED+%3D+13%3B++%2F%2F+%28Output%29+used+to+indicate+what+pump+status+should+be+ON+%28set+HIGH%29+when+the+pump+should+be+on%0Aconst+int+PUMP+%3D+10%3B+%2F%2F+%28Output%29+used+to+turn+the+pump+on+%28set+HIGH%29+and+off+%28set+LOW%29%0Aconst+int+WATER_EMPTY_LED+%3D+12%3B++%2F%2F+%28Output%29+used+to+indicate+if+the+reservoir+is+empty+%28set+HIGH+%3D%3E+ON%29%0Aconst+int+WATER_LEVEL+%3D+11%3B++%2F%2F+%28Input%29+used+to+detect+if+there+is+water+in+the+reservoir+%28HIGH%29+or+if+it+is+empty+%28LOW%29%0Aconst+int+ESP_WATER_EMPTY+%3D+9%3B++%2F%2F+%28Output%29+used+to+signal+the+ESP-01+that+the+water+reservoir+is+empty+%28set+LOW+%3D%3E+empty%29%0A%0A%0A%2F%2F+A0+%3A+ADC+%28Analog+Input%29+used+to+read+soil+humidity%3A+high+value+%3D%3E+dry%2C+low+value+%3D%3E+wet+%0A%2F%2F+Max+value+is+approx.+1018+-+bone+dry%0A%2F%2F+Min+value+is+approx.+530+-+drowning+in+water%0Aconst+unsigned+long+MINIMUM_TIME+%3D+1000UL+*+60UL+*+60UL+*+24UL%3B+%2F%2F+minimum+time+that+must+transpire+between+irrigation+%281+day%29%0A%2F%2Fconst+unsigned+long+MINIMUM_TIME+%3D+60UL+*+1000UL%3B+%2F%2F+minimum+time+that+must+transpire+between+irrigation+%28only+for+testing%29%0Aconst+unsigned+long+MAX_PUMP_ON_TIME+%3D+1000UL+*+60UL+*+15UL%3B+%2F%2F+maximum+time+pump+can+be+turned+on+for+%2815+minutes%29%0A%2F%2Fconst+unsigned+long+MAX_PUMP_ON_TIME+%3D+60UL+*+1000UL%3B+%2F%2F+maximum+time+pump+can+be+turned+on+for+%28only+for+testing%29%0A%0A%0A%2F%2F%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A%2F%2F+VARIABLES%0A%2F%2F%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A%0A%0A%2F%2F+timing%0Aunsigned+long+lastIrrMillis+%3D+0UL%3B%0Aunsigned+long+currentMillis+%3D+0UL%3B%0Aunsigned+long+pumpOnMillis+%3D+0UL%3B%0A%0A%0A%2F%2F+soil+moisture+reading%0Aint+pumpOnThresh+%3D+200%3B++%2F%2F+Turn+on+the+pump+when+ADC+input+value+%3E%3D+this+value%0Aint+pumpOffThresh+%3D+190%3B+%2F%2F+Turn+off+the+pump+when+ADC+input+value+%3C%3D+this+value+%28and+do+not+trun+on+again+for+at+least+a+day%29%0Abool+pumpIsOn+%3D+false%3B%0Aint+moisture+%3D+800%3B+%2F%2F+previous%0Aint+waterLevel%3B%0A%0A%0A%2F%2Fint+tmpMoisture+%3D+0%3B++%2F%2F++new+%28temporary%29%0A%0A%0Aint+displayLine+%3D+0%3B%0Aconst+int+DISPLAY_LINE_INCREASE+%3D+8%3B%0Aconst+int+DISPLAY_LINE_MAX+%3D+32%3B%0A%0A%0A%2F%2F%3D%3D%3D%3D%3D%3D%0A%2F%2F+SETUP%0A%2F%2F%3D%3D%3D%3D%3D%3D%0A%0A%0Avoid+setup%28%29+%7B%0A++%2F%2F+initialize+Serial%0A++Serial.begin%289600%29%3B%0A++delay%28100%29%3B%0A%0A%0A++Serial.println%28%22Soil+moisture+sensor%22%29%3B%0A%0A%0A++%2F%2F+initialize+IO%0A++pinMode%28WATER_LEVEL%2C+INPUT_PULLUP%29%3B%0A++%0A++pinMode%28PUMP%2C+OUTPUT%29%3B%0A++digitalWrite%28PUMP%2C+LOW%29%3B%0A++pumpIsOn+%3D+false%3B%0A++%0A++pinMode%28DRY_LED%2C+OUTPUT%29%3B%0A++digitalWrite%28DRY_LED%2C+LOW%29%3B%0A++%0A++pinMode%28WATER_EMPTY_LED%2C+OUTPUT%29%3B%0A++digitalWrite%28WATER_EMPTY_LED%2C+LOW%29%3B%0A%0A%0A++pinMode%28ENCODER_CLK%2C+INPUT%29%3B%0A++pinMode%28ENCODER_DT%2C+INPUT%29%3B%0A++pinMode%28ENCODER_SW%2C+INPUT%29%3B%0A++%0A++%2F%2F+by+default%2C+we%27ll+generate+the+high+voltage+from+the+3.3v+line+internally%21+%28neat%21%29%0A++display.begin%28SSD1306_SWITCHCAPVCC%2C+0x3C%29%3B++%2F%2F+initialize+with+the+I2C+addr+0x3C+%28for+the+128x32%29%0A++%2F%2F+init+done%0A++%0A++display.setTextSize%281%29%3B%0A++display.setTextColor%28WHITE%29%3B%0A%0A%0A++pinMode%28ESP_WATER_EMPTY%2C+OUTPUT%29%3B%0A++digitalWrite%28ESP_WATER_EMPTY%2C+HIGH%29%3B%0A%7D%0A%0A%0Avoid+loop%28%29+%7B%0A++%2F%2F+rotary+encoder+stuff%0A++encoderSwState+%3D+digitalRead%28ENCODER_SW%29%3B%0A++if+%28%28encoderSwLastState+%3D%3D+encoderSwState%29+and+%28encoderSwState+%3D%3D+false%29%29+%7B%0A++++unsigned+long+deltaTime%3B%0A++++if+%28pumpIsOn%29+%7B%0A++++++deltaTime+%3D+millis%28%29+-+pumpOnMillis%3B%0A++++++digitalWrite%28PUMP%2C+LOW%29%3B%0A++++%7D%0A++++chooseMenu%28%29%3B%0A++++if+%28pumpIsOn%29+%7B%0A++++++pumpOnMillis+%3D+millis%28%29+-+deltaTime%3B%0A++++++digitalWrite%28PUMP%2C+HIGH%29%3B%0A++++%7D%0A++++delay%281000%29%3B%0A++%7D%0A%0A%0A++%2F%2Firrigation+stuff%0A++waterLevel+%3D+readInput%28WATER_LEVEL%29%3B++%2F%2F+read+water+level%0A++if+%28waterLevel+%3D%3D+LOW%29+%7B++%2F%2F+water+reservoir+is+empty%0A++++digitalWrite%28PUMP%2C+LOW%29%3B+%2F%2F+turn+off+pump%0A++++pumpIsOn+%3D+false%3B%0A++++digitalWrite%28WATER_EMPTY_LED%2C+HIGH%29%3B+%2F%2F+turn+on+LED+indicator%0A++++digitalWrite%28ESP_WATER_EMPTY%2C+LOW%29%3B++%2F%2F+signal+ESP-01+to+send+e-mail+informing+water+reservoir+is+empty%0A++++%2F%2F+Serial.println%28%22The+water+reservoir+is+empty+%3D%3E+fill+it+up%21%22%29%3B%0A++%7D+else+%7B%0A++++digitalWrite%28WATER_EMPTY_LED%2C+LOW%29%3B+%2F%2F+turn+off+LED+indicator%0A++++digitalWrite%28ESP_WATER_EMPTY%2C+HIGH%29%3B++%2F%2F+signal+ESP-01+that+water+reservoir+contains+water%0A++%7D%0A++%0A++moisture+%3D+analogRead%28A0%29%3B%0A++if+%28moisture+%3E%3D+pumpOnThresh%29+%7B%0A++++digitalWrite%28DRY_LED%2C+HIGH%29%3B++%2F%2F+turn+on+LED+indicator%0A++++if+%28pumpIsOn%29+%7B%0A++++++currentMillis+%3D+millis%28%29%3B%0A++++++if+%28%28pumpOnMillis+%3D%3D+0%29+or+%28%28currentMillis+-+pumpOnMillis%29+%3E%3D+MAX_PUMP_ON_TIME%29+or+%28currentMillis+%3C+pumpOnMillis%29%29+%7B%0A++++++++digitalWrite%28PUMP%2C+LOW%29%3B+%2F%2F+turn+pump+off%0A++++++++pumpIsOn+%3D+false%3B%0A++++++++lastIrrMillis+%3D+millis%28%29%3B%0A++++++%7D%0A++++%7D+else+%7B++%2F%2F+pump+is+off%0A++++++currentMillis+%3D+millis%28%29%3B%0A++++++if+%28%28lastIrrMillis+%3D%3D+0%29+or+%28currentMillis+-+lastIrrMillis+%3E%3D+MINIMUM_TIME%29%29+%7B%0A++++++++if+%28waterLevel+%3D%3D+HIGH%29+%7B%0A++++++++++digitalWrite%28PUMP%2C+HIGH%29%3B++%2F%2F+turn+on+pump%0A++++++++++pumpIsOn+%3D+true%3B%0A++++++++++pumpOnMillis+%3D+millis%28%29%3B%0A++++++++%7D+else+%7B%0A++++++++++%2F%2F+Serial.println%28%22but+no+water+in+reservoir%21%22%29%3B%0A++++++++%7D%0A++++++%7D+else+%7B%0A++++++++%2F%2F+Serial.println%28%22but+not+enough+time+has+passed+since+last+irrigation.%22%29%3B%0A++++++%7D%0A++++%7D%0A++%7D+else+if+%28moisture+%3C%3D+pumpOffThresh%29+%7B%0A++++digitalWrite%28DRY_LED%2C+LOW%29%3B+%2F%2F+turn+off+LED+indicator%0A++++if+%28pumpIsOn%29+%7B%0A++++++digitalWrite%28PUMP%2C+LOW%29%3B+%2F%2F+turn+off+pump%0A++++++pumpIsOn+%3D+false%3B%0A++++++lastIrrMillis+%3D+millis%28%29%3B++%2F%2F+update+lastIrrMillis+in+preparation+for+MINIMUM_TIME+criteria+calculation%0A++++%7D+else+%7B%0A++++++%2F%2F+Serial.println%28%22The+soil+moisture+level+is+high+and+the+water+pump+is+already+off.%22%29%3B%0A++++%7D%0A++%7D+else+%7B%0A++++%2F%2F+Serial.println%28%22The+soil+moisture+level+is+adequate+%3D%3E+no+action+needed.%22%29%3B%0A++%7D%0A++display.clearDisplay%28%29%3B%0A++display.setCursor%280%2C+0%29%3B%0A++display.print%28%22PumpOnTres%3A+%22%29%3B%0A++display.print%28pumpOnThresh%29%3B%0A++display.setCursor%280%2C+8%29%3B%0A++display.print%28%22Value%3A+%22%29%3B%0A++display.print%28moisture%29%3B%0A++if+%28pumpIsOn%29+%7B%0A++++display.print%28%22+%28ON%29%22%29%3B%0A++%7D+else+%7B%0A++++display.print%28%22+%28OFF%29%22%29%3B%0A++%7D%0A++display.setCursor%280%2C+16%29%3B%0A++display.print%28%22PumpOffTres%3A+%22%29%3B%0A++display.print%28pumpOffThresh%29%3B%0A++display.setCursor%280%2C+24%29%3B%0A++if+%28waterLevel+%3D%3D+LOW%29+%7B%0A++++display.print%28%22Bucket+is+empty.%22%29%3B%0A++%7D+else+%7B%0A++++display.print%28%22Bucket+has+water.%22%29%3B%0A++%7D%0A++display.display%28%29%3B%0A%7D%0A%0A%0Aint+readInput%28int+input%29+%7B%0A++int+millisStep+%3D+20%3B%0A++int+reading%3B%0A++for%28int+readings+%3D+3%3B+readings%3B+readings--%29+%7B%0A++++reading+%3D+debounce%28digitalRead%28input%29%29%3B%0A++++delay%28millisStep%29%3B%0A++%7D%0A++return+reading%3B%0A%7D%0A%0A%0Aint+debounce+%28int+SampleA%29+%7B%0A++static+int+SampleB+%3D+0%3B%0A++static+int+SampleC+%3D+0%3B%0A++static+int+LastDebounceResult+%3D+0%3B%0A++LastDebounceResult+%3D+LastDebounceResult+%26+%28SampleA+%7C+SampleB+%7C+SampleC%29+%7C+%28SampleA+%26+SampleB+%26+SampleC%29%3B%0A++SampleC+%3D+SampleB%3B%0A++SampleB+%3D+SampleA%3B%0A++return+LastDebounceResult%3B%0A%7D%0A%0A%0Avoid+chooseMenu%28%29+%7B%0A++char*+menu%5B%5D+%3D+%7B%22Change+PumpOnTres%22%2C+%22Change+PumpOffTres%22%7D%3B%0A++int+menuLen+%3D+2%3B%0A++bool+skipIt+%3D+true%3B%0A++int+pos+%3D+0%3B%0A%0A%0A++display.clearDisplay%28%29%3B%0A++display.setCursor%280%2C+0%29%3B%0A++display.print%28%22Choose+menu%3A%22%29%3B%0A++display.setCursor%280%2C+8%29%3B%0A++display.print%28menu%5Bpos%5D%29%3B%0A++display.setCursor%280%2C+16%29%3B%0A++display.print%28%22press+dial%22%29%3B%0A++display.setCursor%280%2C+24%29%3B%0A++display.print%28%22to+set.%22%29%3B%0A++display.display%28%29%3B%0A++delay%28200%29%3B%0A++%0A++%2F%2F+Reads+the+initial+state+of+the+ENCODER_SW%0A++encoderSwLastState+%3D+false%3B%0A++%2F%2Fdelay%2880%29%3B%0A++encoderSwState+%3D+digitalRead%28ENCODER_SW%29%3B%0A%0A%0A++while+%28%21%28%28encoderSwLastState+%3D%3D+encoderSwState%29+and+%28encoderSwState+%3D%3D+false%29%29%29+%7B%0A++++encoderSwLastState+%3D+encoderSwState%3B%0A++++encoderSwState+%3D+digitalRead%28ENCODER_SW%29%3B%0A++++%0A++++encoderClkState+%3D+digitalRead%28ENCODER_CLK%29%3B%0A++++if+%28encoderClkState+%21%3D+encoderClkLastState%29+%7B%0A++++++if+%28%21skipIt%29+%7B%0A++++++++if+%28digitalRead%28ENCODER_DT%29+%21%3D+encoderClkState%29+%7B%0A++++++++++pos%2B%2B%3B%0A++++++++++pos+%25%3D+menuLen%3B%0A++++++++%7D+else+%7B%0A++++++++++pos--%3B%0A++++++++++if+%28pos+%3C+0%29+%7B%0A++++++++++++pos+%3D+menuLen+-+1%3B%0A++++++++++%7D%0A++++++++%7D%0A++++++++display.clearDisplay%28%29%3B%0A++++++++display.setCursor%280%2C+0%29%3B%0A++++++++display.print%28%22Choose+menu%3A%22%29%3B%0A++++++++display.setCursor%280%2C+8%29%3B%0A++++++++display.print%28menu%5Bpos%5D%29%3B%0A++++++++display.setCursor%280%2C+16%29%3B%0A++++++++display.print%28%22press+dial%22%29%3B%0A++++++++display.setCursor%280%2C+24%29%3B%0A++++++++display.print%28%22to+set.%22%29%3B%0A++++++++display.display%28%29%3B%0A++++++%7D%0A++++++skipIt+%3D+%21skipIt%3B%0A++++%7D%0A++++encoderClkLastState+%3D+encoderClkState%3B%0A++%7D%0A++display.clearDisplay%28%29%3B%0A++display.setCursor%280%2C+0%29%3B%0A++display.print%28%22Choose+menu%3A%22%29%3B%0A++display.setCursor%280%2C+8%29%3B%0A++display.print%28menu%5Bpos%5D%29%3B%0A++display.setCursor%280%2C+16%29%3B%0A++display.print%28%22menu+chosen.%22%29%3B%0A++%2F%2F+display.setCursor%280%2C+24%29%3B%0A++%2F%2F+display.print%28onThresh%29%3B%0A++display.display%28%29%3B%0A++delay%281000%29%3B%0A++if+%28pos+%3D%3D+0%29+%7B%0A++++pumpOnThresh+%3D+getEncoderData%28%22PumpOnTres%22%2C+pumpOnThresh%29%3B%0A++%7D+else+if+%28pos+%3D%3D+1%29+%7B%0A++++pumpOffThresh+%3D+getEncoderData%28%22PumpOffTres%22%2C+pumpOffThresh%29%3B%0A++++%2F%2F+pumpOffThresh+%3D+setLowThresh%28%29%3B%0A++%7D%0A%7D%0A%0A%0Aint+getEncoderData%28char*+theParam%2C+int+startPos%29+%7B%0A++bool+skipIt+%3D+true%3B%0A++%2F%2F+int+onThresh+%3D+pumpOnThresh%3B%0A%0A%0A++display.clearDisplay%28%29%3B%0A++display.setCursor%280%2C+0%29%3B%0A++display.print%28%22Change+%22%29%3B%0A++display.print%28theParam%29%3B%0A++display.print%28%22%3A%22%29%3B%0A++display.setCursor%280%2C+8%29%3B%0A++display.print%28startPos%29%3B%0A++display.setCursor%280%2C+16%29%3B%0A++display.print%28%22press+dial%22%29%3B%0A++display.setCursor%280%2C+24%29%3B%0A++display.print%28%22to+set.%22%29%3B%0A++display.display%28%29%3B%0A++delay%28200%29%3B%0A++%0A++%2F%2F+Reads+the+initial+state+of+the+ENCODER_SW%0A++encoderSwLastState+%3D+false%3B%0A++encoderSwState+%3D+digitalRead%28ENCODER_SW%29%3B%0A%0A%0A++while+%28%21%28%28encoderSwLastState+%3D%3D+encoderSwState%29+and+%28encoderSwState+%3D%3D+false%29%29%29+%7B%0A++++encoderSwLastState+%3D+encoderSwState%3B%0A++++encoderSwState+%3D+digitalRead%28ENCODER_SW%29%3B%0A++++%0A++++encoderClkState+%3D+digitalRead%28ENCODER_CLK%29%3B%0A++++if+%28encoderClkState+%21%3D+encoderClkLastState%29+%7B%0A++++++if+%28%21skipIt%29+%7B%0A++++++++if+%28digitalRead%28ENCODER_DT%29+%21%3D+encoderClkState%29+%7B%0A++++++++++if+%28startPos+%3C+1023%29+%7B%0A++++++++++++startPos%2B%2B%3B%0A++++++++++%7D%0A++++++++%7D+else+%7B%0A++++++++++if+%28startPos+%3E+0%29+%7B%0A++++++++++++startPos--%3B%0A++++++++++%7D%0A++++++++%7D%0A++++++++display.clearDisplay%28%29%3B%0A++++++++display.setCursor%280%2C+0%29%3B%0A++++++++display.print%28%22Change+%22%29%3B%0A++++++++display.print%28theParam%29%3B%0A++++++++display.print%28%22%3A%22%29%3B%0A++++++++display.setCursor%280%2C+8%29%3B%0A++++++++display.print%28startPos%29%3B%0A++++++++display.setCursor%280%2C+16%29%3B%0A++++++++display.print%28%22press+dial%22%29%3B%0A++++++++display.setCursor%280%2C+24%29%3B%0A++++++++display.print%28%22to+set.%22%29%3B%0A++++++++display.display%28%29%3B%0A++++++%7D%0A++++++skipIt+%3D+%21skipIt%3B%0A++++%7D%0A++++encoderClkLastState+%3D+encoderClkState%3B%0A++%7D%0A++display.clearDisplay%28%29%3B%0A++display.setCursor%280%2C+0%29%3B%0A++display.print%28%22Change+%22%29%3B%0A++display.print%28theParam%29%3B%0A++display.print%28%22%3A%22%29%3B%0A++display.setCursor%280%2C+8%29%3B%0A++display.print%28startPos%29%3B%0A++display.setCursor%280%2C+16%29%3B%0A++display.print%28theParam%29%3B%0A++display.print%28%22+set+to%22%29%3B%0A++display.setCursor%280%2C+24%29%3B%0A++display.print%28startPos%29%3B%0A++display.display%28%29%3B%0A++delay%281000%29%3B%0A++return+startPos%3B%0A%7D]&lt;/p&gt;&lt;div&gt;&lt;/div&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;Arduino Uno IO Pin Use&lt;p&gt;D0: -&lt;/p&gt;&lt;p&gt;D1: -&lt;/p&gt;&lt;p&gt;D2:In ENCODER_CLK&lt;/p&gt;&lt;p&gt;D3:In ENCODER_DT&lt;/p&gt;&lt;p&gt;D4:In ENCODER_SW&lt;/p&gt;&lt;p&gt;D5: -&lt;/p&gt;&lt;p&gt;D6: -&lt;/p&gt;&lt;p&gt;D7: -&lt;/p&gt;&lt;p&gt;D8: -&lt;/p&gt;&lt;p&gt;D9:Out ESP_WATER_EMPTY LOW: Send e-mail informing that water reservoir is empty&lt;/p&gt;&lt;p&gt;D10:Out PUMP HIGH: ON - Turn water pump on&lt;/p&gt;&lt;p&gt;D11:In WATER_LEVEL HIGH: Water reservoir has water (this pin is also connected to GP0 of the ESP-01)&lt;/p&gt;&lt;p&gt;D12:Out WATER_EMPTY_LED HIGH: ON&amp;nbsp; - Signal water reservoir is empty (Blue LED)&lt;/p&gt;&lt;p&gt;D13:Out DRY_LED HIGH: Lit - Signal pump should be on (Red LED)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;A0:Analog In Soil hygrometer reading&lt;/p&gt;&lt;p&gt;A1: -&lt;/p&gt;&lt;p&gt;A2: -&lt;/p&gt;&lt;p&gt;A3: -&lt;/p&gt;&lt;p&gt;A4:SDA I2C (OLED display)&lt;/p&gt;&lt;p&gt;A5:SCL I2C (OLED display)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;Parts Required&lt;p&gt;Let me know if this is desired here.&lt;/p&gt;Preparing the ESP-01&lt;p&gt;This has been covered earlier in this blog, but let me know if this is desired here.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;Concluding Remarks&lt;p&gt;I do not know if i will go any further with this project for the Arduino Uno. In any case, i believe that it is best to wait a few weeks to see how well this system performs before taking it any further.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;It has been lots of fun for me playing around with this project and i hope that i will be able to keep on pretending to be a maker a lot more in the future.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;-raymond&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=4238&amp;AppID=193&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: (Semi)Automated Plant Irrigation System</title><link>https://community.element14.com/challenges-projects/project14/mixing-electronics-water/b/blog/posts/semi-automated-plant-irrigation-system</link><pubDate>Fri, 16 Feb 2018 21:18:50 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:0371e654-77cf-4f8a-aa66-5fe74a98db0a</guid><dc:creator>urkraft</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;&lt;strong&gt;Status:&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;I have just finished a new revision of my code in preparation for implement messaging using the ESP-01. The next steps are as follows:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Upload the new sketch for the ESP-01. (Status: Done)&lt;/li&gt;&lt;li&gt;Make a schematic of the changes that need to be made in order to integrate the ESP-01 into the existing design. (Done)&lt;/li&gt;&lt;li&gt;Power down the irrigation system presently being used to water my olive tree. (Done)&lt;/li&gt;&lt;li&gt;Connect the ESP-01 and necessary circuitry to the existing design (as per step 2). (Done)&lt;/li&gt;&lt;li&gt;Upload the new sketch for the Uno. (Done)&lt;/li&gt;&lt;li&gt;Test that everything appears to be functioning as it should. (Done)&lt;/li&gt;&lt;li&gt;Install the new system at the olive tree. (Done)&lt;/li&gt;&lt;li&gt;Test that everything appears to be functioning as it should. (Done)&lt;/li&gt;&lt;li&gt;Document my work. (Done)&lt;/li&gt;&lt;li&gt;Publish. (Done)&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;-raymond&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=4238&amp;AppID=193&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: (Semi)Automated Plant Irrigation System</title><link>https://community.element14.com/challenges-projects/project14/mixing-electronics-water/b/blog/posts/semi-automated-plant-irrigation-system</link><pubDate>Thu, 15 Feb 2018 23:13:21 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:0371e654-77cf-4f8a-aa66-5fe74a98db0a</guid><dc:creator>urkraft</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;&lt;strong&gt;Status update:&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;I have finally gotten my ESP-01 to connect to an access point (AP) - even one that is hidden! There were a LOT of things that need to be learned and corrected along the way for me, and i will try to document as much as i can here.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;It appears that uploading sketches to the device you loose the ability to communicate with it with AT commands. The first thing it appears that should be done with these devices is to make a connection to an AP and possibly update the firmware. I do not understand how this works, but i have read many places indications that this could be an issue.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Now for the things that i believe that i understand to some degree:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Here is what i would call a generic diagram for an ESP-01 flashing circuit:&lt;/p&gt;&lt;p&gt;&lt;span&gt;[View:/resized-image/__size/620x284/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-0371e654-77cf-4f8a-aa66-5fe74a98db0a/4834.contentimage_5F00_192835.jpg:620:284]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Notes about the flashing circuit:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;It is VERY important to use a 3.3V power supply capable of supplying enough current. I do not know how much current is recommended, but i have read a number of places that neither the 3.3V output from an Arduino nor the 3.3V output from the MB102 breadboard power supply module are reliable for this purpose - so be warned! (I used a lab bench power supply capable of delivering 3A - overkill, i am sure, but there were so many problems to be overcome that i wanted to be 100% sure that this was not the source of my problems).&lt;/li&gt;&lt;li&gt;I have also observed that a number of people have reported having problems using 10k resistors where indicated in the diagram. Their problems appeared to be resolved by using 3.3k resistors instead. (I did not have 3.3k resistors, so i used the 3.9k resistors that were available to me.)&lt;/li&gt;&lt;li&gt;I did not use capacitors C1 and C2.&lt;/li&gt;&lt;li&gt;The USB to TTL converter in the diagram is assumed to be using 3.3V levels on the ESP-01 side. I used an &lt;span&gt;Arduino USB 2 Serial which uses 5V levels with a 3.3V to 5V bi-directonal level shifter circuit as my USB to TTL Converter.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;I used the Arduino IDE to upload sketches&lt;/span&gt;&lt;/li&gt;&lt;li&gt;To upload sketches successfully i had to press and hold the Reset switch, then press and hold the Flash switch, then release the Reset switch, but keep holding the Flash switch depressed until the sketch was done uploading. If problems occurred it was usually sufficient to turn off power to the ESP-01, disconnect the USB cable from the pc, close the Arduino IDE (and Serial window), and reconnect and restart the IDE.&lt;/li&gt;&lt;li&gt;Here is a picture of the Arduino settings that i found to work for me:&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span&gt;[View:/resized-image/__size/428x576/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-0371e654-77cf-4f8a-aa66-5fe74a98db0a/5086.contentimage_5F00_192836.jpg:428:576]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NOTE:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;My ESP-01 has 1MB (black pcb, blue pcb usually =&amp;gt; 512KB)&lt;/li&gt;&lt;li&gt;&lt;span style="text-decoration:underline;"&gt;&lt;strong&gt;Crystal Frequency choice WILL affect which &amp;quot;baud&amp;quot; setting you will have to use in order to be able to read output to Serial - and will probably prevent the unit from finding and connecting to access points!!!!&lt;/strong&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span&gt;If you use an Arduino Uno you will have to connect the Rx from the ESP-01 to the Rx of the UNO (and Tx to Tx as well).&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span&gt;And here is the code i uploaded to the ESP-01 to test everything:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:3ef06e6b-9b7d-4651-b12d-db8be7f5e991:type=c_cpp&amp;amp;text=%23include+%0A%0A%0Aconst+char*+MY_SSID+%3D+%22*********%22%3B+%2F%2F+use+your+SSID+here%0Aconst+char*+PASSWORD+%3D+%22**********%22%3B+%2F%2F+use+your+password+here%0A%0A%0AIPAddress+staticIP%28192%2C+168%2C+1%2C+32%29%3B+%2F%2F+static+ip+address+for+the+ESP-01%0AIPAddress+gateway%28192%2C+168%2C+1%2C+1%29%3B%0AIPAddress+subnet%28255%2C+255%2C+255%2C+0%29%3B%0A%0A%0Aconst+String+HOST+%3D+%22192.168.1.30%22%3B+%2F%2F+static+ip+address+of+my+raspi+server%0Aconst+int+HTTP_PORT+%3D+80%3B%0Aconst+String+URL+%3D+%22%2FfillReservoir.php%22%3B+%2F%2F+my+script+to+send+email+informing+reservoir+empty%0A%0A%0Aconst+int+RESERVOIR+%3D+0%3B+%2F%2F+use+GP0+as+input+to+signal+ESP-01+reservoir+empty+%0Aconst+int+BLUE_LED+%3D+2%3B+%2F%2F+use+the+blue+LED+on+the+ESP-01+to+signal+status%0A%0A%0Aint+reservoirLevel%3B+%2F%2F+LOW+input+will+signal+that+the+reservoir+is+empty%0Aint+ledStatus+%3D+HIGH%3B+%2F%2F+to+turn+LED+off%0A%0A%0Avoid+setup%28%29+%7B++%0A++Serial.begin%28115200%29%3B++%0A++Serial.println%28%29%3B%0A++delay%28100%29%3B++%0A%0A%0A++pinMode%28BLUE_LED%2C+OUTPUT%29%3B%0A++digitalWrite%28BLUE_LED%2C+ledStatus%29%3B%0A++%0A++WiFi.mode%28WIFI_STA%29%3B%0A++bool+wifiIsConnected+%3D+false%3B%0A++wifiConnect%28%29%3B%0A++for+%28int+i+%3D+3%3B+i+%3E+0%3B+i--%29+%7B+%2F%2F+make+3+attempts+to+connect+to+the+AP%0A++++if+%28wifiIsConnected+%3D+wifiConnect%28%29%29+%7B%0A++++++break%3B%0A++++%7D%0A++%7D%0A++if+%28%21wifiIsConnected%29+%7B%0A++++digitalWrite%28BLUE_LED%2C+LOW%29%3B%0A++++delay%2810000%29%3B%0A++++exit%281%29%3B%0A++%7D%0A++%0A++delay%28100%29%3B++%0A++sendMessage%28%29%3B+%2F%2F+just+to+test+that+the+reservoir+empty+messaging+is+working%0A++delay%28500%29%3B++%0A++pinMode%28RESERVOIR%2C+INPUT%29%3B%0A++delay%28100%29%3B%0A%7D++%0A++%0Avoid+loop%28%29+%7B%0A++if+%28LOW+%3D%3D+%28reservoirLevel+%3D+digitalRead%28RESERVOIR%29%29%29+%7B%0A++++sendMessage%28%29%3B%0A++++delay%281000UL+*+60UL+*+24UL%29%3B+%2F%2F+wait+a+day+before+testing+reservoir+status+again%0A++%7D%0A++delay%285000%29%3B%0A%7D%0A%0A%0Avoid+sendMessage%28%29+%7B%0A++WiFiClient+client%3B++%0A++++%0A++if+%28%21client.connect%28HOST%2C+HTTP_PORT%29%29+%7B++%0A++++%2F%2FSerial.println%28%22connection+failed%22%29%3B++%0A++++return%3B++%0A++%7D++%0A++++%0A++client.print%28String%28%22GET+%22%29+%2B+URL+%2B+%22+HTTP%2F1.1%5Cr%5Cn%22+%2B++%0A+++++++++++++++%22Host%3A+%22+%2B+HOST+%2B+%22%5Cr%5Cn%22+%2B+++%0A+++++++++++++++%22Connection%3A+close%5Cr%5Cn%5Cr%5Cn%22%29%3B++%0A++delay%28500%29%3B++%0A%7D%0A%0A%0Abool+wifiConnect%28%29+%7B%0A++bool+wifiConnected+%3D+false%3B%0A%0A%0A++WiFi.begin%28MY_SSID%2C+PASSWORD%29%3B%0A++WiFi.config%28staticIP%2C+gateway%2C+subnet%29%3B%0A++for+%28int+i+%3D+40%3B+i+%3E+0+%3B+i--%29+%7B+%2F%2F+wait+for+20+seconds+to+be+connected%2C+blinking+every+second%0A++++Serial.print%28%22Connection+status%3A+%22%29%3B%0A++++Serial.println%28WiFi.status%28%29%29%3B%0A++++if+%28wifiConnected+%3D+%28WiFi.status%28%29+%3D%3D+3%29%29+%7B++%2F%2FWL_CONNECTED%29%29+%7B%0A++++++wifiConnected+%3D+true%3B%0A++++++break%3B%0A++++%7D%0A++++delay%28500%29%3B%0A++++if+%28ledStatus+%3D%3D+HIGH%29+%7B%0A++++++ledStatus+%3D+LOW%3B%0A++++%7D+else+%7B%0A++++++ledStatus+%3D+HIGH%3B+%0A++++%7D%0A++++digitalWrite%28BLUE_LED%2C+ledStatus%29%3B%0A++%7D%0A++ledStatus+%3D+HIGH%3B%0A++digitalWrite%28BLUE_LED%2C+ledStatus%29%3B%0A++WiFi.printDiag%28Serial%29%3B%0A++return+wifiConnected%3B%0A%7D]&lt;/p&gt;&lt;div&gt;&lt;/div&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Serial output:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span&gt;[View:/resized-image/__size/620x787/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-0371e654-77cf-4f8a-aa66-5fe74a98db0a/8228.contentimage_5F00_192837.jpg:620:787]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;E-mail received:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span&gt;[View:/resized-image/__size/620x114/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-0371e654-77cf-4f8a-aa66-5fe74a98db0a/7633.contentimage_5F00_192838.jpg:620:114]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;And this is how the breadboard looks:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span&gt;[View:/resized-image/__size/620x827/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-0371e654-77cf-4f8a-aa66-5fe74a98db0a/0020.contentimage_5F00_192839.jpg:620:827]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span&gt;-raymond&lt;/span&gt;&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=4238&amp;AppID=193&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: (Semi)Automated Plant Irrigation System</title><link>https://community.element14.com/challenges-projects/project14/mixing-electronics-water/b/blog/posts/semi-automated-plant-irrigation-system</link><pubDate>Wed, 14 Feb 2018 17:27:41 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:0371e654-77cf-4f8a-aa66-5fe74a98db0a</guid><dc:creator>urkraft</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Very strange, but i can get the Adafruit Feather HUZZAH ESP8266 to connect to my SSID (even though it is hidden), but no matter what i do i cannot get the ESP-01 to connect - not even to another WiFi that i have that broadcasts its SSID. I know that i have managed to upload the code successfully and that the code is actually running because i get the &amp;quot;uploading&amp;quot; message in the status area of the Arduino IDE as well as the dots indicating that uploading is in progress (and the blue light on the ESP-01 blinks while this is happening), followed by the &amp;quot;Done uploading&amp;quot; message without any error messages. My code also blinks the blue LED while it is in the loop where it trying to connect to the WiFi - and that is exactly where it is stuck. I have tried a variety of different code examples but have not been able to get anything to work so far. Anyone have any tips for me as to what is wrong? Here is the code i have made (but i have replaced all the sensitive stuff with &amp;#39;*&amp;#39;):&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:3ef06e6b-9b7d-4651-b12d-db8be7f5e991:type=c_cpp&amp;amp;text=%23include+%0A%0A%0Aconst+char*+MY_SSID+++++%3D+%22*********%22%3B%0Aconst+char*+PASSWORD+%3D+%22***********%22%3B%0A%0A%0Aconst+String+HOST+%3D+%22***.***.**.**%22%3B%0Aconst+int+HTTP_PORT+%3D+80%3B%0Aconst+String+URL+%3D+%22%2FfillReservoir.php%22%3B%0A%0A%0Aconst+int+RESERVOIR+%3D+0%3B%0Aconst+int+BLUE_LED+%3D+2%3B%0A%0A%0Aint+reservoirLevel+%3D+HIGH%3B%0Aint+ledStatus+%3D+HIGH%3B%0A%0A%0Avoid+setup%28%29+%7B++%0A++delay%28100%29%3B++%0A%0A%0A++pinMode%28BLUE_LED%2C+OUTPUT%29%3B%0A++digitalWrite%28BLUE_LED%2C+ledStatus%29%3B%0A%0A%0A++WiFi.mode%28WIFI_STA%29%3B%0A++WiFi.begin%28MY_SSID%2C+PASSWORD%29%3B++%0A++++%0A++while+%28WiFi.status%28%29+%21%3D+WL_CONNECTED%29+%7B++%0A++++delay%28500%29%3B%0A++++if+%28ledStatus+%3D%3D+HIGH%29+%7B%0A++++++ledStatus+%3D+LOW%3B%0A++++%7D+else+%7B%0A++++++ledStatus+%3D+HIGH%3B+%0A++++%7D%0A++++digitalWrite%28BLUE_LED%2C+ledStatus%29%3B%0A++%7D%0A++ledStatus+%3D+HIGH%3B%0A++digitalWrite%28BLUE_LED%2C+ledStatus%29%3B%0A++%0A++delay%28100%29%3B++%0A++%0A++sendMessage%28%29%3B%0A++delay%28500%29%3B++%0A++pinMode%28RESERVOIR%2C+INPUT%29%3B%0A++delay%28100%29%3B%0A%7D++%0A++%0Avoid+loop%28%29+%7B%0A++if+%28LOW+%3D%3D+%28reservoirLevel+%3D+digitalRead%28RESERVOIR%29%29%29+%7B%0A++++sendMessage%28%29%3B%0A++++delay%281000UL+*+60UL+*+24UL%29%3B%0A++%7D%0A%7D%0A%0A%0Avoid+sendMessage%28%29+%7B%0A++WiFiClient+client%3B++%0A++++%0A++if+%28%21client.connect%28HOST%2C+HTTP_PORT%29%29+%7B++%0A++++%2F%2FSerial.println%28%22connection+failed%22%29%3B++%0A++++return%3B++%0A++%7D++%0A++++%0A++%2F%2F+We+now+create+a+URI+for+the+request++%0A++++%0A++%2F%2FSerial.print%28%22Requesting+URL%3A+%22%29%3B++%0A++%2F%2FSerial.println%28URL%29%3B++%0A++++%0A++%2F%2F+This+will+send+the+request+to+the+server++%0A++client.print%28String%28%22GET+%22%29+%2B+URL+%2B+%22+HTTP%2F1.1%5Cr%5Cn%22+%2B++%0A+++++++++++++++%22Host%3A+%22+%2B+HOST+%2B+%22%5Cr%5Cn%22+%2B+++%0A+++++++++++++++%22Connection%3A+close%5Cr%5Cn%5Cr%5Cn%22%29%3B++%0A++delay%28500%29%3B++%0A++++%0A++%2F%2F+Read+all+the+lines+of+the+reply+from+server+and+print+them+to+Serial++%0A++%2F*while%28client.available%28%29%29%7B++%0A++++String+line+%3D+client.readStringUntil%28%27%5Cr%27%29%3B++%0A++%7D++*%2F%0A%7D]&lt;/p&gt;&lt;div&gt;&lt;/div&gt;&lt;p&gt;-raymond&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=4238&amp;AppID=193&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: (Semi)Automated Plant Irrigation System</title><link>https://community.element14.com/challenges-projects/project14/mixing-electronics-water/b/blog/posts/semi-automated-plant-irrigation-system</link><pubDate>Tue, 13 Feb 2018 16:55:03 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:0371e654-77cf-4f8a-aa66-5fe74a98db0a</guid><dc:creator>urkraft</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;I have to admit, a &lt;a class="jive-link-external-small" href="https://www.raspberrypi.org/blog/hacker-house-automated-gardener/" rel="nofollow ugc noopener" target="_blank"&gt;Raspberry Pi Zero W based solution&lt;/a&gt; would make for a much more cost effective solution and require less material and work to implement all the functionality that i would like. I should have realized that at a much earlier stage, but my original ambitions were quite different than they are now. But this project was absolutely not a waste of time for me since i have learned a lot along the way (as well as having a lot of fun with it &lt;span&gt;[View:/resized-image/__size/16x16/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-0371e654-77cf-4f8a-aa66-5fe74a98db0a/0677.contentimage_5F00_1.png:16:16]&lt;/span&gt; ).&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;-raymond&lt;/p&gt;&lt;p&gt;ludo ergo sum!&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=4238&amp;AppID=193&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: (Semi)Automated Plant Irrigation System</title><link>https://community.element14.com/challenges-projects/project14/mixing-electronics-water/b/blog/posts/semi-automated-plant-irrigation-system</link><pubDate>Sat, 10 Feb 2018 18:27:35 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:0371e654-77cf-4f8a-aa66-5fe74a98db0a</guid><dc:creator>urkraft</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;&lt;strong&gt;Status 10FEB2018;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Since i do not have any free Arduino Uno boards i had to make one in order to proceed. I had done this previously a long time ago and could not find my notes, but i had since purchased Mark Geddes&amp;#39;s book &amp;quot;Arduino Project Handbook&amp;quot; (ISBN: 978-1-59327-6904) which has building an Arduino as the last project. One of the main reason for me buying the book was his style of documenting his work which i really liked. However i discovered a few errors he made in this project:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;ol&gt;&lt;li&gt;The Reset circuit uses a pull down resistor at the Reset pin of the ATMega328p micro controller, but it should actually be a pull up resistor.&lt;/li&gt;&lt;li&gt;The resistor used in the previous point was only 220 ohm while the Arduino actually uses 10k ohm (which i believe is a much better choice).&lt;/li&gt;&lt;li&gt;He ties pin 21 (AREF) to Vcc, but the Arduino actually has it tied to GND via a 100nF capacitor (which is the recommended solution).&lt;/li&gt;&lt;li&gt;I noticed that the Arduino also has a 1M ohm resistor between pins 9 and 10 (the XTAL pins).&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I corrected all of the above in my layout and used a 5V 2A micro USB power supply instead of his 5V regulator the 2 capacitors he used. Additionally, i added a contact in order to plug in an Arduino USB 2 Serial unit so that i could upload sketches to the micro controller while it was still on the breadboard. The RX signal from this was connected via a 1k ohm resistor to the TxD (pin 3) of the micro controller, and the TX signal was also connected via a 1k ohm resistor to the RxD (pin 2) of the micro controller, and the GND pin was connected to the GND rail. I then tested it all by uploading the blink sketch. I had huge problems uploading the sketch until i found out that i had to hold the reset button in while the sketch was being compiled and release it when compilation was finished in order for it to be uploaded (it is a very long time since i used the Arduino USB 2 Serial unit and i had forgotten all that).&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Here is a picture of the breadboard at this stage:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span&gt;[View:/resized-image/__size/620x465/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-0371e654-77cf-4f8a-aa66-5fe74a98db0a/5861.contentimage_5F00_192834.jpg:620:465]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Ready now to proceed with the WiFi circuitry, i Googled &amp;quot;arduino uno with esp8266&amp;quot; and got a good result &lt;a class="jive-link-external-small" href="https://create.arduino.cc/projecthub/circuito-io-team/simple-arduino-uno-esp-8266-integration-dba10b" rel="nofollow ugc noopener" target="_blank"&gt;here&lt;/a&gt;. Alas, it appears that i need a logic level converter in order to proceed - and i do not have one. Even though these are fairly inexpensive i simply cannot afford any more expenditures at this point in time. The only thing holding me back from completing this project with the feather instead is that i really liked having the ability to adjust the parameters and display status on the little OLED display, but since i could not find any libraries for the OLED display that worked with the feather i am not motivated to pursue that thread any further. So, this all means that i will not be proceeding further with this project until next month (other than following up the testing of the Uno that is being used to irrigate my olive tree).&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;-raymond &lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=4238&amp;AppID=193&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: (Semi)Automated Plant Irrigation System</title><link>https://community.element14.com/challenges-projects/project14/mixing-electronics-water/b/blog/posts/semi-automated-plant-irrigation-system</link><pubDate>Fri, 09 Feb 2018 23:36:18 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:0371e654-77cf-4f8a-aa66-5fe74a98db0a</guid><dc:creator>urkraft</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;&lt;strong&gt;Status:&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Been experimenting with solutions for messaging today. Really tired and sleep deprived now, so i have wasted lots of time because of trivial stupid mistakes (typos). I have been playing around with the Adafruit Feather HUZZAH ESP8266 again, but this time without any extra circuitry and only WiFi code. My idea was to use it to send a message to one of my raspi&amp;#39;s and get it to send me an e-mail. I have a Python script on one of my raspi&amp;#39;s that i use to take a picture and send it to me as an emails attachment if movement is detected via a PIR that is connected to it. It works quite well, but i could not find a way to trigger a Python script remotely automatically. Nico recently suggested using a PHP script to get it done, but i had never configured the mail server on any of my raspi&amp;#39;s. After googling around a bit i found &lt;a class="jive-link-external-small" href="https://linode.com/docs/email/postfix/configure-postfix-to-send-mail-using-gmail-and-google-apps-on-debian-or-ubuntu/" rel="nofollow ugc noopener" target="_blank"&gt;this link&lt;/a&gt; about configuring postfix to send mail using gmail. I had to struggle to get it to work because of a couple of typos that i managed to make along the way, but i finally got it to work! This is the PHP script that i have on the raspi:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;(/var/www/irrigation.php)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;lt;?php&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //the formatting keeps either eliminating this line or the last line of the code - go figure!&lt;/p&gt;&lt;p&gt;[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:3ef06e6b-9b7d-4651-b12d-db8be7f5e991:type=php&amp;amp;text=+++++%24msg+%3D+%22The+water+reservoir+is+empty%22%22%3B%0A+++++%24to_email+%3D+%22myEmail%40myDomain.com%22%3B%0A+++++%24subject+%3D+%22Irrigation+System+Status%22%3B%0A+++++if+%28mail%28%24to_email%2C+%24subject%2C+%24msg%29%29+%7B%0A++++++++++echo+%22Done%21%22%3B%0A+++++%7D+else+%7B%0A++++++++++echo+%22Failed%21%22%3B%0A+++++%7D%0A%3F%3E]&lt;/p&gt;&lt;div&gt;&lt;/div&gt;&lt;p&gt;I tested it by just entering the url for the raspi in a browser followed by the file name like so:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;http://192.198.1.12/irrigation.php&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;and shortly after i received the e-mail.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Next, i just modified the some Adafruit test code for the feather:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:3ef06e6b-9b7d-4651-b12d-db8be7f5e991:type=c_cpp&amp;amp;text=%2F*%0A+*++Simple+HTTP+get+webclient+test%0A+*%2F%0A%0A%0A%23include+%0A%0A%0Aconst+char*+ssid+++++%3D+%22mySSID%22%3B%0Aconst+char*+password+%3D+%22myPassword%22%3B%0A%0A%0Aconst+char*+host+%3D+%22%22%3B%0A%0A%0Avoid+setup%28%29+%7B%0A++Serial.begin%28115200%29%3B%0A++delay%28100%29%3B%0A%0A%0A++%2F%2F+We+start+by+connecting+to+a+WiFi+network%0A%0A%0A++Serial.println%28%29%3B%0A++Serial.println%28%29%3B%0A++Serial.print%28%22Connecting+to+%22%29%3B%0A++Serial.println%28ssid%29%3B%0A++%0A++WiFi.begin%28ssid%2C+password%29%3B%0A++WiFi.config%28IPAddress%28192%2C+168%2C+1%2C+13%29%2C+IPAddress%28192%2C+168%2C+1%2C+1%29%2C+IPAddress%28192%2C+168%2C+1%2C+1%29%29%3B++%2F%2F+replace+with+yours%0A++%0A++while+%28WiFi.status%28%29+%21%3D+WL_CONNECTED%29+%7B%0A++++delay%28500%29%3B%0A++++Serial.print%28%22.%22%29%3B%0A++%7D%0A%0A%0A++Serial.println%28%22%22%29%3B%0A++Serial.println%28%22WiFi+connected%22%29%3B++%0A++Serial.println%28%22IP+address%3A+%22%29%3B%0A++Serial.println%28WiFi.localIP%28%29%29%3B%0A++%0A++delay%285000%29%3B%0A%0A%0A++Serial.print%28%22connecting+to+%22%29%3B%0A++Serial.println%28host%29%3B%0A++%0A++%2F%2F+Use+WiFiClient+class+to+create+TCP+connections%0A++WiFiClient+client%3B%0A++const+int+httpPort+%3D+80%3B%0A++if+%28%21client.connect%28host%2C+httpPort%29%29+%7B%0A++++Serial.println%28%22connection+failed%22%29%3B%0A++++return%3B%0A++%7D%0A++%0A++%2F%2F+We+now+create+a+URI+for+the+request%0A++String+url+%3D+%22%2Firrigation.php%22%3B%0A++Serial.print%28%22Requesting+URL%3A+%22%29%3B%0A++Serial.println%28url%29%3B%0A++%0A++%2F%2F+This+will+send+the+request+to+the+server%0A++client.print%28String%28%22GET+%22%29+%2B+url+%2B+%22+HTTP%2F1.1%5Cr%5Cn%22+%2B%0A+++++++++++++++%22Host%3A+%22+%2B+host+%2B+%22%5Cr%5Cn%22+%2B+%0A+++++++++++++++%22Connection%3A+close%5Cr%5Cn%5Cr%5Cn%22%29%3B%0A++delay%28500%29%3B%0A++%0A++%2F%2F+Read+all+the+lines+of+the+reply+from+server+and+print+them+to+Serial%0A++while%28client.available%28%29%29%7B%0A++++String+line+%3D+client.readStringUntil%28%27%5Cr%27%29%3B%0A++++Serial.print%28line%29%3B%0A++%7D%0A++%0A++Serial.println%28%29%3B%0A++Serial.println%28%22closing+connection%22%29%3B%0A++delay%2850000%29%3B%0A%7D%0A%0A%0A%0A%0Avoid+loop%28%29+%7B%0A%7D]&lt;/p&gt;&lt;div&gt;&lt;/div&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;The above code just does what i did manually to test the PHP script (after configuring the WiFi on the feather) - and it worked!&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I also made a trip into Oslo to buy a &lt;a class="jive-link-external-small" href="https://www.kjell.com/no/produkter/elektro-og-verktoy/arduino/moduler/wifi-modul-for-arduino-esp8266-p87947" rel="nofollow ugc noopener" target="_blank"&gt;ESP8266&lt;/a&gt;, so the next step is to try to get that working with an UNO.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;-raymond&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=4238&amp;AppID=193&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: (Semi)Automated Plant Irrigation System</title><link>https://community.element14.com/challenges-projects/project14/mixing-electronics-water/b/blog/posts/semi-automated-plant-irrigation-system</link><pubDate>Thu, 08 Feb 2018 21:29:21 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:0371e654-77cf-4f8a-aa66-5fe74a98db0a</guid><dc:creator>urkraft</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;&lt;strong&gt;Status update:&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Here is a picture of the latest breadboard configuration (although i would be amazed if it would be helpful to anyone as it looks like a rats nest). It is now connected to all the sensors and actuators and being used to keep my olive tree irrigated:&lt;/p&gt;&lt;p&gt;&lt;span&gt;[View:/resized-image/__size/620x465/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-0371e654-77cf-4f8a-aa66-5fe74a98db0a/8883.contentimage_5F00_192830.jpg:620:465]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Schematic Drawing:&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;[View:/resized-image/__size/620x334/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-0371e654-77cf-4f8a-aa66-5fe74a98db0a/6740.contentimage_5F00_192831.jpg:620:334]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;&lt;strong&gt;Breadboard Drawing:&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;&lt;strong&gt;&lt;span&gt;[View:/resized-image/__size/620x384/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-0371e654-77cf-4f8a-aa66-5fe74a98db0a/5344.contentimage_5F00_192832.jpg:620:384]&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;&lt;strong&gt;Code:&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:3ef06e6b-9b7d-4651-b12d-db8be7f5e991:type=c_cpp&amp;amp;text=%2F**********************************************************************************************%0A*+Program+for+semi-automated+irrigation+using+Arduino+Uno%0A*+%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A*%0A*+Summary%3A%0A*+--------%0A*%0A*+The+main+components+of+the+system+are%3A%0A*%0A*+-+A+soil+moisture+sensor%0A*+-+A+10+gallon+bucket+of+water+%28water+reservoir%29+with+a+water+level+sensor%0A*+-+An+Arduino+Uno+%28hereafter+referred+to+as+%E2%80%9Carduino%E2%80%9D%29%0A*+-+A+peristaltic+water+pump%0A*%0A*+The+two+sensors+are+connected+to+inputs+of+the+arduino%2C+and+the+water+pump+is+controlled+by%0A*+an+output+signal+from+the+arduino.+Two+LED%E2%80%99s+are+used+as+status+indicators%3A%0A*%0A*+-+Red++%3A+Lit+to+indicate+that+the+soil+is+dry+enough+to+warrant+watering%0A*+-+Blue+%3A+Lit+to+indicate+that+the+water+reservoir+is+empty+%28requires+a+refill+of+water%29%0A*%0A*+There+are+three+criteria+which+all+have+to+be+met+in+order+to+turn+on+the+pump+%28and+water%0A*+the+plant%29%3A%0A*%0A*+1%29++There+must+be+water+in+the+reservoir%0A*+2%29++The+soil+moisture+reading+in+the+soil+must+be+greater+than+a+specified+high+threshold%0A*+++++value+%28indicating+the+soil+is+too+dry%29%0A*+3%29++A+specified+minimum+amount+of+time+must+have+elapsed+since+the+pump+was+last+turned+off%0A*+++++while+watering.%0A*++++%0A*+Any+one+of+the+following+criteria+will+cause+the+pump+to+be+turned+off%3A%0A*%0A*+-+No+water+left+in+the+water+reservoir%0A*+-+The+moisture+reading+of+the+soil+is+lower+than+a+specified+low+threshold+value%0A*+++%28indicating+the+soil+has+been+irrigated+sufficiently.+This+criteria+also+triggers+the%0A*+++timer+which+keeps+track+of+the+amount+of+time+that+has+elapsed+since+the+pump+was+turned%0A*+++off%29.%0A*++%0A*+Basically%2C+the+arduino+just+goes+in+a+loop+checking+the+criteria+above+and+taking+action%0A*+when+necessary.+Each+loop+iteration+takes+approximately+20-30+seconds+to+complete.%0A*%0A*+Future+features+to+impliment%3A%0A*%0A*+-+display+for+status+and+as+part+of+interface+for+changing+threshold+values+%28status%3A+implemented%29%0A*+-+interface+for+changing+threshold+values+%28status%3A+implemented%29%0A*+-+ability+for+messaging+when+water+reservoir+is+empty+or+other+problems+occur%0A*+++%28like+when+the+system+is+restarted+to+indicate+that+the+custom+threshold+values%0A*+++need+to+be+reentered.%29%0A*+-+replace+arduino+with+custom+design+%28with+ability+to+reprogram+by+attaching+adequate%0A*+++IO+interface%29%0A*%2F%0A%23include+%0A%23include+%0A%23include+%0A%23include+%0A%0A%0A%23define+OLED_RESET+4%0AAdafruit_SSD1306+display%28OLED_RESET%29%3B%0A%0A%0A%23define+NUMFLAKES+10%0A%23define+XPOS+0%0A%23define+YPOS+1%0A%23define+DELTAY+2%0A%0A%0A%0A%0A%23define+LOGO16_GLCD_HEIGHT+16%0A%23define+LOGO16_GLCD_WIDTH++16%0A%23if+%28SSD1306_LCDHEIGHT+%21%3D+32%29%0A%23error%28%22Height+incorrect%2C+please+fix+Adafruit_SSD1306.h%21%22%29%3B%0A%23endif%0A%0A%0A%2F%2F%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A%2F%2F+encoder+stuff%0A%2F%2F%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A%23define+ENCODER_CLK+2%0A%23define+ENCODER_DT+3%0A%23define+ENCODER_SW+4%0A%0Aint+encoderCounter+%3D+0%3B%0Aint+encoderClkState%3B%0Aint+encoderClkLastState%3B+%0Aint+encoderSwLastState%3B%0Aint+encoderSwState%3B%0Aint+encoderPosition+%3D+0%3B%0A%0A%0A%2F%2F+I%2FO%0Aconst+int+DRY_LED+%3D+13%3B++%2F%2F+%28Output%29+used+to+indicate+what+pump+status+should+be+ON+%28set+HIGH%29+when+the+pump+should+be+on%0Aconst+int+PUMP+%3D+10%3B+%2F%2F+%28Output%29+used+to+turn+the+pump+on+%28set+HIGH%29+and+off+%28set+LOW%29%0Aconst+int+WATER_EMPTY_LED+%3D+12%3B++%2F%2F+%28Output%29+used+to+indicate+if+the+reservoir+is+empty+%28set+HIGH+%3D%3E+ON%29%0Aconst+int+WATER_LEVEL+%3D+11%3B++%2F%2F+%28Input%29+used+to+detect+if+there+is+water+in+the+reservoir+%28HIGH%29+or+if+it+is+empty+%28LOW%29%0A%0A%0A%2F%2F+A0+%3A+ADC+%28Analog+Input%29+used+to+read+soil+humidity%3A+high+value+%3D%3E+dry%2C+low+value+%3D%3E+wet%0A%2F%2F+Max+value+is+approx.+1018+-+bone+dry%0A%2F%2F+Min+value+is+approx.+530+-+drowning+in+water%0Aconst+unsigned+long+MINIMUM_TIME+%3D+1000UL+*+60UL+*+60UL+*+24UL%3B+%2F%2F+minimum+time+that+must+transpire+between+irrigation+%281+day%29%0A%2F%2Fconst+unsigned+long+MINIMUM_TIME+%3D+60UL+*+1000UL%3B+%2F%2F+minimum+time+that+must+transpire+between+irrigation+%28only+for+testing%29%0Aconst+unsigned+long+MAX_PUMP_ON_TIME+%3D+1000UL+*+60UL+*+15UL%3B+%2F%2F+maximum+time+pump+can+be+turned+on+for+%2815+minutes%29%0A%2F%2Fconst+unsigned+long+MAX_PUMP_ON_TIME+%3D+60UL+*+1000UL%3B+%2F%2F+maximum+time+pump+can+be+turned+on+for+%28only+for+testing%29%0A%0A%0A%2F%2F%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A%2F%2F+VARIABLES%0A%2F%2F%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A%0A%0A%2F%2F+timing%0Aunsigned+long+lastIrrMillis+%3D+0UL%3B%0Aunsigned+long+currentMillis+%3D+0UL%3B%0Aunsigned+long+pumpOnMillis+%3D+0UL%3B%0A%0A%0A%2F%2F+soil+moisture+reading%0Aint+pumpOnThresh+%3D+900%3B++%2F%2F+Turn+on+the+pump+when+ADC+input+value+%3E%3D+this+value%0Aint+pumpOffThresh+%3D+800%3B+%2F%2F+Turn+off+the+pump+when+ADC+input+value+%3C%3D+this+value+%28and+do+not+trun+on+again+for+at+least+a+day%29%0Abool+pumpIsOn+%3D+false%3B%0Aint+moisture+%3D+800%3B+%2F%2F+previous%0Aint+waterLevel%3B%0A%0A%0A%2F%2Fint+tmpMoisture+%3D+0%3B++%2F%2F++new+%28temporary%29%0A%0A%0Aint+displayLine+%3D+0%3B%0Aconst+int+DISPLAY_LINE_INCREASE+%3D+8%3B%0Aconst+int+DISPLAY_LINE_MAX+%3D+32%3B%0A%0A%0A%2F%2F%3D%3D%3D%3D%3D%3D%0A%2F%2F+SETUP%0A%2F%2F%3D%3D%3D%3D%3D%3D%0A%0A%0Avoid+setup%28%29+%7B%0A++%2F%2F+initialize+Serial%0A++Serial.begin%289600%29%3B%0A++delay%28100%29%3B%0A%0A%0A++Serial.println%28%22Soil+moisture+sensor%22%29%3B%0A%0A%0A++%2F%2F+initialize+IO%0A++pinMode%28WATER_LEVEL%2C+INPUT_PULLUP%29%3B%0A+%0A++pinMode%28PUMP%2C+OUTPUT%29%3B%0A++digitalWrite%28PUMP%2C+LOW%29%3B%0A++pumpIsOn+%3D+false%3B%0A+%0A++pinMode%28DRY_LED%2C+OUTPUT%29%3B%0A++digitalWrite%28DRY_LED%2C+LOW%29%3B%0A+%0A++pinMode%28WATER_EMPTY_LED%2C+OUTPUT%29%3B%0A++digitalWrite%28WATER_EMPTY_LED%2C+LOW%29%3B%0A%0A%0A++pinMode%28ENCODER_CLK%2C+INPUT%29%3B%0A++pinMode%28ENCODER_DT%2C+INPUT%29%3B%0A++pinMode%28ENCODER_SW%2C+INPUT%29%3B%0A+%0A++%2F%2F+by+default%2C+we%27ll+generate+the+high+voltage+from+the+3.3v+line+internally%21+%28neat%21%29%0A++display.begin%28SSD1306_SWITCHCAPVCC%2C+0x3C%29%3B++%2F%2F+initialize+with+the+I2C+addr+0x3C+%28for+the+128x32%29%0A++%2F%2F+init+done%0A+%0A++display.setTextSize%281%29%3B%0A++display.setTextColor%28WHITE%29%3B%0A%7D%0A%0A%0Avoid+loop%28%29+%7B%0A++%2F%2F+rotary+encoder+stuff%0A++encoderSwState+%3D+digitalRead%28ENCODER_SW%29%3B%0A++if+%28%28encoderSwLastState+%3D%3D+encoderSwState%29+and+%28encoderSwState+%3D%3D+false%29%29+%7B%0A++++chooseMenu%28%29%3B%0A++++delay%281000%29%3B%0A++%7D%0A%0A%0A++%2F%2Firrigation+stuff%0A++waterLevel+%3D+readInput%28WATER_LEVEL%29%3B++%2F%2F+read+water+level%0A++if+%28waterLevel+%3D%3D+LOW%29+%7B++%2F%2F+water+reservoir+is+empty%0A++++digitalWrite%28PUMP%2C+LOW%29%3B+%2F%2F+turn+off+pump%0A++++pumpIsOn+%3D+false%3B%0A++++digitalWrite%28WATER_EMPTY_LED%2C+HIGH%29%3B+%2F%2F+turn+on+LED+indicator%0A++++%2F%2F+Serial.println%28%22The+water+reservoir+is+empty+%3D%3E+fill+it+up%21%22%29%3B%0A++%7D+else+%7B%0A++++digitalWrite%28WATER_EMPTY_LED%2C+LOW%29%3B+%2F%2F+turn+off+LED+indicator%0A++%7D%0A+%0A++moisture+%3D+analogRead%28A0%29%3B%0A++if+%28moisture+%3E%3D+pumpOnThresh%29+%7B%0A++++digitalWrite%28DRY_LED%2C+HIGH%29%3B++%2F%2F+turn+on+LED+indicator%0A++++if+%28pumpIsOn%29+%7B%0A++++++currentMillis+%3D+millis%28%29%3B%0A++++++if+%28%28pumpOnMillis+%3D%3D+0%29+or+%28%28currentMillis+-+pumpOnMillis%29+%3E%3D+MAX_PUMP_ON_TIME%29+or+%28currentMillis+%3C+pumpOnMillis%29%29+%7B%0A++++++++digitalWrite%28PUMP%2C+LOW%29%3B+%2F%2F+turn+pump+off%0A++++++++pumpIsOn+%3D+false%3B%0A++++++++lastIrrMillis+%3D+millis%28%29%3B%0A++++++%7D%0A++++%7D+else+%7B++%2F%2F+pump+is+off%0A++++++currentMillis+%3D+millis%28%29%3B%0A++++++if+%28%28lastIrrMillis+%3D%3D+0%29+or+%28currentMillis+-+lastIrrMillis+%3E%3D+MINIMUM_TIME%29%29+%7B%0A++++++++if+%28waterLevel+%3D%3D+HIGH%29+%7B%0A++++++++++digitalWrite%28PUMP%2C+HIGH%29%3B++%2F%2F+turn+on+pump%0A++++++++++pumpIsOn+%3D+true%3B%0A++++++++++pumpOnMillis+%3D+millis%28%29%3B%0A++++++++%7D+else+%7B%0A++++++++++%2F%2F+Serial.println%28%22but+no+water+in+reservoir%21%22%29%3B%0A++++++++%7D%0A++++++%7D+else+%7B%0A++++++++%2F%2F+Serial.println%28%22but+not+enough+time+has+passed+since+last+irrigation.%22%29%3B%0A++++++%7D%0A++++%7D%0A++%7D+else+if+%28moisture+%3C%3D+pumpOffThresh%29+%7B%0A++++digitalWrite%28DRY_LED%2C+LOW%29%3B+%2F%2F+turn+off+LED+indicator%0A++++if+%28pumpIsOn%29+%7B%0A++++++digitalWrite%28PUMP%2C+LOW%29%3B+%2F%2F+turn+off+pump%0A++++++pumpIsOn+%3D+false%3B%0A++++++lastIrrMillis+%3D+millis%28%29%3B++%2F%2F+update+lastIrrMillis+in+preparation+for+MINIMUM_TIME+criteria+calculation%0A++++%7D+else+%7B%0A++++++%2F%2F+Serial.println%28%22The+soil+moisture+level+is+high+and+the+water+pump+is+already+off.%22%29%3B%0A++++%7D%0A++%7D+else+%7B%0A++++%2F%2F+Serial.println%28%22The+soil+moisture+level+is+adequate+%3D%3E+no+action+needed.%22%29%3B%0A++%7D%0A++display.clearDisplay%28%29%3B%0A++display.setCursor%280%2C+0%29%3B%0A++display.print%28%22PumpOnTres%3A+%22%29%3B%0A++display.print%28pumpOnThresh%29%3B%0A++display.setCursor%280%2C+8%29%3B%0A++display.print%28%22Value%3A+%22%29%3B%0A++display.print%28moisture%29%3B%0A++if+%28pumpIsOn%29+%7B%0A++++display.print%28%22+%28ON%29%22%29%3B%0A++%7D+else+%7B%0A++++display.print%28%22+%28OFF%29%22%29%3B%0A++%7D%0A++display.setCursor%280%2C+16%29%3B%0A++display.print%28%22PumpOffTres%3A+%22%29%3B%0A++display.print%28pumpOffThresh%29%3B%0A++display.setCursor%280%2C+24%29%3B%0A++if+%28waterLevel+%3D%3D+LOW%29+%7B%0A++++display.print%28%22Bucket+is+empty.%22%29%3B%0A++%7D+else+%7B%0A++++display.print%28%22Bucket+has+water.%22%29%3B%0A++%7D%0A++display.display%28%29%3B%0A%7D%0A%0A%0Aint+readInput%28int+input%29+%7B%0A++int+millisStep+%3D+20%3B%0A++int+reading%3B%0A++for%28int+readings+%3D+3%3B+readings%3B+readings--%29+%7B%0A++++reading+%3D+debounce%28digitalRead%28input%29%29%3B%0A++++delay%28millisStep%29%3B%0A++%7D%0A++return+reading%3B%0A%7D%0A%0A%0Aint+debounce+%28int+SampleA%29+%7B%0A++static+int+SampleB+%3D+0%3B%0A++static+int+SampleC+%3D+0%3B%0A++static+int+LastDebounceResult+%3D+0%3B%0A++LastDebounceResult+%3D+LastDebounceResult+%26+%28SampleA+%7C+SampleB+%7C+SampleC%29+%7C+%28SampleA+%26+SampleB+%26+SampleC%29%3B%0A++SampleC+%3D+SampleB%3B%0A++SampleB+%3D+SampleA%3B%0A++return+LastDebounceResult%3B%0A%7D%0A%0A%0Avoid+chooseMenu%28%29+%7B%0A++char*+menu%5B%5D+%3D+%7B%22Change+PumpOnTres%22%2C+%22Change+PumpOffTres%22%7D%3B%0A++int+menuLen+%3D+2%3B%0A++bool+skipIt+%3D+true%3B%0A++int+pos+%3D+0%3B%0A%0A%0A++display.clearDisplay%28%29%3B%0A++display.setCursor%280%2C+0%29%3B%0A++display.print%28%22Choose+menu%3A%22%29%3B%0A++display.setCursor%280%2C+8%29%3B%0A++display.print%28menu%5Bpos%5D%29%3B%0A++display.setCursor%280%2C+16%29%3B%0A++display.print%28%22press+dial%22%29%3B%0A++display.setCursor%280%2C+24%29%3B%0A++display.print%28%22to+set.%22%29%3B%0A++display.display%28%29%3B%0A++delay%28200%29%3B%0A+%0A++%2F%2F+Reads+the+initial+state+of+the+ENCODER_SW%0A++encoderSwLastState+%3D+false%3B%0A++%2F%2Fdelay%2880%29%3B%0A++encoderSwState+%3D+digitalRead%28ENCODER_SW%29%3B%0A%0A%0A++while+%28%21%28%28encoderSwLastState+%3D%3D+encoderSwState%29+and+%28encoderSwState+%3D%3D+false%29%29%29+%7B%0A++++encoderSwLastState+%3D+encoderSwState%3B%0A++++encoderSwState+%3D+digitalRead%28ENCODER_SW%29%3B%0A+++%0A++++encoderClkState+%3D+digitalRead%28ENCODER_CLK%29%3B%0A++++if+%28encoderClkState+%21%3D+encoderClkLastState%29+%7B%0A++++++if+%28%21skipIt%29+%7B%0A++++++++if+%28digitalRead%28ENCODER_DT%29+%21%3D+encoderClkState%29+%7B%0A++++++++++pos%2B%2B%3B%0A++++++++++pos+%25%3D+menuLen%3B%0A++++++++%7D+else+%7B%0A++++++++++pos--%3B%0A++++++++++if+%28pos+%3C+0%29+%7B%0A++++++++++++pos+%3D+menuLen+-+1%3B%0A++++++++++%7D%0A++++++++%7D%0A++++++++display.clearDisplay%28%29%3B%0A++++++++display.setCursor%280%2C+0%29%3B%0A++++++++display.print%28%22Choose+menu%3A%22%29%3B%0A++++++++display.setCursor%280%2C+8%29%3B%0A++++++++display.print%28menu%5Bpos%5D%29%3B%0A++++++++display.setCursor%280%2C+16%29%3B%0A++++++++display.print%28%22press+dial%22%29%3B%0A++++++++display.setCursor%280%2C+24%29%3B%0A++++++++display.print%28%22to+set.%22%29%3B%0A++++++++display.display%28%29%3B%0A++++++%7D%0A++++++skipIt+%3D+%21skipIt%3B%0A++++%7D%0A++++encoderClkLastState+%3D+encoderClkState%3B%0A++%7D%0A++display.clearDisplay%28%29%3B%0A++display.setCursor%280%2C+0%29%3B%0A++display.print%28%22Choose+menu%3A%22%29%3B%0A++display.setCursor%280%2C+8%29%3B%0A++display.print%28menu%5Bpos%5D%29%3B%0A++display.setCursor%280%2C+16%29%3B%0A++display.print%28%22menu+chosen.%22%29%3B%0A++%2F%2F+display.setCursor%280%2C+24%29%3B%0A++%2F%2F+display.print%28onThresh%29%3B%0A++display.display%28%29%3B%0A++delay%281000%29%3B%0A++if+%28pos+%3D%3D+0%29+%7B%0A++++pumpOnThresh+%3D+getEncoderData%28%22PumpOnTres%22%2C+pumpOnThresh%29%3B%0A++%7D+else+if+%28pos+%3D%3D+1%29+%7B%0A++++pumpOffThresh+%3D+getEncoderData%28%22PumpOffTres%22%2C+pumpOffThresh%29%3B%0A++++%2F%2F+pumpOffThresh+%3D+setLowThresh%28%29%3B%0A++%7D%0A%7D%0A%0A%0Aint+getEncoderData%28char*+theParam%2C+int+startPos%29+%7B%0A++bool+skipIt+%3D+true%3B%0A++%2F%2F+int+onThresh+%3D+pumpOnThresh%3B%0A%0A%0A++display.clearDisplay%28%29%3B%0A++display.setCursor%280%2C+0%29%3B%0A++display.print%28%22Change+%22%29%3B%0A++display.print%28theParam%29%3B%0A++display.print%28%22%3A%22%29%3B%0A++display.setCursor%280%2C+8%29%3B%0A++display.print%28startPos%29%3B%0A++display.setCursor%280%2C+16%29%3B%0A++display.print%28%22press+dial%22%29%3B%0A++display.setCursor%280%2C+24%29%3B%0A++display.print%28%22to+set.%22%29%3B%0A++display.display%28%29%3B%0A++delay%28200%29%3B%0A+%0A++%2F%2F+Reads+the+initial+state+of+the+ENCODER_SW%0A++encoderSwLastState+%3D+false%3B%0A++encoderSwState+%3D+digitalRead%28ENCODER_SW%29%3B%0A%0A%0A++while+%28%21%28%28encoderSwLastState+%3D%3D+encoderSwState%29+and+%28encoderSwState+%3D%3D+false%29%29%29+%7B%0A++++encoderSwLastState+%3D+encoderSwState%3B%0A++++encoderSwState+%3D+digitalRead%28ENCODER_SW%29%3B%0A+++%0A++++encoderClkState+%3D+digitalRead%28ENCODER_CLK%29%3B%0A++++if+%28encoderClkState+%21%3D+encoderClkLastState%29+%7B%0A++++++if+%28%21skipIt%29+%7B%0A++++++++if+%28digitalRead%28ENCODER_DT%29+%21%3D+encoderClkState%29+%7B%0A++++++++++if+%28startPos+%3C+1023%29+%7B%0A++++++++++++startPos%2B%2B%3B%0A++++++++++%7D%0A++++++++%7D+else+%7B%0A++++++++++if+%28startPos+%3E+0%29+%7B%0A++++++++++++startPos--%3B%0A++++++++++%7D%0A++++++++%7D%0A++++++++display.clearDisplay%28%29%3B%0A++++++++display.setCursor%280%2C+0%29%3B%0A++++++++display.print%28%22Change+%22%29%3B%0A++++++++display.print%28theParam%29%3B%0A++++++++display.print%28%22%3A%22%29%3B%0A++++++++display.setCursor%280%2C+8%29%3B%0A++++++++display.print%28startPos%29%3B%0A++++++++display.setCursor%280%2C+16%29%3B%0A++++++++display.print%28%22press+dial%22%29%3B%0A++++++++display.setCursor%280%2C+24%29%3B%0A++++++++display.print%28%22to+set.%22%29%3B%0A++++++++display.display%28%29%3B%0A++++++%7D%0A++++++skipIt+%3D+%21skipIt%3B%0A++++%7D%0A++++encoderClkLastState+%3D+encoderClkState%3B%0A++%7D%0A++display.clearDisplay%28%29%3B%0A++display.setCursor%280%2C+0%29%3B%0A++display.print%28%22Change+%22%29%3B%0A++display.print%28theParam%29%3B%0A++display.print%28%22%3A%22%29%3B%0A++display.setCursor%280%2C+8%29%3B%0A++display.print%28startPos%29%3B%0A++display.setCursor%280%2C+16%29%3B%0A++display.print%28theParam%29%3B%0A++display.print%28%22+set+to%22%29%3B%0A++display.setCursor%280%2C+24%29%3B%0A++display.print%28startPos%29%3B%0A++display.display%28%29%3B%0A++delay%281000%29%3B%0A++return+startPos%3B%0A%7D]&lt;/p&gt;&lt;div&gt;&lt;/div&gt;&lt;p&gt;This phase of the project is now undergoing the final tests in full function modus. While this is in progress i plan to shift my focus towards finding a solution for the messaging i wanted to implement.&lt;/p&gt;&lt;p&gt;-raymond&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=4238&amp;AppID=193&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: (Semi)Automated Plant Irrigation System</title><link>https://community.element14.com/challenges-projects/project14/mixing-electronics-water/b/blog/posts/semi-automated-plant-irrigation-system</link><pubDate>Wed, 07 Feb 2018 19:30:10 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:0371e654-77cf-4f8a-aa66-5fe74a98db0a</guid><dc:creator>beacon_dave</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;In the activity view, you need to select the blog title first before the options become available to edit.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;e.g. if you click here:&lt;/p&gt;&lt;p&gt;&lt;a class="jive-link-blog-small" href="/challenges-projects/project14/mixing-electronics-water/b/blog/posts/semi-automated-plant-irrigation-system"&gt;(Semi)Automated Plant Irrigation System&lt;/a&gt; &lt;/p&gt;&lt;p&gt;then you should find that you can edit your previous posts.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=4238&amp;AppID=193&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item></channel></rss>