#################### 太阳能水温传感器 ####################
- platform: ntc # 》水温检测参数《
sensor: resistance_sensor #
icon: mdi:sun-thermometer-outline
calibration:
b_constant: 3435 #NTC的B值
reference_temperature: 25°C #NTC标称温度参数
reference_resistance: 10kOhm #NTC标称温度阻值
name: "solar_temp"
#device_class: "battery" #更改设备类型
accuracy_decimals: 1 #更改小数点位数
# Example source sensors:
- platform: resistance
id: resistance_sensor
sensor: solar_temp
configuration: DOWNSTREAM
resistor: 5.024kOhm #分压电阻阻值
#name: "9solar_水温阻值"
- platform: adc
id: solar_temp
pin: GPIO1
name: "solar_temp_adc1"
update_interval: 1s # never update
accuracy_decimals: 2 #更改小数点位数
attenuation: 11db
filters:
- sliding_window_moving_average: # 滤波
window_size: 15
send_every: 15
#################### 太阳能水位传感器 ####################
- platform: adc
id: solar_water_level
pin: GPIO4
name: "solar_water_level_adc4"
update_interval: 1s # never update
accuracy_decimals: 2 #更改小数点位数
attenuation: 11db
filters:
- sliding_window_moving_average: # 滤波
window_size: 30
send_every: 15
- platform: template
update_interval: 30s
name: "solar_water_level"
unit_of_measurement: "%"
accuracy_decimals: 0
icon: mdi:cup-water
lambda: |-
float x = id(solar_water_level).state;
if ( x >2.43 ) {return 0;}
else if (x > 2.3 ){return 25;}
else if (x > 2.0 ){return 50;}
else if (x > 1.7 ){return 75;}
else {return 100;}
esp32C3主控,使用的是这种4芯水位水温传感器(内部就是电阻分压)采集ADC
水位:我就是采集不同的电压,然后划分不同阶段的水位(0% 25% 50%......100%),这个方法简单粗暴,但是精度不好,采集的电压会飘来飘去,在临界值就会在(例如50% 和 75%)一直跳变,如何做到像太阳能面板那样稳定???
水温:adc采集电压----->resistance----->ntc --->最后得到温度(这部分代码是抄网上的,像套娃一样,得到的温度还不准)
|