请选择 进入手机版 | 继续访问电脑版

 找回密码
 立即注册
查看: 1771|回复: 20

[人体存在] 27.1元打造零延迟人体存在传感器:我的智能家居改造记

[复制链接]

3

主题

38

回帖

205

积分

中级会员

积分
205
金钱
164
HASS币
0
发表于 2025-5-5 10:28:36 | 显示全部楼层 |阅读模式
本帖最后由 yb997471 于 2025-5-5 11:05 编辑

厨房、卫生间红外灯控常因传统传感器性能不足导致尴尬:人未离场却灭灯、进门后要罚站等触发。
为解决这个痛点,我以27.1元成本打造出零延迟人体存在感应系统。

核心器件:
  • ESP8266 12F主控(5元):承载毫米波雷达数据处理
  • 2410C毫米波雷达(13元):通过微多普勒效应精准识别人体微动
  • 3C烟感外壳(5元):完美隐藏电路且符合消防标准

  • 8266转接板(0.8元):扩展接线
  • 5伏转3.3伏(0.3元)
  • 220变压5伏(3元) :220交流电转换5伏直流电


实现效果:
  • 触发延迟<0.3秒
  • 静止检测精度90%以上
  • 支持存在时长设置(5-30分钟可调)
  • 联动智能开关

该方案通过esphome接入HomeAssistant,配合Node-RED实现自动化场景。 较市售成品传感器节省80%成本。



回复

使用道具 举报

3

主题

38

回帖

205

积分

中级会员

积分
205
金钱
164
HASS币
0
 楼主| 发表于 昨天 22:32 | 显示全部楼层
本帖最后由 yb997471 于 2025-5-18 22:33 编辑
完整代码,自己复制一份即可。
esphome:
  name: weishengjian1-2410c
  friendly_name: weishengjian1_2410c

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "2UU/ayxp7RWpUUlPiqOE+9PGPNXcKI="

ota:
  - platform: esphome
    password: "6ce8c4512ebe363d09f"

wifi:
  ssid: ithome_2.4
  password: 123456

  # Optional manual IP
  manual_ip:
    static_ip: 192.168.0.231
    gateway: 192.168.3.1
    subnet: 255.255.255.0
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "chufangld2410AP"
    password: "12345678"

# prefix for Home Assistant entities --> CHANGE to our yown prefix
substitutions:
  device_name: _ 

web_server:
  port: 8080

captive_portal:


# UART for the LD2410 board --> CHANGE to your GPIO!!
uart:
  #可以手动指定 UART 组件的 ID 使用
  id: uart_bus
  tx_pin:
    number: GPIO1
  rx_pin: 
    number: GPIO3
  baud_rate: 256000
  parity: NONE
  stop_bits: 1
 

ld2410:

switch:
  #该开关允许您控制 LD2410 传感器
  - platform: ld2410
    engineering_mode:
      #启用/禁用工程模式
      name: ${device_name}engineering_mode
    bluetooth:
      #打开/关闭蓝牙适配器
      name: ${device_name}control_bluetooth

button: 
  - platform: restart
  #单独
    name: ${device_name}restart_device  

  - platform: ld2410
    factory_reset:
      #此命令用于将所有配置值还原为其原始值
      name: ${device_name}factory_reset
    restart:
      #重启设备
      name: ${device_name}restart
    query_params:
      #刷新设备的所有传感器值
      name: ${device_name}query_params

