『瀚思彼岸』» 智能家居技术论坛
标题: ESPHome驱动UART型雨量传感器 [打印本页]
作者: nbxzl 时间: 2023-10-1 23:11
标题: ESPHome驱动UART型雨量传感器
本帖最后由 nbxzl 于 2023-10-1 23:18 编辑
[attach]51903[/attach]
这种传感器也为孩子科技课做过,报警时播放语音模块,完成上交学校了。当然,如坛友所遇到的问题一样,就是不能长时间在潮湿环境中使用,线路板表面容易腐蚀损坏。
最后找到一款型号为RS200的传感器,其常应用于安防系统中的室外高档摄像机上,用以检测镜头前面的玻璃表面是否有雨水,为驱动雨刮器提供依据等
[attach]51904[/attach]
[attach]51917[/attach]
[attach]51916[/attach]
[attach]51905[/attach]
需要注意的是,采购厂家淘宝卖的模块不配数据线,需要自己另配4P 0.8间距的插头线
[attach]51906[/attach]
[attach]51907[/attach]
传感器表面距离与玻璃最外侧4mm,不与雨水直接接触,实际制作中我把整个模块用有机硅1029绝缘电路板灌封胶密封在玻璃上,胶透明度极高,胶体固化后透明软性,不损坏线路板,也容易清除。
[attach]51908[/attach]
找出一块黑色玻璃触摸86空白面板,在上面留出需要的位置,用热熔胶依次固定小杯和传感器模块(提示:1029透明胶的渗透力极强,正式用之前在别的地方先做下测试),位置要求:RS200 模块正面“PCB 表面”到“玻璃外表面”的典型距离为 4.0mm(可调),玻璃与柔性透明光学材料的厚度可适当调节,例如:若玻璃厚度为 1.5mm,则填充的柔性透明光学材料厚度为2.5mm;若玻璃厚度为2.0mm,则填充的柔性透明光学材料厚度为2.0mm。
按说明书1:1调好透明1029胶,等5分钟气泡没有后缓缓倒入,静置4小时等待固化即可。
按下图将线接好在串口下载器进行调试:
[attach]51914[/attach]
[attach]51910[/attach]
配套调试软件做得一般,只能使用1~4端口,需要把下载器端口控制在这个范围。
[attach]51911[/attach]
确认后打开串口,在玻璃表面用湿润纸巾滑动,软件就会输出雨量数据了。
接下来将传感器固定到ESP8266上,利用以前为HX711做的多余PCB板,板刷上三防漆,把外壳也用密封胶处理好,硬件就完成了。
[attach]51912[/attach]
[attach]51913[/attach]
- substitutions:
- devicename: yuliang
- esphome:
- name: $devicename
- friendly_name: $devicename
- includes:
- - uartRS200_sensor.h
- ## 模块类型
- esp8266:
- board: nodemcuv2
- # 启用日志
- logger:
- baud_rate: 0
- # 启用HomeAssistant API
- api:
- encryption:
- key: "/i/sYVZtlW6NAbsY17CAoSR1+cWkfrQ/dexoW1uXjB2=" ## 密码
- # reboot_timeout: 30min ## 断网重启时间
- ota:
- password: "admin" ## 密码
- port: 8266 ## 端口
- ## 启用网页调试模式
- web_server:
- port: 80 ## 端口
-
- wifi:
- ssid: "xxxxxxx" ## WiFi SSID
- password: "xxxxxxxxxxxx" ## WiFi 密码
- use_address: 192.168.x.xxx ## 指定烧录固件时候目标设备IP,优先级高于静态IP(例如,如果您更改了静态IP并想将OTA刷新为先前配置的IP地址)
- manual_ip: ## 手动配置节点静态IP
- static_ip: 192.168.x.xxx ## 固定IP
- gateway: 192.168.x.x ## 网关
- subnet: 255.255.255.0 ## 子网掩码
- dns1: 223.5.5.5 ## DNS1
- dns2: 223.6.6.6 ## DNS2
- ap: ## wifi连接失败时启用备用热点
- ssid: "yuliang Hotspot" ## WiFi SSID
- password: "admin" ## WiFi 密码
-
- fast_connect: off ##如果启用,则直接连接到WiFi网络,而无需先进行全面扫描。这对于隐藏网络是必需的,并且可以大大缩短连接时间。默认为off。
- ## 强制门户认证
- captive_portal:
-
- # Example configuration entry
- uart:
- id: uart_bus
- rx_pin: GPIO3
- tx_pin: GPIO1
- baud_rate: 115200
- text_sensor:
- - platform: custom
- lambda: |-
- auto uart_custext_sensor = new CustomP1UartComponent(id(uart_bus));
- App.register_component(uart_custext_sensor);
- return {uart_custext_sensor->uart_text_sensors};
- text_sensors:
- id: "uart_readline"
- name: $devicename"_UART"
- button:
- - platform: template
- name: "Rainfall status" #读取雨量状态
- on_press:
- - uart.write: [0x3A, 0x01, 0x00, 0x00, 0x0D]
- - platform: template
- name: "On sleep" #进入睡眠状态
- on_press:
- - uart.write: [0x3A, 0x91, 0x01, 0x00, 0x88]
- - platform: template
- name: "Off sleep" #退出睡眠状态
- on_press:
- - uart.write: [0x3A ,0x91 ,0x00 ,0x00 ,0x7C]
- - platform: template
- name: "On Real time rainfall" #进入实时雨量状态
- on_press:
- - uart.write: [0x3A ,0x84 ,0x01 ,0x00 ,0x43]
- - platform: template
- name: "Off Real time rainfall" #退出实时雨量状态
- on_press:
- - uart.write: [0x3A ,0x84 ,0x00 ,0x00 ,0xB7]
- - platform: template
- name: "CHIP Temperature" #发送芯片温度,数据返回值 3A 90 xx xx xx
- on_press:
- - uart.write: [0x3A ,0x10 ,0x00 ,0x00 ,0xEF]
- - platform: template
- name: "On ambient light" #进入实时环境光测,数据返回值 3A 8F xx xx xx
- on_press:
- - uart.write: [0x3A ,0x8F ,0x01 ,0x00 ,0xDB]
- - platform: template
- name: "Off ambient light" #退出实时环境光测
- on_press:
- - uart.write: [0x3A ,0x8F ,0x00 ,0x00 ,0x2F]
复制代码
[attach]51921[/attach]
[attach]51918[/attach]
[attach]51919[/attach]
[attach]51920[/attach]
作者: dengxiao 时间: 2023-10-1 23:41
感谢楼主分享,一直不懂esphome的自定义uart,现在可以学习了
作者: george65 时间: 2023-10-2 11:23
可以自定義兩組~三組uart嗎??
作者: jole 时间: 2023-10-2 15:25
这个传感器有点贵哦,雨量检测怎么样?准不准
作者: nbxzl 时间: 2023-10-2 20:16
还是比较灵敏准确的
作者: nbxzl 时间: 2023-10-2 20:17
我没有这么多UART,没测试过哦
作者: lensam 时间: 2023-10-2 22:11
不知道是否可以用汽车的雨刮雨量传感器,其实挺准的,只要有3个档,也够用了,就不知道能不能实现,这个就几十块,很便宜。
作者: nbxzl 时间: 2023-10-3 20:10
可以,这个是它应用之一
作者: Ari 时间: 2023-10-3 22:57
顶一个技术性,感谢分享
作者: silversucks 时间: 2023-10-9 10:02
谢谢分享 抄一份哦
作者: roc634 时间: 2024-3-28 10:36
这胶暴晒久了会不会老化变黄?
作者: nbxzl 时间: 2024-4-10 13:38
到目前为止半年时间,一直使用报警正常,安装位置在屋顶,没上去看。以前室外用过这个胶没问题
作者: a_dongde 时间: 2024-4-10 14:08
厉害呀大佬。。。
作者: misLia 时间: 2024-11-4 11:29
自从玩了HA后,就喜欢在某宝上翻各种传感器。前两天晚上,翻到了这个传感器,无奈自己不会弄。今天看到居然已经有第一个吃螃蟹的了。
作者: misLia 时间: 2024-11-4 16:54
大佬,手里还有多余的D1Mini,应该也能可以用吧。
作者: nbxzl 时间: 2024-11-22 01:07
D1Mini ?
作者: shadowba 时间: 2024-11-22 08:16
留名备用
作者: shaula 时间: 2024-11-22 10:42
感谢楼主分享。原先用的是电阻式传感器,用起来还可以,就是连续阴雨天的时候,判断不准确,另外还有氧化问题。因此,照这个贴子做了一个光学雨量传感器。只不过这个传感器主动上报的雨量状态还存在雨转晴时不会主动上报状态的问题。因此,做了一个自动化来读取雨量状态,其中的雨量开关即relay2是个虚拟开关,逻辑是当雨量开关打开时,触发自动化,每一秒读取一次传感器雨量状态,如果60次内有小雨、中雨或大雨,则重新触发自动化,否则就关闭雨量开关。
[attach]65144[/attach][attach]65145[/attach]
- alias: 雨量检测自动化测试
- description: ""
- triggers:
- - trigger: state
- entity_id:
- - switch.relay2
- to: "on"
- conditions: []
- actions:
- - repeat:
- count: 60
- sequence:
- - action: button.press
- metadata: {}
- data: {}
- target:
- entity_id: button.rainfall_status
- - delay:
- hours: 0
- minutes: 0
- seconds: 1
- milliseconds: 0
- - if:
- - condition: or
- conditions:
- - condition: state
- entity_id: sensor.rain_uart_value
- state: 3A8101002C
- - condition: state
- entity_id: sensor.rain_uart_value
- state: 3A81020001
- - condition: state
- entity_id: sensor.rain_uart_value
- state: 3A810300F5
- then:
- - action: automation.trigger
- metadata: {}
- data:
- skip_condition: true
- target:
- entity_id: automation.yu_liang_jian_ce_zi_dong_hua_ce_shi
- - action: switch.turn_off
- metadata: {}
- data: {}
- target:
- entity_id: switch.relay2
- mode: restart
复制代码
作者: misLia 时间: 2024-11-22 13:19
esp8266 D1mini啊。
作者: misLia 时间: 2024-11-22 13:26
我看你这是天台。供电是怎么解决的?风力?
作者: nbxzl 时间: 2024-11-22 20:58

