I have a Raspberry Pi project that has three soil moisture sensors. I take a moisture sample every minute. After about a month I started to get bad readings. On further inspection I noticed that my soil moisture sensors were corroded to the point where they were giving false moisture readings (it completely corroded the metal contact away). It corroded all the sensors equally.

Is soil moisture sensor corrosion normal? If so, how do you prevent this? Is it just a cheap sensor? What is recommended?

Soil Moisture sensor

The sensor I bought can be found here: Amazon - XCSOURCE 5pcs Soil Moisture Sensor And Automatic Watering System for Arduino TE215.

  • 4
    Some people claim that using AC to do the measurement helps too.
    – PlasmaHH
    Commented Jun 8, 2017 at 7:34
  • 3
    I have read numerous sites claiming that reading capacitance instead of resistance is the preferred method that also reduces corrosion.
    – user9993
    Commented Jun 8, 2017 at 8:48
  • 5
    If you want your sensor to last, use an insulated sensor that measures moisture content through capacitance, which doesn't need direct electrical contact to the soil. This is a good one: vegetronix.com/Products/VH400
    – Mels
    Commented Jun 8, 2017 at 12:36

7 Answers 7


If you think about what is happening you have a very hostile environment for electronics (moisture - sometimes large amounts, soil PH and electrical current induced electrolysis)

The Hookup Guide for the SparkFun Soil Moisture Sensor includes the following:

One commonly known issue with soil moisture senors is their short lifespan when exposed to a moist environment. To combat this, we’ve had the PCB coated in Gold Finishing (Electroless Nickel Immersion Gold).

Another way to extend the lifespan of your sensor is to only power it when you take a reading. Using a digital pin set to HIGH on an Arduino, for example, is an easy way to accomplish this. If you wish to power the sensor with more than a digital pin on your microcontroller can provide, you could always use a transistor.

So yes this is normal, I can't speak to the longevity of the sparkfun sensor, but the extra lifetime afforded by the "Gold Finishing", may well be worth the extra cost for your use case. As others have stated powering the sensor only when taking a reading will also increase the lifetime of the sensor. I would also question the need to take a measurement every minute. Does your soil moisture really change significantly over that short a time period?

I just saw this new method (covered in step 5) using graphite rods (pencils) to make long lasting probes.


Yes, this is normal for a DC drive configuration. You're effectively setting up an electrolysis experiment where the copper atoms on the positive electrode are being ionised, transported via the soil's water content across to the negative electrode where they are being deposited and returning to being copper atoms. This explains why the negative electrode looks surprisingly clean for having been buried - the top layer of atoms are recently deposited and likely very pure.

To get around this, there are a few things you can do. Gold plating is a good start, but it will need to be thick and consistent (even an atomic hole will allow access to the underlying copper and eventually this will get eroded). Most ENIG plating on PCBs is to ensure SMD pad flatness and minimise corrosion during storage - you would need a "hard gold" plating for long term use and even then eventually it will fail.

The best approach is to use an AC drive. Here, the electrodes swap from being positive to negative frequently during use. Because of this, ions that get transported and deposited in one half-cycle will be returned across and redeposited in the next half-cycle (where the polarity will be reversed). Net result is no overall electrolytic corrosion (and actually a partial self-cleaning function). Most capacitive sensing schemes are net-zero DC and so doing cap sensing as opposed to resistive sensing on the electrodes will likely help, as others have suggested.

This EE Stackexchange Q&A goes into some detail on drive schemes and a discussion of AC circuits. The way I have done it in the past is to use an astable multivibrator to drive the two electrodes with an AC waveform and then measure the DC input current to the multivibrator and calibrate that against moisture - but I am sure there are more elegant solutions out there if you Google enough.

One last point - if you're using an AC scheme, you should be powering the electrodes continuously to maintain the self-cleaning function (unpowered copper will eventually corrode in soil). With a DC scheme, powering only when needed will reduce the speed of corrosion (as electrolytic corrosion will be faster than that of unpowered copper) but it will not prevent it in the long-run.

  • 1
    Just a thought: Can't you guys use something like Titanium as the sensor metal? Ti resists corrossion even in hot brine. Or is Ti unsuitable as a sensor? Commented Jun 9, 2017 at 5:19
  • 3
    +1 for much more detailled explanation + very concrete tips for fixing than the accepted answer. I haven't thought it through and haven't read up on how the sensor is connected, but couldn't you hack a very simple "ACish" solution: not real AC (as in sinoid curve), just toggling the two contacts from VCC to GND and back again. Synchronous of course. The actual sensing only needs to be done when a parcitular contact is "on", of course, to make it easier. So in regards to sensing it stays DC, but in regards to electroplating the anode it switches around.
    – AnoE
    Commented Jun 9, 2017 at 11:36
  • Square wave AC as you describe, @AnoE, will work just fine. However, care must be taken to ensure that the potential to earth (real, actual earth - the earth you are putting the probe into) goes positive and negative. If the ground connection of your drive circuitry is connected to earth, the mean voltage at each electrode will be somewhere between the positive switching voltage and earth (half way if the duty cycle is 50%). One way to overcome this is AC-coupling the output drives via series capacitors - another would be using a transformer to couple the output.
    – stefandz
    Commented Jun 9, 2017 at 15:30
  • Re: Ti as a sensor, @curious_cat - sounds possible. Also sounds more costly than an AC coupled direct contact sensor or an insulated capacitive sensor as suggested by Mels under the main question.
    – stefandz
    Commented Jun 9, 2017 at 15:36
  • Truy, @stefandz, I was more thinking about potted plants anyways. :D I guess that is an implementation detail most electronic guys don't face too often.
    – AnoE
    Commented Jun 9, 2017 at 16:52

Yes, it's normal.

One electrode (the anode) will oxidise.

That said, it shouldn't happen so quickly. I guess you have the sensor powered constantly. That means you always enable corrosion.

What you can do it so make sure there is current running to the sensor only when you take a reading from it. This will pause corrosion in between the measurements, and make your sensors last longer.


This recent Preventing corrosion on YL-69 might answer your question to at least some extent I think. It reminds users of the sensor to power on the sensor only for short periods of time in order to avoid electrolysis and thus corrosion when you are running it on a constant current.


Sand it a bit with grain 2000 and solder a thin layer of lead-free solder onto it. Do this every few months. The stuff underneath is glassfiber, just be careful around any IC.

I'm much in favour of the idea of only powering a moisture sensor briefly, and then turning it off until its needed again.


To update @Mels comment, there are a number of hobbyist capacitive sensors now, these do not need/have exposed electrodes:

As mentioned in the other answer, ENIG only slows down the process, see http://homecontrols.ch/gardening.php for photographs of this.

I think all of those capacitive ones have unsealed edges on the PCB with the possible exception of the Catnip/wemakethings one. It might be worth a bit of DIY sealing for extra life. Instructables: Waterproofing a Capacitance Soil Moisture Sensor shows adhesive-lined heat shrink and nail polish used to protect the electronics on the sensor.


The named capacitive sensors are all copies from these project: https://www.mikrocontroller.net/articles/Giess-o-mat

All copies have the same problem: They doesn't have the right coating on the pcb. They just having the soldermask, which is the wrong solution: https://hackaday.com/2022/03/02/soil-moisture-sensor-coating-lessons-learned-the-hard-way/

Here is the shop, which sell the original sensors WITH the polyurethan coating: https://www.ramser-elektro.at/shop/bausaetze-und-platinen/giesomat-kapazitiver-bodenfeuchtesensor-erdfeuchtesensor-mit-beschichtung/

I hop, is will help some people ;-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.