#该传感器允许您使用 LD2410 传感器执行不同的 测量。
sensor:
  - platform: ld2410
    light:
      #可选,int):在工程模式下,表示光敏度,否则。 介于 和 包含之间的值。尽管该值似乎是完全黑暗时的最低值
      name: ${device_name}light_sensitivity
    moving_distance:
      #检测到的移动目标的距离(以厘米为单位)
      name : ${device_name}moving_distance
    still_distance:
      #检测到的静止目标的距离(以厘米为单位)
      name: ${device_name}still_distance
    moving_energy:
      #移动目标的能量。 介于 和 包含之间的值
      name: ${device_name}moving_energy
    still_energy:
      #静止目标的能量。 介于 和 包含之间的值
      name: ${device_name}still_energy
    detection_distance:
      #距离目标的距离(以厘米为单位)
      name: ${device_name}detection_distance
    g0:
      #第 X 个门的能量 门的移动能量&门的静止能量
      move_energy:
        name: ${device_name}g0_move_energy
      still_energy:
        name: ${device_name}g0_still_energy
    g1:
      move_energy:
        name: ${device_name}g1_move_energy
      still_energy:
        name: ${device_name}g1_still_energy
    g2:
      move_energy:
        name: ${device_name}g2_move_energy
      still_energy:
        name: ${device_name}g2_still_energy
    g3:
      move_energy:
        name: ${device_name}g3_move_energy
      still_energy:
        name: ${device_name}g3_still_energy
    g4:
      move_energy:
        name: ${device_name}g4_move_energy
      still_energy:
        name: ${device_name}g4_still_energy
    g5:
      move_energy:
        name: ${device_name}g5_move_energy
      still_energy:
        name: ${device_name}g5_still_energy
    g6:
      move_energy:
        name: ${device_name}g6_move_energy
      still_energy:
        name: ${device_name}g6_still_energy
    g7:
      move_energy:
        name: ${device_name}g7_move_energy
      still_energy:
        name: ${device_name}g7_still_energy
    g8:
      move_energy:
        name: ${device_name}g8_move_energy
      still_energy:
        name: ${device_name}g8_still_energy

binary_sensor:
  - platform: ld2410
    has_target:
      #如果为 true,则目标检测到静止或移动
      name: ${device_name}presence
    has_moving_target:
      #如果为 true,则检测到移动目标
      name: ${device_name}moving_target
    has_still_target:
      #如果为 true,则检测到静止目标
      name: ${device_name}still_target
    out_pin_presence_status:
      #当处于工程模式时,指示 OUT 引脚是否指示存在,否则。 OUT 引脚指示取决于光功能配置
      name: ${device_name}engineering_occupancy

# LD2410 PINOUT GPIO --> CHANGE to your own GPIO!!
  - platform: gpio
    pin: GPIO5
    name: ${device_name}occupancy
    device_class: presence

number:

  - platform: ld2410
    timeout:
      #状态保持存在的时间(以秒为单位) 离开后
      name: ${device_name}timeout
    light_threshold:
      #设置 light 函数的 light 阈值
      name: ${device_name}light_threshold
    max_move_distance_gate:
      #:用于移动检测的最大距离门
      name: ${device_name}max_move_distance_gate
    max_still_distance_gate:
      #用于静止检测的最大距离门
      name: ${device_name}max_still_distance_gate
    g0:
      #第 X 个门的阈值
      move_threshold:
        #运动检测门的阈值。 对于所考虑的门 (距离) ,高于此级别,将触发移动检测
        name: ${device_name}g0_move_threshold
      still_threshold:
        #用于静止检测的门阈值。 对于所考虑的门 (距离) ,高于此水平时,仍将触发检测
        name: ${device_name}g0_still_threshold
    g1:
      move_threshold:
        name: ${device_name}g1_move_threshold
      still_threshold:
        name: ${device_name}g1_still_threshold
    g2:
      move_threshold:
        name: ${device_name}g2_move_threshold
      still_threshold:
        name: ${device_name}g2_still_threshold
    g3:
      move_threshold:
        name: ${device_name}g3_move_threshold
      still_threshold:
        name: ${device_name}g3_still_threshold
    g4:
      move_threshold:
        name: ${device_name}g4_move_threshold
      still_threshold:
        name: ${device_name}g4_still_threshold
    g5:
      move_threshold:
        name: ${device_name}g5_move_threshold
      still_threshold:
        name: ${device_name}g5_still_threshold
    g6:
      move_threshold:
        name: ${device_name}g6_move_threshold
      still_threshold:
        name: ${device_name}g6_still_threshold
    g7:
      move_threshold:
        name: ${device_name}g7_move_threshold
      still_threshold:
        name: ${device_name}g7_still_threshold
    g8:
      move_threshold:
        name: ${device_name}g8_move_threshold
      still_threshold:
        name: ${device_name}g8_still_threshold

