Soil moisture sensors

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

As an FYI,

If distance/reach is an issue, one may consider a LoRa based Soil Sensor.

There is a community using these. I have only recently been trying these out, so can not yet attest to how well they can hold up to weather, water, etc. but they have been sprayed with a waterproof coating, which I believe is the manufacturer’s own special sauce.

So after all the discussion what is the best quality/price one?

@sparkydave quick question about this bluetooth sensor:

I have the gl-s10-bt-proxy (The Best Home Assistant Bluetooth Proxy: GL.iNet GL-S10 | Blakadder's Smarthome Shenanigans) with ESPHome, and is this sensor working with the Xiaomi BLE integration?
Thank you!

Yes, it works with the Xiami BLE integration. But make sure you select the bluetooth version for $20. The cheap for $6 doesn’t have BT.

1 Like

Thank you! Just order it from aliexpress.

BLE Sensor arrived! Fw 3.3.6 Immediately discovered by HA, Bluetooth range seems very high using gl-s10 proxy. Seems a good purchase.

1 Like

Question (if youre still around) - my computer recognizes it on ESPhome web, but everytime I try to flash it with ESPhome I get the error:

Failed to initialize. Try resetting your device or holding the BOOT button while selecting your serial port until it starts preparing the installation.

I tried to put it in Download mode (not sure how to tell if Im doing it correctly) but no luck. For Download mode I follow these steps:

Press and hold IO0
Plug USB cable. Wait seconds for boot
Release IO0

cc: @WallyR

What it?
Each board may have a different approach on how to get it into flash mode, so knowing the board is important.

On the chip I see Espressif ESP32-S2-SOLO or 21098-ESPS2SOLO

On the board I see SOIL_SENSOR_ESP32S V03

Apologies in advance, as Im new to setting up these boards. Hopefully this is what you need, let me know otherwise.

And for further context, I have the battery unplugged and removed the board from the case so the USB cable is secured into the port. Also made sure Im using a data cable and can see it as a USB serial device.

And for further context, I have the battery unplugged and removed the board from the case so the USB cable is secured into the port. Also made sure Im using a data cable and can see it as a USB serial device.

EDIT: Okay turns out ESPHome web doesnt work well with this board so I’m going to use Adafruit ESPTool to flash a bin. I will try to use ESPHome manual download to create the BIN file.

Any good projects for ESPHome I can reference for this sensor?

cc: @WallyR @Ksully86 if you would know.

cc: @WallyR @Ksully86 if you would know.

I used ESP flasher when I flashed mine, but it was ages ago, before the ESPHome web flasher became available.
I will see what is possible when I get back home next weekend.