Soil moisture showing the same voltage 24/7

i have an esp 32 with a voltage soil moisture sensor and it always reports the same voltage… here is my yaml.

esphome:
  name: multi
  friendly_name: multi

esp32:
  board: esp32dev
  framework:
    type: arduino
    version: latest
# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "xxxxxxxxxxxxxxxxxxx"
mdns:
  disabled: false

ota:
  - platform: esphome
    password: "xxxxxxxxx"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.1.188
    gateway: 192.168.1.254
    subnet: 255.255.255.0
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Multi Fallback Hotspot"
    password: "xxxxxxxxx"

captive_portal:

sensor:
  - platform: dht
    pin: GPIO4
    model: DHT22
    temperature:
      name: "multisensor Temperature"
    humidity:
      name: "multisensor Humidity"
    update_interval: 60s
  - platform: wifi_signal
    name: 'WiFi Signal'
    entity_category: diagnostic
  - platform: uptime
    name: 'Uptime'
    entity_category: diagnostic
    unit_of_measurement: s


  - platform: adc
    pin: GPIO33
    id: esp_wassernapf_volt
    name: "soil Volt"
    update_interval: 900s
    accuracy_decimals: 5    
    unit_of_measurement: 'V'
  

  - platform: template
    name: "soil volume"
    id: water1
    unit_of_measurement: "gal"
    

    filters:
      - calibrate_linear:
          # 0.1v = 0ml
          # 1v = 1700ml
          - 0.06 -> 0.0 # empty
          - 0.1 -> 1.0 # half full  or 10 mL of water
          - 0.2 -> 2.0 # 20 ml -- full will be when the entire pad is covered  
    icon: "mdi:water-percent"
    update_interval: 1s
    accuracy_decimals: 1
    lambda: |-
      return id(esp_water_volt).state;   

web_server:
  port: 80





text_sensor:
  - platform: version
    name: 'ESPHome Version'
    entity_category: diagnostic
  - platform: wifi_info
    ip_address:
      name: WiFi IP Address
      entity_category: diagnostic
    ssid:
      name: WiFi SSID
      entity_category: diagnostic
    mac_address:
      name: WiFi MAC Address
      entity_category: diagnostic
    dns_address:
      name: WiFi DNS Address
      entity_category: diagnostic

You have better luck here, if you post your sensor and wiring as well.
And your log.

What voltage does your moisture sensor output?

With this config you are limited to a maximum of 0.95V:

See the attenuation setting if you need a wider input voltage range: Analog To Digital Sensor — ESPHome

it shows 1.039

Then you need to set the ADC attenuation option.

the sensor looks just like this sensor.

the sensor is wired directly to the esp32.
here are the logs for the espboard https://pastecode.io/s/ius217px

my full yaml https://pastecode.io/s/y1ib8r8v

  - platform: adc
    pin: GPIO33
    id: esp_wassernapf_volt
    name: "soil Volt"
    update_interval: 900s
    attenuation: auto ### <----- ADD THIS
    accuracy_decimals: 5    
    unit_of_measurement: 'V'

This will allow you to measure ~0.075V to ~3.12V.

If your sensor puts out more than 3V you will need a physical voltage divider. Or better yet an external I2C ADC that is actually linear (the ESP one is awful at the extreme ends of its range).

well that seemed to do the trick its showing a voltage of 2.46 so im guessing if i add water to that pot it should go up, or if i look tomorrow it should go down.

That’s water level sensor, I doubt you get good results for soil moisture…

1 Like