Ld2410 ble - hlk-ld2410b

His cases are great! I’m sure you saw there were several options for cases and mounts in the link provided to tinkercatd. I will say they are a tight fit so I did add a little more size upwards on the cases where the ESP32, MmWave sensor and pir fit but you can cut out any of the ones you don’t want using tinkercatd or whatever program you use. Also, the cases for the ESP32 only are great for BT proxies with a regular 30 pin ESP32 like the one used in that article. I used the DORHEA 4PCS ESP32 ESP-32S. They fit perfectly but I don’t think a ESP32 with more pins would fit without some adjustments.

I did end.up adjusting the yaml for ESPHome for more controls based on the yaml for the EP1. Below is what I ended up with. I will say that those PIR’s do have some false positives so going add the yanl above to try and resolve that issue. Usually I get the false positives on the MmWave sensors regardless of which one is used… I actually ordered the same Panasonic PIR’s used in the EP1 so going to see how those work out but they are bigger so I’m going to have to adjust the case a bit more for it to fit. I need to remove the light part as I thought it would turn off the red led on the ESP32 but it actually turns on a different blue led which is off by default. I like having a switch for the blinking light on the dfrobot which was super annoying and didn’t want to but black paint or tape over it personally Since the EP1 uses a custom board with a temperature and light sensor it does actually turn a red light off on the EP1 board. I also like having the occupancy sensor that combines the pir and MmWave sensor so you can create automations on the pir, MmWave sensor, or the occupancy sensor which combines buth sensors to turn off or on.

substitutions:
  factory_reset_disabled: "true"
  uart_target_output_disabled: "true"
  uart_presence_output_disabled: "true"
  device_name: "dfrobot-pir"

esphome:
  name: dfrobot-pir
  friendly_name: dfrobot pir

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

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

ota:
  password: "hjhhhhhhhjhhhhhhh"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Dfrobot-Pir Fallback Hotspot"
    password: "122222211"

# MQTT client component
mqtt:
  broker: !secret mqtt_ip
  username: !secret mqtt_username
  password: !secret mqtt_password
  discovery: False # Only if you use the HA API usually
  id: mqtt_client

# fallback if WiFi fails
captive_portal:

light:
  - platform: status_led
    name: "ESP32 Status LED"
    pin: GPIO2

web_server:
  port: 80
  version: 2
  include_internal: true
  auth:
    username: hhhhh
    password: hhhhh

# Enable HTTP/HTTPS requests
http_request:
  # default ESPHome
  useragent: esphome/$device_name
  # request time out / default 5s
  timeout: 2s

# UART communication settings for mmWave sensor | Remember to set pins
uart:
  id: uart_bus
  # pin to send data from ESP
  tx_pin: GPIO25
  # pin to receive data to ESP
  rx_pin: GPIO33
  # baud rate for UART bus (required)
  baud_rate: 115200
  debug:
  # debug communication to both directions
    direction: BOTH
    # useful to debug all incoming communication
    dummy_receiver: true
    after:
      delimiter: "\n"
    sequence:
      - lambda: UARTDebug::log_string(direction, bytes);

switch:

  - platform: template
    name: "mmWave Sensor"
    id: "mmwave_sensor"
    entity_category: config
    optimistic: true
    restore_state: true
    turn_on_action:
      - uart.write: "sensorStart"
      - delay: 1s
    turn_off_action:
      - uart.write: "sensorStop"
      - delay: 1s    

  - platform: template
    name: "mmWave LED"
    id: "mmwave_led"
    entity_category: config
    optimistic: true
    restore_state: true
    turn_on_action:
      - switch.turn_off: mmwave_sensor
      - delay: 1s
      - uart.write: "setLedMode 1 0"
      - delay: 1s
      - uart.write: "saveConfig"
      - delay: 3s
      - switch.turn_on: mmwave_sensor
    turn_off_action:
      - switch.turn_off: mmwave_sensor
      - delay: 1s
      - uart.write: "setLedMode 1 1"
      - delay: 1s
      - uart.write: "saveConfig"
      - delay: 3s
      - switch.turn_on: mmwave_sensor

  - platform: template
    name: "uart_presence_output"
    id: "uart_presence_output"
    entity_category: config
    internal: ${uart_presence_output_disabled}
    optimistic: true
    restore_state: true
    turn_on_action:
      - switch.turn_off: mmwave_sensor
      - delay: 1s
      - uart.write: "setUartOutput 1 1"
      - delay: 1s
      - uart.write: "saveConfig"
      - delay: 3s
      - switch.turn_on: mmwave_sensor
    turn_off_action:
      - switch.turn_off: mmwave_sensor
      - delay: 1s
      - uart.write: "setUartOutput 1 0"
      - delay: 1s
      - uart.write: "saveConfig"
      - delay: 3s
      - switch.turn_on: mmwave_sensor

  - platform: template
    name: "uart_target_output"
    id: "uart_target_output"
    entity_category: config
    internal: ${uart_target_output_disabled}
    optimistic: true
    restore_state: true
    assumed_state: false
    turn_on_action:
      - switch.turn_off: mmwave_sensor
      - delay: 1s
      - uart.write: "setUartOutput 2 1 1 1"
      - delay: 1s
      - uart.write: "saveConfig"
      - delay: 3s
      - switch.turn_on: mmwave_sensor
    turn_off_action:
      - switch.turn_off: mmwave_sensor
      - delay: 1s
      - uart.write: "setUartOutput 2 0"
      - delay: 1s
      - uart.write: "saveConfig"
      - delay: 3s
      - switch.turn_on: mmwave_sensor      

