Soil moisture sensor

Enquiring about soil moisture sensor suitable for Pico preferably with quiik connector.

I see CE09438 but not sure if this is suitable with Pico due to voltage or adapter requirements.
Information on each product should include more information like adapter types and compatible products Pico, Pi, … as appears some systems can be adapted across multiple systems.

1 Like

Hi Steffan,

I had a look at the soil sensor you linked, the description mentions an operating voltage of 5V, so you’d need a voltage divider before going into a Pico ADC pin.

Alternatively, Sparkfun make a Qwiic-capable soil moisture sensor that works between 3.3V and 5V, so that’s fine for a Pico, but it only has an Arduino library, so you’d need to port it over to MicroPython or C SDK I2C commands:

https://github.com/sparkfun/Zio-Qwiic-Soil-Moisture-Sensor/archive/master.zip

1 Like

Hi @Steffan224686 I’ve built a soil moisture reader with RPi Pico and the DFRobot Moisture Sensor successfully - Soil Moisture Sensor (Arduino Compatible) Immersion Gold | DFRobot SEN0114 | Core Electronics Australia

With that moisture sensor I didn’t need to use a voltage divider which was handy, but I don’t think it has a quiik connector sorry.

Here’s a sample of my python code if you want to use it. Note my device outputs to a 7 segment display module, but I’ve removed most of that code for brevity.

from machine import Pin, ADC
import utime

sensor_moisture = ADC(26)

conversion_factor = 1023 / 65535

# ~150 in fingers
# ~615 in mouth
# ~700 in water

sensorVal = 0.0
strStatus = ""
while True:
    reading = sensor_moisture.read_u16()
    converted = reading * conversion_factor
    
    sensorVal = converted
    
    if converted < 320:
        strStatus = "BAD"
    else:
        strStatus = "GOOD"
        
    print(strStatus)
    
    print(str(reading) + " " + str(converted))
    utime.sleep(1)
2 Likes

I don’t know how this would apply to the Raspberry Pi Pico, but I had previously done a project with the BBC Micro:bit V1 Board, and could not find a moisture sensor within my budget. I discovered that by connecting 2 alligator clips to the 3V and Pin0 and 2 long steel nails, there is a way to read the moisture data coming from the nails when they are touching the soil.

Maybe this is helpful for you, and a way to save some money, however I do not know how to achieve this with a Raspberry Pi Pico, but I will edit this post if I find something useful.

2 Likes

Thanks Jacob for the code.
It explained the connections required and I have worked out that I cannot use adapters of the sensor (3 wires) to a quiik connection (4 wires)as the sensor requires connection to either ADC(26), ADC(27) or ADC(28) - one of three analogue digital converters (ADC) on the Pico.
The Quiik connectors connect to SCL9 and SDA8 instead.
Using your code I connected wires from

  • Sensor (Black) to Pico GND
  • Sensor (Red) to Pico 3V3
  • Sensor (Blue) to Pico GP26 (ADC26), GP27 (ADC(27), or GP28 ADC(28)
    altering the above code accordingly (sensor_moisture = ADC(26), …)
    In the diagram attached I tested out on ADC(27)

The other alternative I am looking at is adding in
Analog to Digital Converter - MCP3002 - to wire in the sensor to the Quiik connector on my SSD1306 display.

Code is good and gave the indicative values listed.
Thanks

2 Likes

SparkFun Qwiic Soil Moisture Sensor has Qwiic connector but could not find any library or documentation to connect it to pico.

1 Like

Any recommendations for LONG LASTING soil moisture sensors for use with the Pico?
I used the basic “Capacitive Soil Moisture Sensor v2.0” that came with the Plant_io kit; however, after a few months of work it now only gives me readings of 100% (even when in dry air).

I have found the following, but not sure if it’s any good or compatible:

(be sure to select the Model: “Waterproof & Capacitance Type”)

Many thanks!

2 Likes

Hi Axel
While ever you have any sort of voltage on a bit of metal in the ground you are going to have electrolysis or a migration of material from the soil to the metal or vice versa. It all adds up to what you might call corrosion . Even dissimilar metals when damp will develop a voltage like a battery.

This happens everywhere. Metal pipes in the ground have a voltage applied with a polarity that causes the migration to occur from the ground TO the pipe. This prevents the pipe material gradually disappearing. This is termed Cathodic Protection.

A similar effect will be between a ship’s hull and the sea water. In this case there are large Zinc blocks attached to the hull all around as Sacrificial Anodes. The zinc block disappears over time so saving the hull from extensive damage.

I am afraid the short answer is there is not a lot you can do about it.
Cheers Bob

3 Likes

Hi Axel,

Out of curiosity, did you leave the soil sensor connected to the plant_io system? The voltage should be shut off between samples to slow the rate that the sensor degrades.

You could also try coating the sensors in something like hairspray or more officially - conformal coating

2 Likes

Thanks heaps Bob. I guess I then need to look for a brand where probes are much thicker, and which could potentially be sanded down slightly wen they get a bit corroded?

1 Like

Hi Liam,
The sensor was connected to the plant_io system the entire time that it was in use (in the soil), and yes, this is programmed to only switch on briefly every 20 minutes.
I can try your hairspray suggestion when my new sensors arrive, but would this not insulate the connectors, and therefore stop them getting a reading?

1 Like

Hi Axel

Do you need a reading so often. After all soil moisture change is not something that happens every few minutes. If say you took a reading every hour that could potentially about triple the life span.

If the resistance type that would certainly be the case. Don’t know about the capacitance “Gravity” type that is linked above.

Or have a periodic planned replacement program.
Cheers Bob

3 Likes

Hi Axel,

We do have that DFRobot sensor in stock ourselves.

I found this investigation into protecting these sensors better from corrosion, conformal coating as @Liam120347 recommended is used here.

2 Likes

Hi Robert,
Thanks heaps for the detailed response.

1 Like

Good point on the timing. I will set it to every hour at least, possibly moving to every two hours. And, because I am using a larger plant pot, I will increase the number of seconds that the pump runs (max_time).

Also, I have just coated my recently arrived replacement capacitive tester with multiple layers of clear nail varnish (both the electronics and probe part) and it still works. The results were different, but I could compensate for this by adjusting the two last value in:
self.curr_sens = self.mf.normalise_x(moving_ave, 22_000, 30_500)

1 Like

Thanks heaps Jack,
I followed the steps in your link to try to water and corrosion proof my new probe.
Coating the “below ground” part of the probe with nail varnish did reduce the sensitivity of the probe, but I could compensate for this by adjusting the max and min values at the end of this line in Plant_io.py:
self.curr_sens = self.mf.normalise_x(moving_ave, 22_000, 30_500)

1 Like

Hi Axel

I don’t know anything about nail varnish but the “conformal coating” previously suggested is pretty much electrically inert. It is used to tropic proof PC boards successfully and also for sea going electronics. Can make life difficult when replacing components but by the time it is used things are usually very reliable and repairs are not often required.
Cheers Bob

1 Like