rasclatt-dot-com / ESP32-Plant-Waterer-for-ESPHome

Simple ESPHome plant watering device built for Home Assistant control and automation.
MIT License
71 stars 6 forks source link

ADC Raw Values #3

Open MRobi1 opened 5 months ago

MRobi1 commented 5 months ago

Hey, not sure if you still use this, I'm wondering if you remember how you viewed the raw values from the ADC sensor to determine the filter values?

    filters:
      - calibrate_linear:
        - 1.795 -> 0.0
        - 1.43 -> 100.0

I just finished watering to runoff and have the xiaomi plant sensor right beside the m5stack sensor. The xiaomi sensor is reading 82%, m5stack is reading 5%.

rasclatt-dot-com commented 4 months ago

These values were based on recommendations in other projects in m5 community.

My initial testing noticed that the m5 capacitive sensor (and similar capacitive sensors) take some time to register changes in soil moisture.

This is due to the nature of how capacitive sensors work, also how quickly the soil absorbs the moisture.

This is why I configured long delays between initial trigger of the pump before allowing the pump to run again to allow time for the readings to catch up, (and avoid flooding my plants).

nborson commented 3 months ago

The xiaomi sensor is reading 82%, m5stack is reading 5%.

@MRobi1 wow, that's a big difference! I didn't have another sensor to compare with, but using the calibration values in the sample code, my new sensor gave me ranges of 2% (in air) to 27% (in fairly dry soil before watering) to 73% (after watering thoroughly and waiting overnight), which passes the reality check. Edit: the reading in soil jumped from 73% to 96% after re-calibrating to - 1.53 -> 100.0. Could you be measuring the wrong pin, or using a different attenuation: value, or using 3.3V rather than the 5V output on the Atom's Grove connector?

how you viewed the raw values from the ADC sensor

Commenting out unit_of_measurement: "%" and - calibrate_linear: filter -- and increasing the accuracy_decimals -- gives the raw voltage at the pin.

sensor:
  - platform: adc
    pin: 32
    name: ${plant_1} Soil Moisture Value
    attenuation: auto
    id: plant_1_soil_moisture
    accuracy_decimals: 3
    # unit_of_measurement: "%"
    update_interval: 10s
    icon: mdi:flower
    filters:
    #   - calibrate_linear:
    #     - 1.795 -> 0.0
    #     - 1.43 -> 100.0
      - sliding_window_moving_average:
          window_size: 12
          send_every: 3
          send_first_at: 2
      - median:
          window_size: 12
          send_every: 3
          send_first_at: 2

I bought two new m5stack U101 sensors (the ones @rasclatt-dot-com describes), and I found these voltages from them on the Atom lite with attenuation: auto:

V (Min/Max/Avg) Sensor 1 Sensor 2 Notes
Air 1.786/1.787/1.7865 1.789/1.792/1.7905 The difference between sensing dessicated air with ~10% RH vs room air with 47% RH was at most 0.001V. See screenshot below
Water 1.529/1.532/1.530 1.528/1.532/1.530 Immersed the probe in water to the top of the sensor strip
Vs. sample code (dry/wet) -0.47%/+6.99% -0.25%/+6.99%

History Screenshot Screenshot of History in Home Assistant shows raw Sensor 2 voltages while the sensor is in dessicated air (left half of graph) and 47% RH room air (right half of graph). The average is just 0.25% lower than the calibration voltage in the sample code.

Notes

Conclusions