Soil moisture sensors: problems & solutions

Soil moisture sensors are popular among hobbyists who e.g. want to monitor or automatically irrigate their plants.

There are a number of cheap sensors available in the various ‘Chinese webshops’ but those come with a caveat. I will discuss a few and come with ‘solutions’ to some of the biggest problems.

The above sensor is very popular, but in short: it is shit. It is a resistive soil moisture sensor and those come with a big problem: electrolysis. The fact that there is a constant current flowing through the sensor when it is in contact with wet soil will lead to electrolytic breakdown of the very thin layer on the sensor’s PCB, or in other words: after a relatively short period the metal will no longer be on your sensor, but in your soil.

Another issue with this module is that people use the entire module even when that is not necessary. Let me explain with help of a picture:

Soil moisture sensor module

The image shows the circuit used in the module. It is basically a comparator that when the soil moisture (and thus the resistance) reaches a value that is set with the variable resistor, the output of the comparator (DO) toggles. So far so good. The analog output (AO) on the other hand is directly connected to the sensor. That means that if you only use the Analog Output, you do not need the module at all, just connecting the sensor to an analog input and use an internal or external pullup will suffice.
I suggest you do not use this sensor at all.

Soil moisture sensor

The above sensor is more of the same. It is also a resistive sensor and thus has the same problems as the one above. It does not have a digital output, just an analog. Also, because of the exposed electronics on it, it is not really suitable for outside use. I suggest you do not buy this one.

Soil sensor (supposedly protected)

The above sensor supposedly is made from a non-electrolytic sensitive material. It is suggested it is made of carbon. My experience with it is not long enough to say if that is true, but it seems to be fake in that aspect. However, it is definitely useable in combination with some solutions i will suggest later.

Capacitive soilsensor

The above sensor is a capacitive sensor. That means it does not measure the resistance of the soil but the capacitance of the soil. That means that there is no need to have any bare metal sticking in the soil and therefore electrolysis is not a problem. It has some other issues though: The coating that is used to cover the plates of the ‘capacitor’ sadly does not cover the sides of the PCB. Therefore moisture will eventually leak in and basically turn the capacitor into a resistor that will rot away. Also because of the exposed electronics at the top it is not really suitable to use outside. If you want to use this sensor it would be a good idea to dip or spray it completely into/with PlastiDipR.

Sadly there are some issues with this sensor:

  1. Some sensors do not use a TLC555 but an NE555. The latter is not working properly with 3v3 which means you have to remove the voltage regulator.
  2. The 1Mohm resistor (called R4 on the pcb) is not connected to ground on some boards, leading to very slow readings. As this seems to be a problem in the boards design it is easiest solved by soldering a 1Mohm resistor over the Aout and Ground pins.

Realise that capacitive sensors measure other values than resistive soil sensors. A capacitive sensor measures true water content of the soil whereas a resistive sensor in fact measures ion/salt content in the soil, so adding say fertilizer to your soil will change the reading of your resistive sensor but not your capacitive sensor. As such capacitive sensors are better than resistive sensors, but it can be a pain to make sure they are completely watertight. In my experience the often used nailpolish will dissolve over time as does laquer. The before mentioned PlastiDipis a good solution, but adds to the cost of the sensor. The resistive sensor is just much easier.

So what can we do to protect the resistive sensor against electrolysis?
You will read various ‘solutions’ for this:
“You have to feed it with AC”
Yeah, right.Let alone that most of the circuits to do that do not provide AC but just a DC Sinewave or some other form of pulsed DC which does not help at all
“You have to reverse the voltage”
Okay….. apart from the fact that this requires an extra pin, it also takes a lot of time sensitive programming.

There are better solutions:
Use decent galvanized bolts/nails of say 6mm thick and don’t give a fuck. After the growing season take them out, give them a scrub and use again. They will last pretty long.

Only apply a voltage and thus a current to your sensor when you need it.
You really do not need to know the moisture content of your soil every second of the day. Suppose you measure only 4-6 times a day and every measurement takes say 1 mSec. Then you only need to apply a voltage for 4-6mSec a day. That is a lot less electrolysis.
You can do this by feeding the voltage divider that makes up your sensor and pull up resistor simply from an extra pin of your microcontroller and set up a timer to drive that pin HIGH, read the value and drive the pin LOW once every 4-6 hrs. If you do not cherish the idea to use an I/O pin to feed a sensor, the circuits below will do the same. Obviously one should not set an internal pull up resistor when using this option.

soilmoisture sensor,High side switching with PNP transistor
Soilmoisture sensor,Low side switching with FET

There are purists that say you would still need to reverse the voltage for those 4-6 msecs as well, but come on.

The easiest though is to do away with metal alltogether and to use graphite rods. These are current conducting and not subjected to electrolysis or regular corrosis.
It is of course not possible to solder wires to graphite but wires can easily be attached with some heat shrink. The rods as shown here have a combined resistance of approx 10k.

A simple sensor with graphite rods

2 thoughts on “Soil moisture sensors: problems & solutions”

  1. There are problems of measuring liquid conductance with using a DC voltage and resistance measurements. You acknowledge the electrolytic effects on the electrodes as the primary issue. “Polarization” effects are a major and well-known issue and this will cause reading errors. If you put graphite electrodes into a weak salt solution and watch the current vs time as you switch ON the DC voltage, you will observe a spike and then a considerable drop in current (“conductance”); this is due to electrode polarization by ion mobility. This is the reason for reversing the voltage even with platinum or carbon electrodes. Orion, the maker of scientific grade conductivity electrodes has a section on this effect – “From Ohm’s Law, the conductance =current/voltage. Actually there are many practical difficulties. Solutionconductivity is due to ion mobility. Use of DC voltage would soon deplete theions near the plates, causing polarization, and a higher than actualresistance. This can be mostly overcome by using AC voltage, but then the instrument designer must correct for various capacitance and other effects.”
    So.. you could make your article more useful and accurate by acknowledging and discussion the reasons for the voltage reversing drive instead of discounting this method.

    1. Thank you for your input. In fact the conductive method doesn’t measure moisture but ions, hence the method is an approximation for soil moisture to begin with. What I do in this article is discuss the various possibilities of measuring soil moisture. I do not think I am ‘discounting’ AC measurements, I just describe the practical problems of AC. This is about practical solutions for DIY-ers, not for the owners of a commercial Orion probe. Certainly the things you mention do happen, but it is negligible in the grand scheme of things. Sure it can be done by using 2 pins to feed the probe, take the measurement and then reverse the polarity for a similar time. It is much simpler to just take the measurement and switch off the current. a few mSec on a 24hr period is not going to make much difference

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.