I am having issues getting correct readings from my 12 sensors. i am assuming it is something in my lambda or attentuation? i have them reading as percentage and then template sensors for reading raw voltage value for calibration. they are all reading at the same values which are
[D][sensor:094]: 'Plant Moisture 9 Raw Voltage': Sending state 0.00066 V with 2 decimals of accuracy
and
[D][sensor:094]: 'Plant Moisture 8': Sending state 79.52293 % with 2 decimals of accuracy
this is sections of my code
sensor:
- platform: adc
pin: GPIO3
id: adc_sensor
attenuation: 11db
update_interval: 60s
- platform: cd74hc4067
id: adc_1
name: Plant Moisture 1
number: 0
sensor: adc_sensor
accuracy_decimals: 2
unit_of_measurement: "%"
device_class: humidity
icon: "mdi:water-percent"
filters:
- lambda: |-
float moisture_dry_soil_value= 3.0000;
float moisture_wet_soil_value = 0.25488;
if (x > moisture_dry_soil_value ) {
return 0;
} else if (x < moisture_wet_soil_value) {
return 100;
} else {
return (moisture_dry_soil_value - x) / (moisture_dry_soil_value - moisture_wet_soil_value ) * 100.0;
}
- platform: cd74hc4067
id: adc_2
name: Plant Moisture 2
############# Continue for other 11 sensors #############
- platform: template
name: "Plant Moisture 1 Raw Voltage"
lambda: |-
float voltage = id(adc_sensor).raw_state / 4095.0 * 3.3;
return voltage;
unit_of_measurement: "V"
accuracy_decimals: 2
- platform: template
name: "Plant Moisture 2 Raw Voltage"
lambda: |-
float voltage = id(adc_sensor).raw_state / 4095.0 * 3.3;
############# Continue for other 11 sensors #############
globals:
- id: current_channel
type: int
restore_value: no
initial_value: '0'
- id: sensor_1_value
type: float
restore_value: no
initial_value: '0.0'
- id: sensor_2_value
type: float
restore_value: no
############# Continue for other 11 sensors #############
cd74hc4067:
id: cd74hc4067_hub
pin_s0: GPIO18
pin_s1: GPIO19
pin_s2: GPIO20
pin_s3: GPIO21
any help would be greatly appreciated!