Soil moisture sensors

Ok that sounds exactly what I am looking for. Do you have any walkthroughs for setting them up I see they have some info on the site but I’m not really seeing a walkthrough? Kinda wish it was zigbee sense the wifi signal is weakest in the garden and I am not sure how good the wifi antenna will be on these but I’m guessing it will be fine. I can’t find any real details on the store, any idea where they are located? Also have you tried waterproofing it? Documentation on store says you must add protection to the whole sensor? does that mean the part that’s in the ground, any idea. I guess I’ll email them and ask. I would guess either some silicon sealant and or marine 4:1 heat shrink tubing would go along way in waterproofing.

Thanks again.

thanks for the info but I do have some smaller plants, I think I am going to go with what Wally is suggesting for a sensor. If you are having issues with power drain, I would look into connecting a solar panel to them with a rechargeable battery. I’m sure there is an easy to follow guide somewhere to make it safe for the sensor and battery.

Other than the waterproofing do you think there is any real benefit to the sensor you linked VS the one WallR suggested? Both seem to be what I am looking for but WallyR’s suggestion seems to be easier to get going/setup? I really do appreciate any input you have.

I have programmed my own code for it, so I can use ESP-Now, so no walkthrough available.

It should be quite easy, because the code to read the moisture value is just this:

#define NO_OF_SAMPLES   64          //Multisampling
const adc_channel_t      MOISTURE_CHANNEL    = ADC_CHANNEL_8;     // GPIO9
uint32_t readMoisture() {
    uint32_t adc_reading = 0;
    //Multisampling
    for (int i = 0; i < NO_OF_SAMPLES; i++) {
        adc_reading += adc1_get_raw((adc1_channel_t)MOISTURE_CHANNEL);
    }
    adc_reading /= NO_OF_SAMPLES;
    return adc_reading;
}

There is Arduino code samples on their store page and there is also notes about the waterproofing.
I would probably connect the USB-C cable in your situation and then just seal all holes in the case, but test that ESPHome can reboot automatically after an update, so you do not need to break the seal all the time you need to update.

The WiFi signal seems decent, but I switched to ESP-Now to get a better signal and also to lower the battery drain, since I use them indoor and running on battery only.

That’s a big “other than…”.

My recommendation is the only one rated for outdoors. As noted in the post I linked to I’ve used a couple of other indoor options that were custom waterproofed for outdoors. Save yourself some hassle, they don’t last.

It uses ESPHome which is also very easy to set up.

ok I am a bit lost, I just received the April soil moisture sensor but I am not sure where to go from here I have esphome installed on HA but I guess I need HTTPS so instead I am have to go to the web.esphome to flash except it never sees anything is conned to the computer I know you said you are using ESP now, did you have any issues with not seeing the device. I had happened to have a 8266 that I tested to see if the issue is my setup and my computer found the 8266 right away so my setup should be good. I tried to put the soil sensor in the download mode but it still doesn’t see the device… maybe I am just not putting it in download mode correctly? what is your process to putting it in download mode I am wondering if this is my issue? what OS did you use Im on windows 11, I am wondering if I need to install some drivers. The web.esphome sugest this as a step:

Make sure you have the right drivers installed. Below are the drivers for common chips used in ESP devices:

  • CP2102 drivers: Windows & Mac
  • CH342, CH343, CH9102 drivers: Windows, Mac
    (download via blue button with icon)
  • CH340, CH341 drivers: Windows, Mac
    (download via blue button with icon)

I think I use 2102 drivers, but there are two types of drivers, because there are 2 types of chipsets.
One chipset is the original one and one is a copy. The copy earlier just used the original drivers, but the manufacturer of the original chipset got tired of the competition from copies, so they changed the drivers so the newer ones only work with the original chipset.

You might have to find drivers that work with the chipset copies.

thanks, I figured out the problem… the usb c cable they sent with the sensor was just power and not data WTF! lol super lame

LOL, I did not get a cable with mine, so I used one I had already that was data also.

I just ordered a vh400 along with some valves, I just got a new esp32 c-6 that I planned/ plan to use for the soil sensor and any project using esp32 because of the wifi efficiency. Only thing is its not supported yet in esphome so until the esp32 c6 -6 is supported I have some spare esp8266 I can use (if they will work ok). Would using a esp8266 change anything about your code or how well the sensor worked? if using a esp8266 is going to be a hassle with the vh400 I can just get a esp32 that is supported in esphome.

any updates to your code or advice for working with the vh400?

No changes. It has been working faultlessly. The probe is buried horizontally at root level in my lawn.

I was wondering if I could bury it, I have to say based on the photos I thought the probe was longer.

I have been trying your code and I am getting and incorrect readout of the “Lawn moisture” it just says 64% when fully submerged and voltage is reading around 3.0v-2.995. I am getting a reading of the voltage correctly af far as I can tell. Looking at the calibration code shouldn’t 3.0v be 71%? I would think that should be 100% if 3v is the peak voltage. I’m a beginner so IDK im kinda lost.

I see in the logs it says update every 60 sec but I don’t see anything that relates to that in your code?? What am I missing? Id like to update at least every 10 sec. I changed the voltage update interval, just not sure about moisture.

UPDATE
Now lawn moisture is showing 72% so I guess that is equal to the 3.0v in the calibration settings. Except how do I get lawn moisture to read the correct 100% seems your code calibrates it to a max of 72% if I am understanding it. Do I need to change the calibration?

This is my current ESPHome sensor:

sensor:   
  - platform: adc
    pin: GPIO36
    name: "Lawn Moisture Raw Voltage"
    id: raw_v
    unit_of_measurement: "V"
    device_class: voltage
    attenuation: 11db
    update_interval: 10s

  - platform: template
    name: "Lawn Moisture"
    unit_of_measurement: "%"
    device_class: humidity
    state_class: measurement
    lambda: |-
      return (id(raw_v).state);
    filters:
      - calibrate_polynomial:
         degree: 5
         datapoints:
          # Map from sensor -> true value
          - 0.1 -> 0
          - 0.2 -> 1
          - 0.3 -> 2
          - 0.4 -> 3
          - 0.5 -> 4
          - 0.6 -> 5
          - 0.7 -> 6
          - 0.8 -> 7
          - 0.9 -> 8
          - 1 -> 9
          - 1.1 -> 10
          - 1.2 -> 12.5
          - 1.3 -> 15.004
          - 1.4 -> 19.812
          - 1.5 -> 24.62
          - 1.6 -> 29.428
          - 1.7 -> 34.236
          - 1.8 -> 39.044
          - 1.9 -> 42.118
          - 2 -> 44.75
          - 2.1 -> 47.382
          - 2.2 -> 50.014
          - 2.3 -> 52.646
          - 2.4 -> 55.278
          - 2.5 -> 57.91
          - 2.6 -> 60.542
          - 2.7 -> 63.174
          - 2.8 -> 65.806
          - 2.9 -> 68.438
          - 3 -> 71.07
      - sliding_window_moving_average:
          window_size: 12
          send_every: 12
          send_first_at: 12

If you don’t want the voltage you can skip the template sensor and apply the filters and unit directly to the ADC sensor.

There are two things that affect the update rate, the ADC update interval (10s) and the sliding window moving average (12 samples) so 12 x 10s = 2 minutes. Feel free to adjust either or both as you see fit. Though honestly even that is faster than needed. Soil moisture does not change that quickly unless you get a sudden tropical storm after weeks of dry.

In Home Assistant I convert this to soil saturation (soil can not hold 100% water like your glass because it is partly dirt).

This is the template sensor:

template:
  - sensor:
      - name: "Soil Saturation"
        icon: "mdi:water-percent"
        unit_of_measurement: "%"
        state_class: measurement
        state: "{{ (100 * states('sensor.lawn_moisture')|float(0) / 63)|round(1) }}"
        availability: "{{ states('sensor.lawn_moisture')|is_number }}"

This too could be implemented in ESPHome. However I chose to do it in home assistant as it is easier to change (though again that could be done with an input_number brought into ESPHome as a sensor).

Note the number “63” was found by experimentation. It is the maximum reading I ever saw of sensor.lawn_moisture after very heavy soaking rain. I had to update it a few times as the soil settled around the sensor. This value is highly dependant on soil type and compaction and you will have to change it depending on your soil. You could get a good start by soaking the sensor installed in the lawn with a hose.

There are videos on the probe website about the moisture holding capacity of soils vs absolute % moisture.

This sensor will read 100% (or very near to it) when the soil holds as much water as it can.

Ah ok thanks I’ll check that out with the templet. I am using the sensors to turn on/ off water to my potted plants and some of them are small so an extra minute in the update might mean water is draining out.

How did you figure you the percentage with the voltage calibration?

That “63” setting is basically the max water holding capability of the soil…for me I plant in mostly potting soil(at least the ones I want to use the moisture sensor for), so I guess I can drench a test pot filled with potting soil and see what the value is.

I do want to add that templet into ESPhome so I guess I’ll look into the input_number.

Thanks again

Also what do you think of these, I might test them out if I could figure out the wiring. It says it’s water proof and at only $15 each is a lot cheaper if I adds up as I want to use a bunch. I’d think programming should be similar, not sure if there is much difference between the capacitive boards or not.

Plantmate Capacitive Soil Moisture Sensor 3.3V Compatible with Arduino (2-PAC) https://a.co/d/10nyzxD

The calibration data is listed on the probe website.

Does anyone have experience using this Tuya-based soil moisture sensor? It uses three probes, so not sure if it’s capacitive or resistive measurement. Currently $27 after checkbox coupon.

image

Amazon.com: ZIGBEE Garden Soil Moisture & Temperature Meter,Sensor-Outdoor Waterproof,Plant Humidity Tester,Compatible with TUYA Smart APP : Patio, Lawn & Garden

They’re awful… horribly inaccurate and ones with older firmware can drain the batteries in a day. They also can’t be updated over the air, so if you get a bad firmware version you might as well just chuck it in the bin.

@dgaust Thank you for helping me dodge that bullet. I’ve purchased so many disappointing zigbee devices lately. I’m reluctant to buy another without some real user feedback. The large number of obviously fake Amazon reviews in this segment is daunting.

Perhaps, do you have an opinion on this Bluetooth version? It’s been around forever, and it has an integration available. But similar looking devices are offered by dozens of vendors, so who knows if any work as promised. Some call in Mi Flora, but goes by many other names. image

If they have two or more sensor legs, then they are almost for certain resistive sensors.
Resistive sensors will decay and pollute the soil.
A capacitativ sensor will not, because it requires no direct contact with the soil.

A resistiv sensor might offer extra values, like nutrition value and acidity, but those are varying depending on the moisture in the soil, so they are extremely imprecise due to the fluctuations. In other words not worth looking at.

I have 9 of these and they have been really good. None have caused any trouble in years of use. They batteries have lasted ages too.

2 Likes