作者: nbxzl 时间: 2024-11-22 21:05
应该可以用,试试看
作者: norikohxb 时间: 2025-1-22 00:51
多少钱老板?
作者: nbxzl 时间: 2025-2-12 11:29
传感器大概60左右,WIFI芯片12左右,变压器大概15左右,其它配件大概是10左右
作者: norikohxb 时间: 2025-2-12 13:37
变压器我有是12v还是5v你的传感器+芯片的加工组合能否卖一个给我
作者: nbxzl 时间: 2025-2-18 16:51
最近工作比较忙,空闲时间比较少,没办法帮忙,你可按帖子依次制作,有什么不明白的可以提问,下面是之前购买的链接,供参考:
智能雨量检测模块RS200
可以用8266开发板代替单一模块
8266开发板
0.8mm间距 雨量传感器配套短线
86型空白面板:白色钢化玻璃表面
作者: nbxzl 时间: 2025-2-18 16:54
贴子用以前剩下的黑色空白面板,实际使用中,因放置在屋顶,加上黑色板吸热,易死机,处理成白色面,目前一直正常使用。
作者: hyq 时间: 2025-2-21 17:04
方便展示一下在HA中的效果图吗?
作者: nbxzl 时间: 2025-2-22 09:26
- id: '1696250526466'
alias: 微信报警_下小雨
description: ''
trigger:
- platform: state
entity_id:
- sensor.yuliang_177_yuliang_177_uart
to: 3A8101002C
for:
hours: 0
minutes: 0
seconds: 5
from: 3A810000D8
condition: []
action:
- service: notify.wework
data:
message: 注意哦,下小雨了!
- delay:
hours: 0
minutes: 5
seconds: 0
milliseconds: 0
- device_id: dce12561214bf712aa2421d330ee0654
domain: button
entity_id: fd51bd1cdec2dad2701131e14fb4b34d
type: press
mode: single
- id: '1696257537665'
alias: 微信报警_小雨变中雨
description: ''
trigger:
- platform: state
entity_id:
- sensor.yuliang_177_yuliang_177_uart
for:
hours: 0
minutes: 0
seconds: 5
from: 3A8101002C
to: 3A81020001
condition: []
action:
- service: notify.wework
data:
message: 注意,小雨变中雨了!
mode: single
- id: '1696257839578'
alias: 微信报警_大雨变中雨
description: ''
trigger:
- platform: state
entity_id:
- sensor.yuliang_177_yuliang_177_uart
to: 3A81020001
for:
hours: 0
minutes: 0
seconds: 5
from: 3A810300F5
condition: []
action:
- service: notify.wework
data:
message: 哈哈,大雨变中雨了!
- delay:
hours: 0
minutes: 5
seconds: 0
milliseconds: 0
- device_id: dce12561214bf712aa2421d330ee0654
domain: button
entity_id: fd51bd1cdec2dad2701131e14fb4b34d
type: press
mode: single
- id: '1696258084153'
alias: 微信报警_中雨变小雨
description: ''
trigger:
- platform: state
entity_id:
- sensor.yuliang_177_yuliang_177_uart
to: 3A8101002C
for:
hours: 0
minutes: 0
seconds: 5
from: 3A81020001
condition: []
action:
- service: notify.wework
data:
message: 嘿嘿,中雨变小雨了!
- delay:
hours: 0
minutes: 5
seconds: 0
milliseconds: 0
- device_id: dce12561214bf712aa2421d330ee0654
domain: button
entity_id: fd51bd1cdec2dad2701131e14fb4b34d
type: press
mode: single
- id: '1696258298242'
alias: 微信报警_中雨变大雨
description: ''
trigger:
- platform: state
entity_id:
- sensor.yuliang_177_yuliang_177_uart
to: 3A810300F5
for:
hours: 0
minutes: 0
seconds: 5
from: 3A81020001
condition: []
action:
- service: notify.wework
data:
message: 唉,中雨变大雨了!
- delay:
hours: 0
minutes: 5
seconds: 0
milliseconds: 0
- device_id: dce12561214bf712aa2421d330ee0654
domain: button
entity_id: fd51bd1cdec2dad2701131e14fb4b34d
type: press
mode: single
- id: '1696258463410'
alias: 微信报警_天晴
description: ''
trigger:
- platform: state
entity_id:
- sensor.yuliang_177_yuliang_177_uart
to: 3A810000D8
for:
hours: 0
minutes: 0
seconds: 5
from: 3A8101002C
condition: []
action:
- service: notify.wework
data:
message: 耶,雨过天晴了!
- delay:
hours: 0
minutes: 10
seconds: 0
milliseconds: 0
- device_id: dce12561214bf712aa2421d330ee0654
domain: button
entity_id: fd51bd1cdec2dad2701131e14fb4b34d
type: press
mode: single
- id: '1696258797194'
alias: 微信报警_大雨变小雨
description: ''
trigger:
- platform: state
entity_id:
- sensor.yuliang_177_yuliang_177_uart
to: 3A8101002C
for:
hours: 0
minutes: 0
seconds: 5
from: 3A810300F5
condition: []
action:
- service: notify.wework
data:
message: 哈哈,大雨变小雨了!
- delay:
hours: 0
minutes: 5
seconds: 0
milliseconds: 0
- device_id: dce12561214bf712aa2421d330ee0654
domain: button
entity_id: fd51bd1cdec2dad2701131e14fb4b34d
type: press
mode: single
- id: '1697345390585'
alias: 自动刷新雨量状态
description: ''
trigger: []
condition:
- condition: state
entity_id: sensor.yuliang_177_yuliang_177_uart
state: 3A8101002C
for:
hours: 0
minutes: 5
seconds: 0
- condition: state
entity_id: sensor.yuliang_177_yuliang_177_uart
state: 3A81020001
for:
hours: 0
minutes: 5
seconds: 0
- condition: state
entity_id: sensor.yuliang_177_yuliang_177_uart
state: 3A810300F5
for:
hours: 0
minutes: 5
seconds: 0
action:
- device_id: dce12561214bf712aa2421d330ee0654
domain: button
entity_id: fd51bd1cdec2dad2701131e14fb4b34d
type: press
mode: single
作者: nbxzl 时间: 2025-2-22 09:29
本帖最后由 nbxzl 于 2025-2-22 09:31 编辑
HA界面中
[attach]68389[/attach]
设置了微信推送到手机上
[attach]68390[/attach]
作者: shaula 时间: 2025-2-23 20:22
楼主,最新的esphome取消了custom组件,请教有什么办法可以读取 UART并传入到 Text Sensor传感器当中?
作者: nbxzl 时间: 2025-2-24 09:12
抱歉,这个不清楚,实在想用可以临时安装老版ESPHOME
作者: shaula 时间: 2025-2-25 13:05
本帖最后由 shaula 于 2025-2-25 13:09 编辑
找到解决方案了
在esphome该设备的yaml文件里加入这一段后ota,即可使用custom组件。
external_components:
- source:
type: git
url: https://github.com/robertklep/esphome-custom-component
components: [ custom, custom_component ]
作者: nbxzl 时间: 2025-2-28 08:49
| 欢迎光临 『瀚思彼岸』» 智能家居技术论坛 (https://bbs.hassbian.com/) |
Powered by Discuz! X3.5 |