『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 323|回复: 2

[硬件DIY] 便宜好用海凌科LD2420人体传感器装入86开关

[复制链接]

5

主题

30

帖子

332

积分

论坛DIY达人

积分
332
金钱
302
HASS币
10
发表于 5 天前 | 显示全部楼层 |阅读模式
本帖最后由 slychen 于 2025-2-28 08:40 编辑

一直在用LD2410作为人体传感器在用,最近想在餐厅的开关里装人体传感器,但2410的尺寸偏大装不下,就找了个尺寸合适的2420装入,没想到居然还挺好用的。
IMG_5728 2.jpg
硬件接法参照2420手册:esp8266的RX接2420的ot1、TX接2420的RX。
增加TEMT6000,接入esp8266点ADC接口作为光照传感器。

原来这86开关是8266控制的,用细线将几个IO口引出接左边为TEMT6000光线传感器,右边为LD2420:
IMG_5727.jpg

装好点样子,左边的按键开了个孔,嵌入个亚克力给光照传感器透光:
IMG_5729.jpg

web界面:
截屏2025-02-27 13.29.28.png

Homeassistant界面:

截屏2025-02-27 13.29.58.png

esphome代码如下:
esphome:
  name: dinner_room_sensor_switch

esp8266:
  board: esp01_1m

# Enable logging
logger:
  baud_rate: 0
# Enable Home Assistant API
api:


ota:
  platform: esphome
  password: ""

wifi:
  ssid: !secret wifi_ssid #改为你自己家的WIFI名称
  password: !secret wifi_password #改为你家的WIFI密码

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Dinner Room Sensor Switch"
    password: ""
web_server: 
  port: 80

captive_portal:
uart:
  id: uart_bus  
  tx_pin: GPIO1   #使用D1 mini RX
  rx_pin: GPIO3   #使用D1 mini TX
  baud_rate: 115200
  parity: NONE
  stop_bits: 1    

binary_sensor:    
  # 物理按钮开关
  - platform: gpio
    pin: GPIO05
    
    name: "Switch1"
    internal: true
    on_press:
      then:
        - switch.toggle: relay_1
        - logger.log: "Power Button Turned Press!"
    filters:
      - delayed_on_off: 50ms


  - platform: gpio
    pin: GPIO04
    
    name: "Switch2"
    internal: true
    on_press:
      then:
        - switch.toggle: relay_2
        - logger.log: "Power Button Turned Press!"
    filters:
      - delayed_on_off: 50ms

  - platform: ld2420
    has_target:
      name: Presence
    
switch:
  - platform: gpio
    pin: GPIO14
#反向开关
    #inverted: true
    name: "餐厅开关1"
    id: relay_1  
  - platform: gpio
    pin: GPIO13
#反向开关
    #inverted: true
    name: "厨房大灯"
    id: relay_2 
    

ld2420:
  uart_id: uart_bus
text_sensor:
  - platform: ld2420
    fw_version:
      name: Firmware version

sensor:
  - platform: ld2420
    moving_distance:
      name : Moving Distance

  - platform: adc
    pin: A0
    name: "餐厅光照度"
    device_class: illuminance
    unit_of_measurement: lx
    filters:
      - lambda: |-
          return (x / 10000.0) * 2000000.0;
    update_interval: 10s 


select:
  - platform: ld2420
    operating_mode:
      name: Operating Mode

number:
  - platform: ld2420
    presence_timeout:
      name: Timeout Presence 
    min_gate_distance:   #最小门数,最小门数不要选择0,否则会有底噪干扰
      name: Min Gate
    max_gate_distance:  #最大门数,超过12无效,每个门的距离大概是0.7米,按照自己的需求选择
      name: Max Gate
    # See "Number" section below for detail

    gate_move_sensitivity:
      name: Move Calibration Sensitivity Factor
    gate_still_sensitivity:
      name: Still Calibration Sensitivity Factor
#直接选择设置各个门的阈值,后面根据距离可以自己增加门数到12
    gate_0:
      move_threshold:
        name: Gate 0 Move Threshold
      still_threshold:
        name: Gate 0 Still Threshold
    gate_1:
      move_threshold:
        name: Gate 1 Move Threshold
      still_threshold:
        name: Gate 1 Still Threshold
    gate_2:
      move_threshold:
        name: Gate 2 Move Threshold
      still_threshold:
        name: Gate 2 Still Threshold  
    gate_3:
      move_threshold:
        name: Gate 3 Move Threshold
      still_threshold:
        name: Gate 3 Still Threshold  
    gate_4:
      move_threshold:
        name: Gate 4 Move Threshold
      still_threshold:
        name: Gate 4 Still Threshold                       
button:
  - platform: ld2420
    apply_config:
      name: Apply Config
    factory_reset:
      name: Factory Reset
    restart_module:
      name: Restart Module
    revert_config:
      name: Undo Edits
因为开关距离餐桌较近(2米左右),每个门代表0.7米,所以可以将传感门设置最小为1、最大为3,避免误触发。gate_0到gate_4的那段为直接设置从门0到门4的阈值改变灵敏度;也可以改为选择每个门来分别设置每个门的阈值,用了这种设置原来每个门直接设置的滑块就不会出现,代码如下:
number:
  - platform: ld2420
    presence_timeout:
      name: Detection Presence Timeout
    min_gate_distance:
      name: Min Gate
    max_gate_distance:
      name: Max Gate
    gate_select:
      name: Select Gate to Set
    still_threshold:
      name: Set Still Threshold Value
    move_threshold:
      name: Set Move Threshold Value
另外LD2420的自动校准也挺好用的,可以排除干扰源:在前面没有人的情况下Operating Mode(运行模式),选择Calibrate(校准)让它收集底噪信息约两三分钟后,它会计算这段时间的平均底噪信息,按下Aply Config,    就会自动保存校正结果排除底噪干扰。
另外简单说明下:所谓的门的概念有点不好理解,其实就是距离区间,一个门的距离大概0.7米,从离传感器最近的0门到最远12门大概就是8米多的距离;每个门的阈值调整就是调整这距离区间内的灵敏度,将人体移动感应到的信号值大小从0到65535分级,如设置值1000,就表示感应移动信号强度达到1000时传感器就发出有人的信号,设置数值越大就表示人体移动幅度越大传感器才发出有人信号。





回复

使用道具 举报

0

主题

649

帖子

2716

积分

金牌会员

Rank: 6Rank: 6

积分
2716
金钱
2067
HASS币
0
发表于 5 天前 | 显示全部楼层
这个开关是自己diy的吗
回复

使用道具 举报

164

主题

2643

帖子

8172

积分

元老级技术达人

积分
8172
金钱
5524
HASS币
30
发表于 5 天前 | 显示全部楼层
[backcolor=rgba(127, 127, 127, 0.3)]  没有看懂
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2025-3-4 19:38 , Processed in 0.579013 second(s), 27 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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