Hi everyone,
I got an analog Capacitive Soil Moisture sensor.
This sensor when dry gives me value of 530, when in water I get the value 220.
Does anyone knows how I can get an percent value in Home Assistant. between those two values?
Hi @Marcmk. I am reasonably sure that you can achieve the result you want by using a very good solution I found here which was suggested by @nickrout in a discussion started by @Craggy_h
The solution was to help with a discussion about tank level as a percentage but I believe your needs are the same.
Nick put forward that the maths was like this:
Percentage = constant - sensor value x inverted slope
So…The two values you need to calculate for your sensor would then be:
Constant = dry value x inverted slope
Constant = 530 x (-0.3225806 x -1)
Constant = 530 x 0.3225806
Constant = 170.967718
So in your case you then have to put that into a value template:
value_template: “{{ (constant - states(‘sensor.your_sensor’) | float * slope) | round(0) }}”
Hi,
I tried also this solution but I get no real value calculation by using the formular.
I have an analog voltage value which should generate an -90 up to +200 value
the voltag signal is 0-3V but I use analog values just from 0 up to 1,46V
so:
analog value 0 should be -90
analog value 146 should be +200
I get Slope 1,327 but get no real values for Constant (0x???). Can someone give my an Idea what I’am doing wrong.