Capacitive soil moisture sensor

Is there support for the Capacitive soil moisture sensor in EspHome or are there plans for it.
I can’t find anything about it on esphome.io.

You just need to create a binary sensor and a sensor connected to the A0 pin

sensor:
  #connect VCC to 5V
  - platform: adc
    pin: A0
    name: ${devicename} Soil Moisture Value
    id:  soil_moisture
    accuracy_decimals: 1
    update_interval: 10s
    icon: mdi:flower
    unit_of_measurement: '%'
    filters:
      - lambda: |-
          if (x > 0.67) { 				// if over 0.7 volts, we are dry
            return 0;
          } else if (x < 0.28) { 			// if under 0.264 volts, we are fully saturated
            return 100;
          } else {
            return (0.67-x) / (0.67-0.28) * 100.0; 	// use a linear fit for any values in between
          }

binary_sensor:

  - platform: template
    name: ${devicename} Soil Moisture
    device_class: moisture
    #Change this value to determine desire wetness of soil
    lambda: |-
        if (id(soil_moisture).state > 35) {
          return true; 
        } else {
          return false; 
        }

4 Likes

Thanks, I ordered one and start testing as soon it arives.

Did it work?

Still waiting for the sensor, but I keep you informed.

Finaly arrived. I’m working with a ESP32 from AZ-DELIVERY. I can’t find the A0 pin. From what I uderstand it is on GPIO36. This is not on a pin on the outside. So I picked GPIO34. That seems to be A6. The log only displays 1.1 Volt. Wet or dry, it stays the same. Also on the sensor I measure this with a voltmeter. I have two sensors, but on both the same result. If I disconnect the yellow wire I’m reading 0 Volt.
My sensor is version 2.0.

I found the problem. I’m using a ESP32. You need to put in “attenuation: 11db” in the config.

2 Likes

Thanks mate, just used this thread to get my first one up and running, my wife is impressed!