# Soil moisture measurement

Background

To kick-start my longstanding ambition of getting back into electronics, I decided to try and make a device that measures the soil moisture of potted plants to determine whether they need to be watered. The aim for the first incarnation is to have a led that shows the plant's current water level (add water is red!), but of course I have wild plans for self-watering plants down the road.

My first stab was based on the Garduino instructable, specifically this circuit here:

It is a simple voltage divider using a known resistor and two copper wire electrodes stuck in the soil as measuring device. The voltage measured at A0 using the ADC on my Teensy++ is proportional to the ratio of the resistances, and I can work back to the actual soil resistance.

However, in practice the soil resistance turned out to be subject to a very large drift. Almost immediately after turning on the device, the measured soil resistance started dropping. (This also happens if you stick a multimeter in the plant.) After a few days of measurement, I could find no usable connection between the measurements and the moisture level. Removing the probe and inspecting it revealed considerable tarnish on the anode. To me, this indicates that some sort of chemical reaction is taking place (electrolysis?). A multimeter measures a voltage differential of a few tens of millivolts: I have turned my plant into a battery!

To avoid this problem I moved to a probe constructed out of stainless steel screws. As they are considerably less reactive than copper, the oxidation should be less of a problem. Also, to avoid "charging" the soil, i have put the voltage divider between two digital output pins of the Teensy. The measurement happens as follows:

• Both pins are kept low when no measurement is taking place.
• I drive one pin high. I wait one millisecond and I measure the voltage at the center of the divider.
• I invert the pin voltages (high<->low), wait one millisecond and measure again. I should now measure the complement of the first measurement.
• Both pins are brought low again and the device sleeps until the next measurement.

This does reduce the oxidation problem, but the measured soil resistance still seems to start dropping as soon as I start measuring.

Question

1. Can anyone recommend a robust method to measure soil moisture?
2. Can anyone explain what is really going on here?

Brainstorming:

I've been reading about capacitive sensing recently. Capacitive-touch sensors have the great advantage that they can be completely hermetically sealed behind a thin layer of plastic, so there is no exposed metal to corrode. ("Electronics and Robotics: Sensing touch through a thick surface?")

Because you can't get DC current to flow through the plastic, such sensors must use AC, as Leon Heller suggested.

Alas, most of the discussion I've seen has been about how to respond only to intelligent finger-presses; what little discussion there is about water an moisture is about how to reduce the sensitivity of capacitive sensors to water splashes. ("Sparkfun forums: Capacitive sensors and waterproofing"). So clearly they are sensitive to water, so perhaps you could use this "flaw" and turn it into a feature.

• Yes, this would certainly work and it is my current line of inquiry. The main trouble I'm having is designing the probe such that is has a capacitance swing that is large enough to measure. This is my main source of inspiration: mechanical.poly.edu/faculty/vkapila/ME3484/Readings/… – drxzcl Feb 7 '11 at 20:06
• I'm making good progress with a capacitive sensor. The main challenge is making sure the moisture does not come into direct contact with the electrodes, as that turns it into a resistive load. But I think i have the electronics part of it worked out. – drxzcl Feb 28 '11 at 9:26

You should be using AC, to avoid polarisation of the electrodes, with a Wenner bridge arrangement.

• Could you please elaborate a bit more on the concept of a Wenner bridge? A search yields mostly journal papers, and I do not have access to those without physically going to the university library. The titles (salinity measurements etc) seem promising! – drxzcl Jan 27 '11 at 8:25
• corrosion-doctors.org/Corrosion-Kinetics/Ohmic-drop-soil.htm – Mark Jan 28 '11 at 16:20

The only robust method for measuring soil moisture that I am aware of is using these probes.

• Very interesting! I had heard of probes measuring the dielectric constant by basically building a capacitor, but I had seen any for sale. Since it's a hobby project I prefer "build" to "buy", but i do prefer "buy" to "nothing" ;) – drxzcl Jan 28 '11 at 13:40
• On that note, "Because our probe measures the dielectric constant of the soil using transmission line techniques, it is insensitive to water salinity, and will not corrode over time as does conductivity based probes." - it sounds like exactly the technology i need. – drxzcl Jan 28 '11 at 13:41
• I'm trying to figure out exactly how the probes in the shared link work. Are they using TDR or TDT? Or is it just capacitance? What would a basic setup include to replicate their functionality? – Davido Sep 25 '14 at 3:39

Here's how botanicalls does it.

• Am I correct in assuming the 9, 10 and 12 pins are used for other things? They don't seem to affect the sensor circuit. – drxzcl Jan 26 '11 at 21:24
• Yes, it looks like 9 & 10 are just controlling LEDs and 12 is a switch – Toby Jaffey Jan 26 '11 at 21:38
• Let's see if i get this. I would drive 8 high, establishing a (small) current through the probe. This current is amplified by the BJT and I would measure the voltage drop of this current over a known resistor of 100 Ohm. What would this buy me over the voltage divider design? – drxzcl Jan 27 '11 at 1:05
• Thanks for pointing me to Botanicalls! I have examined their schematics and code and I have made some interesting discoveries, aside the difference in measuring circuits above. They use galvanized steel electrodes that are only energized during measurement (no delay at all, not even a ms) and they still have problems with degradation due to electrolysis. They also keep a moving average of the moisture sensor readings, by default 10 samples over 2 minutes. I'll experiment a bit and report back. – drxzcl Jan 28 '11 at 9:22

I've constructed a soil humidity sensor using two galvanized nails set in a cylinder of Plaster of Paris. I didn't test it over a long enough period of time to draw any conclusions as you have, but you might experiment with that design.

The plaster neutralizes any acid in the moisture, thus isolating humidity content as a variable (but also works as a kind of low-pass filter!) + the galvanization on the nails helps to prevent them from oxidizing.

Please post if you find a good solution.

• Now that you have had some time with these sensors do you know any more about their durability? I am particularly concerned about galvanic corrosion.... – angelatlarge Dec 24 '15 at 16:11

You might try using the Irrometer Watermark sensors. I'm using them now to measure soil moisture. If you're interested, I can try and dig up the schematic.

• I've looked at the website and I've noticed they have both capacitative sensors and resistive sensors embedded in gypsum. Which are you using? Are they any good? – drxzcl Feb 1 '11 at 13:45

I'd recommend the Watermark sensors. They're durable and quite easy to read. You need two digital outputs plus one input per sensor.

Connect each meter to your outputs, in series with a 10k resistor. When you want to measure, set one output High and the other Low. Measure the voltage across the sensor. http://www.irrometer.com/pdf/supportmaterial/sensors/voltage-WM-chart.pdf has a chart for rough calibration; you'll need to establish a "completely wet" baseline. Because you're supposed to thoroughly wet the soil when you bury the sensor, you'd do this anyway in order to make sure the thing is working correctly.

You use two outputs because you should switch polarity in order to avoid corrosion.