|
Post by papa on Mar 1, 2017 20:56:06 GMT
Perhaps like me, you've been interested in using OpenHAB & nodes to automate irrigation. I recently created a Soil Moisture & Soil Temperature End Node that I wanted to use for Irrigation Automation. Studying this, this, & this, I saw a good start on how I might irrigate my garden beds. These versions rely on weather data & (predetermined, but adjustable) watering periods. I wanted to include the weather data. However, instead of watering by timers, I wanted to use my soil moisture end node to trigger watering when the soil was drying out & stop when adequate moisure was achieved. The following irrigation automation assumes one has these working: OpenHAB, MQTT, & computourist-style gateway. (I believe a ESP8266 wifi node could also be used without a gateway.) I used Linux & OpenHAB2. Also assumed is a Soil Moisture End Node in the garden bed & something like a DHT End Node. The DHT End Node will toggle a electrically activated water valve via a DC to AC solid state relay. The following also assumes an irrigation system (sprinklers, drip, ??) which includes water valves that open via AC electricity. Clicking the node's User Interface or physical switch will (for maybe a minute) toggle the state of the valve open or closed before the state reverts its state before the attempted switch. This setup was successfully tested later in a real garden (see below). For now, it was tested successfully with soil probes inserted into a plant pot. When the pot's soil dries below the moisture threshold, the node triggers the relay to turn on an AC light. Even with DHT sensor, push button, soil moisture sensor, & soil temp sensor running, the node had enough current to trigger the relay to switch on an AC device. At this date, I thought I might mount the irrigation node on a stake in a garden bed & for protection, cap it with a liter bottle whose bottom has been removed. Later (see this post), I installed the irrigation node in a sealed project box.
|
|
|
Post by papa on Mar 1, 2017 20:56:31 GMT
This irrigation system can work with (in each garden bed) a wall-powered end node that includes at a minimum: soil moisture probe, DS18 Sensor to sense soil temperature , & a solid state relay which the node triggers with a 5 volt signal sent via a transistor. Such a node may also include a DHT Sensor to measure outdoor temperature & humidity plus a push button. With help from OpenHAB programming, this node does it all: read soil moisture (corrected by temperature) & (in the garden bed) switch on a water valve via the relay. This system can also work (less effectively?) with (in ONE garden bed) a soil moisture & temperature end node powered by battery or wall power. A wall powered DHT End Node with relay near the water source & an electrical outlet could control the water supply to all beds. This version would be most effective in watering one bed. It could water more than one bed, but all beds would receive water based on one bed's moisture reading. See here for the separate Soil Moisture Node (#DEFINE SLEEPY for battery). See here, starting with the first Oct 10, 2015 post, for the separate DHT end node that sends 5 volts (via a transistor) to the relay that controls the water valve. Again for irrigation purposes you could eliminate the DHT sensor & the pushbutton. To use this system for lawn irrigation, I'm thinking one could put a (protected) node that controls a solid state relay near each water valve & then put a battery powered (& protected) soil moisture node in the lawn zone that is watered by that valve.
|
|
|
Post by papa on Mar 1, 2017 21:03:03 GMT
<< click on the pic for a larger view ^^ Updated March 24, 2020: Here is a schematic for an irrigation node that combines all functions. Please note this Irrigation Node schematic uses pins D6 & D7 for the soil moisture probes, instead of D7 & D8 in the schematic for the Soil Moisture End Node.
This updated schematic recommends adjusting a 0 ohm to 10 kilo ohm potentiometer to achieve "resistor 2."
|
|
|
Post by papa on Mar 1, 2017 21:08:50 GMT
Irrigation Node, Software (Updated August 30, 2021)
Go here for the latest sketch for the Irrigation Node that combines all functions. Again (in case one wants to install the push button on D8), this version of the Multi-Choice End Node sketch uses pins D6 & D7 for the soil moisture probes, instead of D7 & D8 in the Soil Moisture End Node sketch. With this version of the sketch, when radio connection with the Gateway is lost, the irrigation control node turns off the relay so the water valve will not be stuck on flooding the garden. When a connection to the Gateway is restored, the previous relay state resumes. With this newer version of the sketch, I inverted readings of the soil moisture probes so the values increase along with the amount of soil moisture. Necessary customization of the Irrigation End Node ... Fairly early in the sketch, customize by UNcommenting these #DEFINEs: FAHR or CELS (temperature scale) HT (if using that sensor) BUTTON (if using button & relay) ACTOR (if just using the relay) SOILMOIST DS18 & DS18B. Configurations below assume NODEID 12. (Use no NODEID lower than 05.) Use the same ENCRYPTKEY as for your Gateway. At least for testing, UNcomment #define DEBUG UNcomment only your RFM69 radio's frequency Ncomment ONLY if your RFM69 radio has an "h" in its part number.
|
|
|
Post by papa on Mar 1, 2017 21:34:15 GMT
Added 3/5/2017: Be sure OpenHAB's Weather binding is installed.
To Automate Irrigation, add the following OpenHAB config file entries if they are not already present... Blue text indicates missing config lines that were supplied on 3/3/2014 .items (units in inches)Number Weather_Precip_IN "Precip Today [%s in]" <precip2> (Weather) {weather="locationId=home, type=precipitation, property=total, unit=inches"} Number Precip_IN_Yesterday "Precip Yesterday [%s in]" <precip2> Number Precip_IN_Last7Days "Precip Last 7 Days [%s in]" <precip2>
Number Precip_Probability "Precip probable [%d %%]" <rain> (Weather) {weather="locationId=home, forecast=0, type=precipitation, property=probability"} Number Precip_Probability_2day "Precip probable tomorrow [%d %%]" <rain> (Weather) {weather="locationId=home, forecast=2, type=precipitation, property=probability"}Number DS18_Node02 "Soil_Temp_02 [%.1f °F]" <temperature> {mqtt="<[mosquitto:home/rfm_gw/nb/node02/dev50:state:default]"} Number SoilMst_02 "Soil Moisture Level_02 [%s]" <humidity> {mqtt="<[mosquitto:home/rfm_gw/nb/node02/dev67:state:default]"} String SoilM_Data "Soil Moisture_02 [%s]" <humidity> Switch GoodWaterTime "Good Time to Water ?" <sprinkler> Switch MaybeIrrigate .sitemap Switch item=Valve01 Switch item=MaybeIrrigate To Automate Irrigation, add the following OpenHAB config files ... Irrigation.rules (7.65 KB) ^^ Download to your rules folder. (In the rule "Does_Weather_Suggest_Irrigation, the variable rainThreshold = 1 means a rainfall of 1 inch) ^^ Download sprinkler.png to your icons or images folder. In mapdb.persist add to the Strategies { [/b][/font][/span] nearMidnight : "0 52 23 * * ?" In mapdb.persist add to the Items { [ list ] } ... Precip_IN_Last7Days : strategy = everyMinute, restoreOnStartup// store precip total every day ONLY near midnight TODAY to use (tomorrow) for Yesterday's precip (NOT in a group) // Just 2 min before, Precip_IN_Yesterday gets Weather_Precip_In (accumulation for current day) Precip_IN_Yesterday : strategy = nearMidnight, restoreOnStartupIf you have not already, download soilmoist.scale to your transform folder & edit it to reflect your soil conditions. See this thread for more about this. If you are putting a water valve & an irrigation end node in more than one bed, add more items (adapting from the items provided here) for those nodes & add/adapt a Control_Valve02 rule for a second bed, etc for more beds. The OpenHAB Irrigation.rules have many log posting lines which can be activated by UNcommenting, by removing the "//" that starts them (& sometimes the line just before them). Via the Terminal command sudo tail -f /var/log/openhab2/openhab.log these log posting lines will display can be used to help monitor & debug. How the Irrigation.rules work: Based on rain lately & predicted rain, a MaybeIrrigate switch is set or cleared. If MaybeIrrigate is ON AND soil moisture is less than the set moisture threshold AND if it's an acceptable time to water (daytime, before & after the heat of the day), then a solid state relay opens a water valve to irrigate. I'm interested to hear from those that try this Irrigation Automation via OpenHAB & how it worked for them.[/ul]
|
|
|
Post by papa on Mar 3, 2017 0:23:23 GMT
See the 3/1/2017 post above that starts includes "Here is the sketch." There I just posted a new version of the irrigation node sketch. With this new version of the sketch, when radio connection with the Gateway is lost, the irrigation control node turns off the relay so the water valve will not be stuck on flooding the garden. When a connection to the Gateway is restored, the previous relay state resumes.
|
|
|
Post by papa on Mar 3, 2017 15:32:52 GMT
See the 3/1/2017 post above that starts "To Automate Irrigation, add the following OpenHAB config file entries ..." There I just posted some missing config file entries.
|
|
ragoth
Junior Member
Posts: 64
|
Post by ragoth on Mar 5, 2017 16:36:09 GMT
Dear Mr.Papa, I have a basic doubt, ie., the above items and sitemap file etc., are the complete file contents or it is to be added with your existing Configuration files like My.items, My.sitemap and My.rules files. It may be a silly question, but please reply.
|
|
|
Post by papa on Mar 5, 2017 16:53:38 GMT
Understandable question, ragoth. Copy the sprinkler.png icon to your images folder. Copy the Irrigation.rules file to your rules folder. Irrigation.rules can function along side other rules files (presupposing the rules contained in the files don't try to do conflicting things).
WITH CARE, add the above items & sitemap entries to your EXISTING .items & .sitemap files. Be sure you don't end up with an item defined in more than one way. The items Number Weather_Precip_IN & Number Precip_Probability may already be in your items. In those cases & any others, use the above versions if they differ from existing ones.
In the Mar 1, 2017 post above about OpenHAB config entries, I added a few notes in this purple text.
|
|
|
Post by papa on Mar 8, 2017 21:35:07 GMT
I developed this Irrigation Automation on a Linux laptop running OpenHAB 2. If you'll use this with OpenHAB 1.x, see this thread about translating OH 2 config files to OH 1.
|
|
|
Post by jimkernsjr on Mar 16, 2017 1:07:16 GMT
P.S. I'm not being negative about using those package management thingies, but I came from Red Hat Linux long before it had all that fancy stuff. I find it depends on what SBC you have, what OS flavor, what Package management thing you end up with. So I just prefer the commands. But I will say from my limited experiece with it, RPI is the best, and I found Pine64 to be as unstable as Charles Manson on crack. I also like your irrigation system you develop. I have one I developed, completely standalone, that ran on the RPI, with the "PiHat Relay Board". It's completely written in Python, PHP, and MySQL (which is why I'm somewhat Biased). I just dont know how I feel about OpenHAB controlling watervalves over a wireless network - this scares me a little. My software has been working flawlessley since about 2014, but has a small voltage drop problem I discovered. If you tax the CPU with a valve open, the PI can hang up, and you know the rest. Which is why I say be careful! My lawn got a good watering that weekend! I've since used a port expander, Darlington chip, and offloaded the relay power so it's not being powered by the PI. It also now has a watchdog system too! I've added MQTT to it and make it check in with OPENHAB every 5 minutes, or OpenHAB shuts it down. The whole project is great, and Its still better than most I've seen featurewise. It's just not as polished, as you can see (times in "raw" format, etc). I just added zones 5-8 for this year because I added irrigation to my back yard. If it's something anyone has an interest it, I'd love to share it - maybe someone has the time to take it further than I ever did. It would be easy to integrate further to openhab, you could just have Openhab cancel the watering if your soil is already damp enough. But anyway, honestly, I'm more scared of water than electricity...some of the biggest natural disasters were water, not fire. Be careful with it! Attachments:
|
|
|
Post by papa on Mar 16, 2017 1:35:15 GMT
jimkernsjr, I moved your interesting post (above) about Irrigation Automation here. You raise some safety, reliability issues that I've had in the back of my mind.
I will be doing low flow drip irrigation, not heavy flow sprinklers. For my irrigation controlled nodes, I probably will use Buono Uno's plus shield. Each garden bed will have a soil moisture probe reporting to the node so that will cancel irrigation when moisture reaches in the middle of a good zone for the plants. I'm also thinking of using the expire binding to cancel irrigation if the soil end node loses touch. I'll probably also have OH message me if soil moisture somehow gets above the set moisture threshold & the valve is still on (stuck?)
I'll take to heart your warning that the node's signal to the relay could get stuck on & consider a separate power supply for the relay. I'll also take to heart your concerns about wirelessly controlling the irrigation valves.
It will take me a while to build irrigation piping, etc. May be wise to start with one garden bed that matters less & experiment with it.
|
|
brump
Junior Member
Posts: 81
|
Post by brump on Mar 24, 2017 19:04:17 GMT
Hi Papa,
Good progress. I've been a little away working. Now I'm back.
I implemented the timers on my irrigation system and everything is stable.
I'll post the news soon.
|
|
|
Post by papa on Mar 24, 2017 19:10:04 GMT
Great to hear from you, brump. I look forward to your describing what you've accomplished & what you may be working on still.
Is your irrigation system actually controlling water yet? I have to transition to my other living place in a couple weeks & (sometime after that) install drip irrigation before I can test my implementation.
|
|
|
Post by papa on Apr 3, 2017 20:43:50 GMT
I've aimed to make this Irrigation Automation as reliable as possible. jimkernsjr raised the possibility of flooding above. As I said in this post ... In the txRadio() function, I added this line (it parallels how computourist has DEBUG output "No Connection"): if (retx) digitalWrite(ACT1, 0); // Turn off irrigation ACTOR if node loses connection with Gateway I've just simulated again the conditions of lost connection & resumed connection & confirmed that the first turns off the relay & the second turns it on again (if moisture is needed).
|
|
|
Post by papa on Apr 26, 2017 21:44:28 GMT
I've continued to work on this Irrigation Automation project. Having 3 raised garden beds, I've built 3 each of the following: 1. Moisture sensor (2 stainless skewer lengths stabilized in 2 synthetic wine corks fastened together) 2. Drip tubing grid 3. Moisture & temperature sensor node controlling a solid state relay to activate a 24 VAC solenoid valve. I'm in the process of building the PVC piping & electrical wiring (in conduit) running to each bed. BTW, I tested the nodes in each outside garden bed & confirmed that they communicate with my second floor gateway.
Moisture sensor construction is updated below in this post.
|
|
|
Post by papa on May 8, 2017 23:50:02 GMT
After weather & other delays, I've finished most of the plumbing & wiring (via conduit) the electrical outlets to the 3 raised beds. (No leaks. Outlets work.)
Trenches for pipes & conduit are mostly filled in.
Still to do: - Connect the electrical water valves to the drip grids. - In the waterproof project box for each bed, install the node plus its relay, moisture sensor, & temperature sensor. - Wire the valve power supply through the relay. - Button up the project box. - Tweak the Arduino & OpenHAB programming based on real world experience
|
|
|
Post by papa on May 17, 2017 15:10:02 GMT
In this post above, I offered the latest version of my Multi-Choice Node Sketch. With this newer version of the sketch, I inverted readings of the soil moisture probes so the values increase along with the amount of soil moisture. The sketch has more options to create other kinds of nodes, including mixing the options. See this list (with links) of node possibilities.
|
|
|
Post by papa on Jul 22, 2017 16:19:04 GMT
Belated update on the Irrigation Automation Project Weeks ago, I finished the to do list: - Connected the electrical water valves to the drip grids. - In the waterproof project box for each bed, installed the node plus its relay, moisture sensor, & temperature sensor. - Wired the valve power supply through the relay. - Buttoned up the project box. ( See the project box in this post.) - Tweaked the Arduino & OpenHAB programming based on real world experience. The "tweaks" included correlating the moisture sensor readings with what is moist for a garden plant, especially the low & high sides of the moist range. These readings are probably not exact, but are good enough to keep soil moisture in a healthy range. In the OpenHAB irrigation rules, I use cron programming which sets moisture threshold at the low end of moist for about half of a week & at the high end the other half of the week. This cycling of moisture levels is supposed to be good for plants & encourage deep roots. Moisture sensors are still working. Their wiring & programming alternates the current powering the sensors, which so far seems to avoid electrolysis & eventual failure. The node programming turns off the relay & water valve whenever the node loses contact with the gateway. I've never had a flood due to a stuck valve. So far the project boxes protect the electronics from moisture & dirt. With some effort, I believe for the winter, I can remove & store the drip grids & electronics. This project (my biggest to date) was a lot of work over a long period. However, I am very pleased with the results. I love drip irrigation which is gentler & more efficient than alternatives. I definitely use less water. The electronics & programming are working well. It's a kick to hear the valves click on & the garden "waters itself." The plants are healthy & productive. I can focus on picking, eating, & giving away the garden produce. 32 square feet of raised beds is providing more than my wife & I can eat so friends are also benefiting from the bounty. So far I am more pleased with the results than I anticipated.
|
|
|
Post by papa on Aug 19, 2017 3:21:48 GMT
|
|
|
Post by papa on Oct 16, 2017 20:45:55 GMT
Update on My Automated Garden Irrigation
After a summer plus some fall operation, I am still pleased with my automated Garden Irrigation. Generally, the circuits & code have kept the moisture in my three raised beds in plants' ideal range (alternating between low & high thresholds in that ideal range). Between that & my drip irrigation grids, I am using less water, the water is applied more gently than before plus less water & soil bounces up on the plants. As I coded, the electrically activated water valves turn off when its node loses connection with the gateway & resumes when the connection is restored. It was nice to let the system mostly handle watering the garden & I could focus on other things.
I had one smaller issue: From time to time, I needed to re-seat the moisture sensors: lift them from the soil & reinsert them. This usually restored the accuracy of the moisture readings.
Bigger issue: A) About two weeks ago, one node started getting very low moisture readings even when a purchased moisture tester or a feel test indicated the moisture was OK, even high. B) Until I discovered this, during the scheduled watering windows, the garden bed's water valve was kept on. Until I turned off the main water supply, this over watered the bed (though not drastically because it is drip irrigation). Re-seating the moisture sensor did not solve the issue.
Fixing Bigger Issue A) 1) Today, I polished the moisture sensor's metal probes with steel wool. That did not make a difference, but was worth a try. 2) Insulated wires run from the two moisture sensor probes. The wires' bared ends insert into two female headers on the node's shield. With steel wool today, I polished those bare copper ends. So far now, that bed's node gets a moisture reading that I expect. The main water supply is still off. I will visually monitor the moisture readings for a while & if satisfactory, will restore the main water supply.
Note: I often make connections to nodes via bared wires inserted into female headers. I have such inside nodes running a couple years without problems. Moreover, I have two other garden bed nodes running inside protected cases without problems. However, apparently, even in protected cases, outside nodes may sometimes need tarnish removed from their probes or wires.
Fixing Bigger Issue B) False low moisture readings kept calling for water during the "Good Watering" periods: Probably not now, but in the winter, I will tweak the OpenHAB rules. My soil holds water well & when working, the system will keep moisture levels near the low & high thresholds I have set. So I might have an OpenHAB rule turn off the water valve (& send me a message) if a moisture reading is significantly lower than the current threshold.
Again, I am pleased with how this system works. I expected more problems. Apparently electrolysis on the moisture sensor probes is avoided by powering one probe, turning off probe power during the node's pause between sends, then powering the other probe, pausing power, etc. I am also confident that coding additions can do more to avoid over watering.
|
|
brump
Junior Member
Posts: 81
|
Post by brump on Oct 17, 2017 2:01:57 GMT
Again, I am pleased with how this system works. I expected more problems. Apparently electrolysis on the moisture sensor probes is avoided by powering one probe, turning off probe power during the node's pause between sends, then powering the other probe, pausing power, etc. I am also confident that coding additions can do more to avoid over watering. Hi Papa, Have tried to use as sensors 316 stainless steel bars. Probably will not have problems with oxidation. Another important point is not to leave the electrical connections between the material and the exposed conductors. Liquid insulation tape solves this problem well. Brump
|
|
|
Post by papa on Oct 17, 2017 17:31:49 GMT
brump: Have tried to use as sensors 316 stainless steel bars. Probably will not have problems with oxidation.
papa: I use stainless steel skewers. Since polishing the skewer ends did not help, I don't believe oxidation was the probelm.
brump: Another important point is not to leave the electrical connections between the material and the exposed conductors. Liquid insulation tape solves this problem well.
papa: I'm not sure I understand your "not to leave the electrical connections between the material and the exposed conductors." My wires solder to the skewers above the soil and the soldered areas are covered with heat shrink insulation. I use liquid insulation in other situations & like it.
I believe I need to re-position the moisture sensors occasionally because the dense soil shrinks away from the probes. In most cases, that restores accurate readings. One time for the one node, I had to polish the moisture sensor's wires where they connect with the node sockets.
Thanks, brump, for checking in with suggestions. How is your irrigation project progressing?
|
|
brump
Junior Member
Posts: 81
|
Post by brump on Oct 23, 2017 1:40:32 GMT
papa: I'm not sure I understand your "not to leave the electrical connections between the material and the exposed conductors." My wires solder to the skewers above the soil and the soldered areas are covered with heat shrink insulation. I use liquid insulation in other situations & like it. I believe I need to re-position the moisture sensors occasionally because the dense soil shrinks away from the probes. In most cases, that restores accurate readings. One time for the one node, I had to polish the moisture sensor's wires where they connect with the node sockets. I say that because the oxidation in the wires increases the resistance at that point. Regarding the heat shrink used, always prefer the model with internal glue. No glue can occur on rainy days or where there is large water accumulation, end up migrating to the wire and cause oxidation, as mentioned above. The hint of liquid insulator and when properly applied it can be immersed in water that your wire does not run risk of exposure. papa: Good to know. Thanks. So far, my oxidized wires were inside the project box and inserted into the node's sockets. My irrigation project is in the same way. Only with timer and solenoid to open the water flow. After February I intend to replace my sprinklers with retractable models, with that I will have to open the grass and so prepare to install electrical pipes to install the humidity sensors. You're making great progress. Congratulations! papa: Yes, thanks, the progress has been very satisfying.
|
|
brump
Junior Member
Posts: 81
|
Post by brump on Oct 23, 2017 16:23:20 GMT
papa: Good to know. Thanks. So far, my oxidized wires were inside the project box and inserted into the node's sockets.
You can use dow corning 4 (DC 4) on the connectors and wires inside the box.
|
|
|
Post by papa on Oct 23, 2017 19:21:30 GMT
Thanks, brump. You are a treasure of information. Heat shrink tubing with a glue lining looks promising for achieving a tighter seal in challenging installations like outdoors.
I had never heard of Dow Corning 4 Electrical Insulating Compound. It looks interesting, but from what I read, DC 4 might prevent the bare wire ends from electrically connecting to the node's female sockets (as I need).
I believe those bare wire ends may have been stripped of insulation & exposed long before I used those wires. Thus the oxidation could have started before I attached those wires to the moisture sensor. I have no trouble with the the nodes in the other two garden beds. I bared the ends of those two nodes' moisture sensor wires not long before I inserted them into the node's female sockets.
|
|
brump
Junior Member
Posts: 81
|
Post by brump on Oct 23, 2017 22:52:25 GMT
I had never heard of Dow Corning 4 Electrical Insulating Compound. It looks interesting, but from what I read, DC 4 might prevent the bare wire ends from electrically connecting to the node's female sockets (as I need). I'm happy to contribute to your project.
|
|