select:
  - platform: ld2410
    distance_resolution:
      #控制浇口距离分辨率
      name: ${device_name}distance_resolution
    light_function:
      #如果设置,将根据光阈值影响 OUT 引脚值
      name: ${device_name}ligh_function
    out_pin_level:
      #控制 OUT 引脚值
      name: ${device_name}out_pin_level
回复

使用道具 举报

3

主题

38

回帖

205

积分

中级会员

积分
205
金钱
164
HASS币
0
 楼主| 发表于 2025-5-5 10:34:12 | 显示全部楼层
成品图片
WechatIMG91240.jpg
WechatIMG940.jpg
WechatIMG941.jpg
WechatIMG942.jpg
WechatIMG943.jpg
回复

使用道具 举报

20

主题

62

回帖

776

积分

论坛分享达人

积分
776
金钱
694
HASS币
10
发表于 2025-5-5 10:51:02 | 显示全部楼层
回复

使用道具 举报

27

主题

127

回帖

1301

积分

金牌会员

积分
1301
金钱
1147
HASS币
0
发表于 2025-5-5 10:52:40 | 显示全部楼层
2410C和2410B可以直接接入有蓝牙的HA设备。你的8266都不需要的其实10几块就够了
回复

使用道具 举报

3

主题

38

回帖

205

积分

中级会员

积分
205
金钱
164
HASS币
0
 楼主| 发表于 2025-5-5 10:59:31 | 显示全部楼层
geniusliang 发表于 2025-5-5 10:52
2410C和2410B可以直接接入有蓝牙的HA设备。你的8266都不需要的其实10几块就够了 ...

恩,主机没有蓝牙,都是WiFi跟zigbee方式接入的
回复

使用道具 举报

170

主题

2550

回帖

8505

积分

元老级技术达人

积分
8505
金钱
5780
HASS币
30
发表于 2025-5-5 11:33:41 | 显示全部楼层
5伏转3.3伏有什么用?很多开发板不都是5v usb输入,并且板子上支持3.3和5v的吗?
回复

使用道具 举报

1

主题

32

回帖

232

积分

中级会员

积分
232
金钱
199
HASS币
0
发表于 2025-5-5 16:55:38 | 显示全部楼层
bugensui 发表于 2025-5-5 11:33
5伏转3.3伏有什么用?很多开发板不都是5v usb输入,并且板子上支持3.3和5v的吗? ...

新手我也有这个疑问。
回复

使用道具 举报

36

主题

683

回帖

4916

积分

论坛元老

积分
4916
金钱
4187
HASS币
60
发表于 2025-5-5 20:33:38 | 显示全部楼层
本帖最后由 huang7dede 于 2025-5-5 20:35 编辑
bugensui 发表于 2025-5-5 11:33
5伏转3.3伏有什么用?很多开发板不都是5v usb输入,并且板子上支持3.3和5v的吗? ...

因为他用的这个不是开发版,是esp8266模块,你说的是基于esp8266的NodeMCU开发版,添加了电源转换,usb接口,微动开关,上下拉电阻,led指示灯,排线针脚等等,那个一般10多元,这个12F一般就几元钱。
回复

使用道具 举报

170

主题

2550

回帖

8505

积分

元老级技术达人

积分
8505
金钱
5780
HASS币
30
发表于 2025-5-5 23:27:36 | 显示全部楼层
huang7dede 发表于 2025-5-5 20:33
因为他用的这个不是开发版,是esp8266模块,你说的是基于esp8266的NodeMCU开发版,添加了电源转换,usb接 ...

原来如此,学习了。我一直以为是1个东西,
回复

使用道具 举报

ms2 手机认证

24

主题

739

回帖

4087

积分

论坛元老

积分
4087
金钱
3319
HASS币
20
发表于 2025-5-6 09:21:38 | 显示全部楼层
geniusliang 发表于 2025-5-5 10:52
2410C和2410B可以直接接入有蓝牙的HA设备。你的8266都不需要的其实10几块就够了 ...

这个具体怎么做,能说得详细点吗
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian ( 晋ICP备17001384号-1 )

GMT+8, 2025-5-19 00:48 , Processed in 0.074440 second(s), 27 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表