Hi all,
I would like to filter an adc value in this way:
If the value of the ADC is above 2 volt and below 5 volt then give me back the value
else return zero
so I tried to find a solution in different ways but non of my ideas was right.
The last try was this
#################################################
# ADC ACQUISITION MANAGEMENT #
#################################################
#Acquisition of battery voltage - needed to check the residual charge
- platform: adc
pin: $battery_acquisition
name: "Voltage supply battery"
id: V_bat
attenuation: 11db
update_interval: 1s
filters:
- calibrate_linear:
- 0.0 -> 0.0
- 2.49 -> 2.74
- 2.99 -> 2.68
- 3.04 -> 2.71
- 3.08 -> 2.74
- 3.85 -> 3.14
- median:
window_size: 3
send_every: 4
send_first_at: 3
icon: "mdi:battery-medium"
- platform: template
name: "Battery voltage value"
id: battery_voltage_value
icon: "mdi:battery-medium"
on_value_range:
above: 2
below: 5
then:
- lambda: |
battery_voltage_value=v_bat;
When I compile I get the following error:
Compiling .pioenvs/irrigatore/src/main.cpp.o
/config/irrigatore.yaml: In lambda function:
/config/irrigatore.yaml:385:10: error: cannot convert 'float' to 'esphome::globals::GlobalsComponent<float>*' in assignment
red= id(v_bat).state;
^
*** [.pioenvs/irrigatore/src/main.cpp.o] Error 1
But it does not work.
Could you help me?