DIY
最近入手了净水器,担心漏水,所以想买水浸,看了下小米水浸50 多的价格直接劝退
昨天无意间想到ESP 的ADC 是不是就能实现,正好排针用来检测是不是可行,于是ESPHOME 简单配置了下测试没有问题
主要原理就是ESP 排针的5V 或者3V 电压可以通过水导通到ESP 的ADC引脚,通过电压值来触发水浸状态
演示
视频
ESPHOME 配置
substitutions:
device_name: kitchen_moisture
esphome:
name: ${device_name}
esp8266:
board: esp01_1m
logger:
api:
password: !secret api_password
ota:
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: on
web_server:
port: 80
sensor:
- platform: wifi_signal
name: ${device_name}_signal
update_interval: 1s
- platform: adc
pin: A0
id: voltage
name: ${device_name}_voltage
update_interval: 5s
binary_sensor:
- platform: template
device_class: moisture
name: ${device_name}
lambda: |-
float analog = id(voltage).state;
return analog > 0.5; #esp8266 adc最大只支持1v的电压,这里设置0.5v作为触发电压,esp32的adc我记得是最高3v,根据实际情况修改不改也行
text_sensor:
- platform: wifi_info
ip_address:
name: ${device_name}_ip
mac_address:
name: ${device_name}_mac
|