binary_sensor:
  # mmWave Sensor | remember to set the pin
- platform: gpio
  name: dfrobot_mmwave
  id: mmwave
  device_class: occupancy  
  pin:
    number: GPIO27
    mode: INPUT_PULLDOWN
  # PIR Sensor | remember to set the pin
- platform: gpio
  name: dfrobot_pir
  id: pir_motion_sensor
  pin:
    number: GPIO18
    mode: INPUT_PULLDOWN
  # delay detection off by 3s
  filters:
    - delayed_off: 3s    
- platform: template
  name: occupancy
  id: occupancy
  device_class: occupancy    
  filters:
    - delayed_off: "10s"
  lambda: |-
    if ( id(mmwave).state or id(pir_motion_sensor).state) {
      return true;
    } 
    else if (id(mmwave).state == 0 and id(pir_motion_sensor).state == 0) {
      return false;
    } 
    else {
      return id(occupancy).state;
    }        


number:
  - platform: template
    name: mmWave Distance
    id: mmwave_distance
    entity_category: config
    min_value: 0
    max_value: 800
    initial_value: 315
    optimistic: true
    step: 15
    restore_value: true
    unit_of_measurement: cm
    mode: slider
    set_action:
      - switch.turn_off: mmwave_sensor
      - delay: 1s
      - uart.write: !lambda int cm = (int)ceil(x / 15.0);
          std::string cms = "detRangeCfg -1 0 " + to_string(cm);
          return std::vector<unsigned char>(cms.begin(), cms.end());
      - delay: 1s
      - uart.write: "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89"
      - delay: 1s
      - switch.turn_on: mmwave_sensor

  - platform: template
    name: mmWave Off Latency
    id: mmwave_off_latency
    entity_category: config
    min_value: 1
    max_value: 60
    initial_value: 15
    optimistic: true
    step: 1
    restore_value: true
    unit_of_measurement: seconds
    mode: slider
    set_action:
      - switch.turn_off: mmwave_sensor
      - delay: 1s
      - uart.write: !lambda |-
          std::string mss = "setLatency " + to_string(id(mmwave_on_latency).state) + " " + to_string(id(mmwave_off_latency).state);
          return std::vector<unsigned char>(mss.begin(), mss.end());
      - delay: 1s
      - uart.write: "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89"
      - delay: 1s
      - switch.turn_on: mmwave_sensor

  - platform: template
    name: mmWave On Latency
    id: mmwave_on_latency
    entity_category: config
    min_value: 0
    max_value: 60
    initial_value: 0
    optimistic: true
    step: 0.5
    restore_value: true
    unit_of_measurement: seconds
    mode: slider
    set_action:
      - switch.turn_off: mmwave_sensor
      - delay: 1s
      - uart.write: !lambda |-
          std::string mss = "setLatency " + to_string(id(mmwave_on_latency).state) + " " + to_string(id(mmwave_off_latency).state);
          return std::vector<unsigned char>(mss.begin(), mss.end());
      - delay: 1s
      - uart.write: "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89"
      - delay: 1s
      - switch.turn_on: mmwave_sensor

  - platform: template
    name: mmWave Sensitivity
    id: mmwave_sensitivity
    entity_category: config
    min_value: 0
    max_value: 9
    initial_value: 7
    optimistic: true
    step: 1
    restore_value: true
    set_action:
      - switch.turn_off: mmwave_sensor
      - delay: 1s
      - uart.write:
          !lambda std::string mss = "setSensitivity " + to_string((int)x);
          return std::vector<unsigned char>(mss.begin(), mss.end());
      - delay: 1s
      - uart.write: "saveConfig"
      - delay: 1s
      - switch.turn_on: mmwave_sensor        

button:
# Restart the device
  - platform: restart
    name: restart_mmwave_final
# Switch for Safe Mode
  - platform: safe_mode
    internal: true
    name: use_safe_mode
  - platform: template
    name: "Restart mmWave Sensor"
    id: "restart_mmwave"
    entity_category: config
    internal: true
    on_press:
      - uart.write: "resetSystem"        

  - platform: template
    name: "Factory Reset mmWave"
    id: "factory_reset_mmwave"
    internal: ${factory_reset_disabled}
    entity_category: config
    on_press:
      - switch.turn_off: mmwave_sensor
      - delay: 1s
      - uart.write: "resetCfg"
      - delay: 3s
      - switch.turn_on: mmwave_sensor