I have recently assembled the components for a Soil Capacitance Sensor, which I have configure using EPSHome. I am pleased to announce that the sensor appears to be working and it provides an output which changes depending on the moisture level.
The issue I am having is the output it provides is in volts and I would like to output this in a more friendly reading as a percentage.
I have done some experiments and have determined that when submerged in water the output is 1.31v and when the sensor is dry it is 2.79v
I believe I can achieve the outcome I am looking for by using a template sensor with a lambda filter however despite my best efforts to research how to achieve this I haven’t been able to locate anything workable.
I would like my lambda to output 100% if the sensor reports a reading of 1.31v or below, and 0% if the sensor reports a reading of 2.79v or above. Then based on these min and max values calculate a percentage value for any reading in-between.
- DFRobot Analog Capacitive Soil Moisture Sensor
- DFRobot FireBeetle ESP32 IoT Microcontroller
sensor: - platform: adc pin: A0 name: "Soil Moisture volts" id: SMV update_interval: 1s attenuation: 11db - platform: template name: "Soil Moisture" id: SML lambda: ' '
Would appreciate any assistance.