Soil moisture with ESPHome

Hello,

I would like to measure the soil moisture with ESPHome and an ESP8266 with the following soil moisture sensor.

my actual yaml code looks like that:

 name: esphome-web-255ca2
 friendly_name: Bodensensor 1

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "lSBpIKAtnWLJ3yWeIQ/kZ3/GAkX7JN5uBSAspQ0R1KY="

ota:


wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esphome-Web-255Ca2"
    password: "ouzEhpSXLZXs"

captive_portal:

sensor:
  - platform: adc
    pin: A0
    name: "Bodenfeuchte"
    update_interval: 60s
    filters:
    - multiply: 3.3

In Home Assistant it looks so:
image

If the sensor is not in the ground, I have approx. 1.8V, so that would be dry.
I think you should then water from 1.7V.

But I don’t like the way it looks, is there a better way?

Thank You

I am in the states, but I would love to get something that monitors soil moisture with my irrigation system…so I am certainly interested in this project. How do you keep them protected from the weather?

Welcome @Timo_76761. You might need to elaborate on this as it’s not so clear what you need help with to me.

Did you test the “wet” value in a glass of water? Then you should have the full range.

There’s lots of examples on the forum for converting the value to a percentage if you prefer it like that.

If you dig into this projects config you will find an example of that.

A better test would be a sample of soil from the yard that is saturated to the point of dripping through a colander. Different soil types have different water holding capacities.

2 Likes

Yeah I’ve been in the habit of glass of water during the build process (for initial hardware testing), and then setting my final 100% and 0% values from insitu saturation / dry tests a little later on.

1 Like

use after your Test a filter like:
my shows it in %

  - platform: ads1115
    multiplexer: 'A2_GND'
    gain: 4.096 #measures up to 4.096V default 6.144
    name: "ADS1115 Channel A2-GND DFRobot Prozent"
    update_interval: 10s
    unit_of_measurement: "%"
    state_class: "measurement"
    device_class: "moisture"
    accuracy_decimals: 0
    filters:
    -  calibrate_linear:
       - 2.87 -> 0
       - 0.353 -> 100
    - lambda: |
       if (x < 0) return 0;
       else return (x);
1 Like

I’m interested to find out how this sensor has stood up over the past year. Could you provide an update?

Did you keep the sensor submerged? I had a similar probe, but it deteriorated over time and I’m curious about how your probe is holding up.

Good Quality => V2.0 - DFRobot SEN0308

I have been using these for more than 2 years

I recently built a soil moisture sensor using an SHT31 sensor in a waterproof cable — sourced here: Amazon SHT31 cable sensors.

The system runs on a Lolin D32 (ESP32) powered by a LiPo battery, all housed in a weatherproof IP67 electrical box: Amazon waterproof electrical boxes.

To maximize uptime, I implemented a deep-sleep cycle in ESPHome. The device wakes every few minutes, samples temperature and humidity from the SHT31, transmits the data to Home Assistant, then immediately returns to deep sleep. In sleep mode, current draw drops to just a few microamps, allowing the sensor to run for weeks (Your mileage may vary depending on battery. I currently project getting 6 weeks) on a single charge.

I’m planning to add a 2 W solar panel in the next revision to keep the LiPo charged indefinitely, making it a fully self-sustaining outdoor node.

The ESPHome configuration is available here:
GitHub: Soil-Moisture Project

Using the SHT31 for soil humidity avoids the corrosion problems common with analog probes, while still providing accurate, repeatable readings. It integrates cleanly into Home Assistant for automations like irrigation control or soil dryness alerts.
This design balances low power usage, environmental durability, and reliable sensing—a solid foundation for long-term outdoor monitoring.

Can you give little bit details about the vapor permeable part of that probe?

Not really, It’s a generic sensor, probably a knockoff of the brand name Sensirion SHT31 . My understanding is that it is a polyester and teflon combination. It isn’t “Waterproof” it’s just “Water resistant.”

I have put it in water and it survived but I would be very hesitant to leave
it in a cup of water. The sensor would survive but I’m not so sure about the electronics inside.

The physical package is a 1 3/4" long cylinder with a membrane at the end.


Thanks for sharing.

Depends on that membrane and the sealing to the probe body.
Original Sensirion filter cap is made of polyester screen and teflon filter and it’s rated waterproof to 1m of water depth. Probably conservative.

This is the actual one I purchased
Taidacent - Amazon.com

Two options, take your dremel and open it or sink it to water tank for a week… :wink:
Seriously, magnifying glass could give better idea how the filter is sealed to the probe body.

I have updated this project with two new features. The sensor was using too much idle power during the sleep times. There is now a logic level MOSFET (IRLZ44N) in the power circuit stopping the power consumption.

The second feature is a capacitance moisture meter from vegtronix.