Just to close the issue a couple of things.
I had to put a delay before updating ADC, as the values recorded were incorrect. The final configuration is:
switch:
- platform: gpio
pin: GPIO14
name: "VDD_s_humedad"
on_turn_on:
then:
- delay: 2s
- component.update: adc_0
sensor:
- platform: adc
pin: A0
name: "Humedad del suelo"
update_interval: 6h
accuracy_decimals: 0
id: adc_0
filters:
- lambda: return 100.0 - x*100.0;
and the log:
[17:06:30][D][switch:021]: ‘VDD_s_humedad’ Turning ON.
[17:06:30][D][switch:045]: ‘VDD_s_humedad’: Sending state ON
[17:06:32][D][adc:056]: ‘Humedad del suelo’: Got voltage=0.35V
[17:06:32][D][sensor:092]: ‘Humedad del suelo’: Sending state 65.42969 V with 0 decimals of accuracy
[17:06:35][D][switch:025]: ‘VDD_s_humedad’ Turning OFF.
[17:06:35][D][switch:045]: ‘VDD_s_humedad’: Sending state OFF
What I would like to do is to filter out the values obtained with the sensor not powered, wich are always in the range of 0,01V (90 after the conversion)
I’ve tried “on_value_range” and several lambdas formulas, but I always get compilation errors.
eHc