人体存在检测 ESPHome+ESP01S+LD2402

一、硬件准备

  1. USB转TTL
  2. ESP01S模块
  3. HLK-LD2402
    实物图:
    USB转TTL USB转TTL
    ESP01SESP01S
    HLK-LD2402HLK-LD2402

二、使用ESPHome对ESP01S模块进行固件烧写

USB转TTLESP01S烧写模式连接:

USB转TTLESP01S
3V33V3
TXDRX(IO3)
RXDTX(IO1)
GNDGND
GNDIO0

ESPHome代码:
实现功能:有人时板载led灯亮,无人时板载led灯灭

esphome:
  name: esp01s-ld2402
  friendly_name: ESP01S_LD2402

esp8266:
  board: esp01_1m

# Enable logging
logger:
  level: DEBUG

sensor:
  - platform: wifi_signal
    name: "wifi强度"
    update_interval: 30s

binary_sensor:
  - platform: gpio
    name: "人体存在传感器"
    pin: GPIO3
    device_class: motion
    filters: 
      - delayed_on: 10ms
      - delayed_off: 10ms
    on_press: 
      then:
        - output.turn_on: bin_led
    on_release: 
      then:
        - output.turn_off: bin_led

output:
  - platform: gpio
    id: bin_led
    pin: GPIO2
    inverted: True

# Enable Home Assistant API
api:
  encryption:
    key: "xxxxxxxxxxxx"

ota:
  - platform: esphome
    password: "xxxxxxxxxxxx"

# web控制
web_server:
  port: 80

wifi:
  ssid: "xxxxxxxxxxxx"
  password: "xxxxxxxxxxxx"
  manual_ip: 
    static_ip: 192.168.2.98
    gateway: 192.168.2.1
    subnet: 255.255.255.0

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp01S-Ld2402 Fallback Hotspot"
    password: "xxxxxxxxxxxx"

captive_portal:
    

三、ESP01S与LD2402工作模式接线

ESP01SLD2402电源
3V3V3.3V
RXIO
GNDGGND

注意:ESP01S冷启动时IO0、IO1、IO2不能是低电平,低电平则无法启动

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值