Arduino Plant Irrigator, Code Free

1.5K52

Intro: Arduino Plant Irrigator, Code Free

In this instructable we build a watering robot, which irrigates your plants at daytime when the soil gets dry enough. This is a classic Arduino-based project, but this time we use a visual programming language, XOD, which makes the programming process quite explicit.

STEP 1: Robot Makeup

An immersive water pump will deliver water to the plant when the soil is dry. We measure its moisture level using a soil moisture sensor.

We don't want to water our plant at night, so the luminosity sensor checks if it is daytime.

To ensure the pump’s safe operation, we use another soil moisture sensor as a water level sensor.

The robot's visual language is laconic: red LED means "there's no water, can't irrigate" green LED means "I'm operating, measuring the environmental indicators, ready to irrigate when needed".

An Iskra Neo (Arduino Leonardo) board commands all modules.

STEP 2: Assembling Electronic Modules

Modules used:

  • Iskra Neo board (Arduino Leonardo)
  • Slot shield
  • Soil moisture sensor (x2)
  • Luminosity sensor
  • LED module (x2)
  • Pump
  • Wall plug (6-9V DC)

Note the power supply circuit:

  • Use a jumper to make the V2 bus on a Slot shield use Vin power supply (from the plug directly)
  • Place the MOSFET module on any V2 slot with a V=P+ jumper on
  • Make sure other modules use the V1 power bus (which is Arduino's 5V)

Best practice is to wire soil moisture sensors through another couple of MOSFETs and read them regularly to avoid electrolytic corrosion, but let's keep this robot simple.

STEP 3: Understanding Workflow

Examine the diagram from the bottom up!

  • The pump is turned on when both "climate" and "water" conditions are met
  • Water condition means that there is enough water in the tank, if it is not so, the "no-water led" turns on and the result of conjunction for climate and water conditions becomes false
  • Climate condition is also a complex one: it is true if both soil and luminosity conditions are true
  • Soil condition is based on comparison between current soil moisture level and a predefined threshold value Luminosity condition is similar to the soil condition, but measures luminosity instead

STEP 4: Obtaining Threshold Values

Sensor thresholds (sample data, may vary in your case):

  • Soil moisture: 0.15
  • Luminosity: 0.58
  • Water: 0.2

How to take measurements (for XOD versions without Serial features):

  1. Download and install Arduino IDE
  2. Open File-Examples-01.Basics-AnalogReadSerial example
  3. Change "delay(1);" to "delay(250);"
  4. Connect the board. Make sure your board model and port are selected in Service menu
  5. Repeat for each sensor:
  • Check the pin number in "int sensorValue = analogRead(A0);" and change A0 to A3 and A2 for luminosity and water sensors respectively (if you've assembled your device according to the scheme)
  • Upload the sketch Open Service-Serial Monitor, make sure 9600 baud selected in the bottom right dropdown and watch live measurements change as you adjust the sensor's environment
  • Pick a value between registered minimum and maximum (closer to minimum for the luminosity sensor), divide it by 1023 and use the result in your patch

STEP 5: XOD Basics

  • Download and install the XOD IDE
  • A XOD program is called a patch; we build it in the area with a number of slotted rows on the right.
  • At the first launch you can run into a built-in tutorial patch.
  • The patch consists of nodes, connected with links through the pins.
  • Each node represents either a physical device/signal or a data item, while links control the data flow.
  • Double-click any blank space of the patch or press "i" key to open a quick search dialog where nodes can be found by their names or descriptions.
  • Use project browser on the upper left to explore the patches.
  • Select a node and view/edit its properties in the inspector on the bottom-left side.
  • To try XODing yourself, click File-New Project and create an empty patch.
  • You can return to the tutorial any time you like by opening the Help menu.

STEP 6: Irrigator Patch

Use the patch (basic-irrgator.xodball) or build it yourself according to the diagram.

Notice that the patch provided has already been created, so some nodes were updated in the IDE:

  • "analog-input" nodes are now deprecated, use "analog-read" instead
  • "led" node has more features now

Although the thresholds are just constant numbers, I don't put them in the comparison nodes property fields, but add explicit constant-number nodes instead to emphasize that these values could be evaluated differently. For instance, there could be a mobile application that allows the owner to tweak these values, so there would be another "retrieve from app" node instead of these constant-number nodes.

STEP 7: Deployment

  • When the patch is ready, click Deploy, Upload to Arduino.
  • Connect the board.
  • Check the board model and serial port in the dropdowns, then click Upload.
  • This may take a while; Internet connection is required.
  • If you use the browser XOD IDE, use Arduino IDE to upload the program to the board.
  • If you have any troubles uploading the patch, explore the XOD Forum

STEP 8: Construction Time

Use any suitable parts to make the robot's shell or design and 3D-print them yourself. At the worst just drop the pump and the sensor in the water tank and stick the soil sensor where it belongs.
Consider making a curtain for the luminosity sensor, because our LEDs may blind the sensor and it will misjudge the night time.

STEP 9: Water Level Sensor Placement

If you use a soil moisture sensor to check water level, make sure its golden coating is above water, and its tips will miss water earlier than the upper side of the pump will.

STEP 10: Testing

When your robot is ready, thresholds are measured and encoded in the patch, and the latter is uploaded to the board, it's time to test all possible cases.

  • Make the water level sensor dry. Only the red LED should be on. Even if the soil is dry and the room is illuminated at the same time, the pump should not start.
  • Now add the water, but first cover the luminosity sensor to make sure dry soil and presence of water won't make the robot irrigate at night.
  • Finally, let the robot water your plant. It should stop when the soil is moist enough.
  • Take the soil sensor out to repeat the irrigation (just to be sure).

STEP 11: Enjoy and Improve

Now that the basic irrigator is complete, consider some options for improvement:

  • Re-wire the soil moisture sensors to avoid corrosion
  • Add other environment measurements, e.g. air humidity
  • Make a real-time schedule
  • Put the robot online to monitor and control it remotely

2 Comments

I've been making a very similar project- I found that stainless steel screws are excellent soil moisture probes. I simply wrapped copepr around the neck of 3/616 x 4" SS bolts and got rid of the little PC board probes that came with the soil moisture sensor kit. In fact a voltage divider circuit worked best, using the SS screw pair as the second (cathode) side of the VR and sent the output wire directly to my A0 pin ( I use 4; A0 thru A3) with my nano A-4 &5 as my IIC inputs for my LCD. The input is easily adjustable through the XOD multiplier node. Calibrating between the 'dry' and "moist" zones is done with a few days of testing - I insert the SS screw contacts directly into the plant soil about 3" apart. this seems to give the best result, although it can change the output according to the varying amounts of plant food you give the plant- Plant food is electrolytic. I try to mix my plant food to a TDS of about 1200 to 1500 and that gives me a near perfect stable moisture reading and quite an acceptable nutrient level for my plants. I also found my moisture levels were much more stable with some level of electrolytes in the water. Just plain tap water gave unstable or erratic readings over time, causing the system to glitch toward either too dry or too wet. Also, the type of soil is very critical to electronic readings. Dense, poorly drained soil gave me a very narrow (brittle) moisture reading and caused some overwatering due to delays in the soil absorbing the moisture. Loose, aeriated soil also tended to separate or loosen contact with the sensors which caused erratic readings. I became accustomed to making sure the soil around the probes was well compacted making good contact. I also experimented with various shapes of probes, from spirals, to ring to sheet metal squares, perforated tubes - and found the shape barely made any difference. But, one huge problem with the little probes that come with the kit you are using is corrosion. In jsut a matter of a few days, I found the PC board probes corroded almost completely to uselessness. I then coated the probes with silver solder, but then found they developed a kind of oxide crust that interfered with the readings. So far, the stainless steel probes are doing just fin. I intended to replace them with titanium rods (available through "online metal store" at a very reasonable price. I chose titanium because I had experienced many years ago with an electrolytic chemical process in which titanium anode/cathode was the only metal that did not dissolve itself into the process through corrosion in the electrolysis.

Placing a time delay between watering events greatly stabilized the system. I water for only 6 seconds then wait at least 300 seconds before accepting the next reading of the sensor. If the soil reading is still below the threshold, the plant gets another 6 seconds of water- and so on until the reading is satisfactory. I found that the system quickly leveld out to where the plant calls for moisture as soon as the 6-second delivery amount of moisture has been well absorbed- about every 45 minutes on cool days and about every 30 minutes on warmer days. I do not get wasted nutrient water draining through the soil and dripping out into the catch pan. The plant uses all the moisture and nutrient it is getting.

One other thing: I learned that a pump can fail. So, I use a gravity feed system, Water is delivered to a reservoir that is elevated about 1 meter above the base of the plant and a small valve is opened to gently drain the water into the pot. I use a circular ring distributor to put the water completely around the base of the plant so it quickly drains equally into the root ball and uniformly near the moisture probes.

I did some other testing which demonstrated a small voltage is generated between the probes in the electrolytic rich environment of moist soil. I thought using probes of the same metals would eliminate this small background interference with the readings- but it persists. I do not quite understand this phenomenon or have I found its source. Apparently, growing plants produce a small but detectable flow of current- I did not know this before and it dogged my moisture readings causing them to be inconsistent. However, I played around with the various resistor values in the anode resistor of the voltage divider and found that about a 10K value seems to overpower the small voltage produced between the moisture probes, rather damping out the effect. Now, I have very reliable moisture readings and exceptionally healthy plants.

I also programmed with XOD although my first sketch was entirely in C++. I found XOD to be outstandingly easy to use and to change as needed.

Thanks for your excellent Instructable! Your charting was very helpful and informative.

Nice design. Anything that can help make my plants easier to take care of.