HLK-LD2410B with a Wemos Mini D1 (v4) connected to Home Assistant using ESPHome

Last Updated or created 2024-04-19

UPDATED: 20240419

LD2410 is a high-sensitivity 24GHz human presence status sensing module developed by Hi-link. Its working principle is to use FMCW frequency-modulated continuous waves to detect human targets in the set space. Combined with radar signal processing and precise human body sensing algorithms, it realizes high-sensitivity human presence status sensing, and can identify human bodies in motion and stationary states. And auxiliary information such as the distance of the target can be calculated.

This product is mainly used in indoor scenes to sense whether there is a moving or micro-moving human body in the area, and output the detection results in real time. The farthest sensing distance can reach 5 meters, and the distance resolution is 0.75m. Provides a visual configuration tool, which can easily configure the sensing distance range, sensing sensitivity in different intervals and unmanned delay time, etc., to adapt to different specific application needs.

Support GPIO and UART output, plug and play, and can be flexibly applied to different smart scenarios and terminal products.

There are 3 versions: Without Bluetooth, with Bluetooth (B version) and a C version which uses the standard pin distance.
The other ones are a pain in the *ss to solder!

Got a Bluetooth version? See end of post!

When searching for examples, I noticed that many had issues getting this working.
Let me be clear, it wasn’t working for me the first time.
Things i’ve learned:

  • Flash the first initial ESPHome using a USB cable, after that you can connect the module and flash OTA
  • Do not use the standard Uart RX/TX, it didn’t work for me. And messes-up the logging over USB (See baudrate: 0 to turn this off)
  • When connecting D7/D8 and this signal gets pulled down, the wemos won’t boot. (Running wifi connections gets interrupted)
    This is also a sign that RX/TX is switched around!
  • Measure and make sure you have a good, stable 5V power to your LD2410

Here is a post about the RCWL-0516, a similar project, but this one can’t measure distances and person detection won’t work when a person is not moving.

https://www.henriaanstoot.nl/2022/11/14/radar-module-rcwl-0516-with-mqtt/

Steps to take:

  • Flash ESPHome over USB
  • Detect and add using Home Assistant
  • Edit and upload code (below)
  • Connect the sensor

Wire it up like this:

20240419 image corrected

ESPHome YAML:

Parts i’ve changed:
board: Changed from esp-1?? to d1_mini
logger: baud_rate: 0
tx_pin and rx_pin

esphome:
  name: ld2410-1
  friendly_name: ld2410-1

esp8266:
  board: d1_mini

# Enable logging
logger:
  baud_rate: 0

# Enable Home Assistant API
api:
  encryption:
    key: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx="

ota:
  password: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Ld2410-1 Fallback Hotspot"
    password: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

captive_portal:
    
ld2410:
  id: ld2410_radar
  
uart:
  tx_pin: GPIO15
  rx_pin: GPIO13
  baud_rate: 256000
  parity: NONE
  stop_bits: 1

number:
  - platform: ld2410
    timeout:
      name: Radar Timeout
    max_move_distance_gate:
      name: Radar Max Move Distance
    max_still_distance_gate:
      name: Radar Max Still Distance
    g0:
      move_threshold:
        name: g0 move threshold
      still_threshold:
        name: g0 still threshold
    g1:
      move_threshold:
        name: g1 move threshold
      still_threshold:
        name: g1 still threshold
    g2:
      move_threshold:
        name: g2 move threshold
      still_threshold:
        name: g2 still threshold
    g3:
      move_threshold:
        name: g3 move threshold
      still_threshold:
        name: g3 still threshold
    g4:
      move_threshold:
        name: g4 move threshold
      still_threshold:
        name: g4 still threshold
    g5:
      move_threshold:
        name: g5 move threshold
      still_threshold:
        name: g5 still threshold
    g6:
      move_threshold:
        name: g6 move threshold
      still_threshold:
        name: g6 still threshold
    g7:
      move_threshold:
        name: g7 move threshold
      still_threshold:
        name: g7 still threshold
    g8:
      move_threshold:
        name: g8 move threshold
      still_threshold:
        name: g8 still threshold

binary_sensor:
  - platform: ld2410
    has_target:
      name: Radar Target
      id: radar_has_target
    has_moving_target:
      name: Radar Moving Target
    has_still_target:
      name: Radar Still Target
button:
  - platform: ld2410
    factory_reset:
      name: "factory reset"
    restart:
      name: "restart"
    query_params:
      name: query params

sensor:
  - platform: ld2410
    moving_distance:
      name: Radar Moving Distance
      id: moving_distance
    still_distance:
      name: Radar Still Distance
      id: still_distance
    moving_energy:
      name: Radar Move Energy
    still_energy:
      name: Radar Still Energy
    detection_distance:
      name: Radar Detection Distance
      id: radar_detection_distance
    g0:
      move_energy:
        name: g0 move energy
      still_energy:
        name: g0 still energy
    g1:
      move_energy:
        name: g1 move energy
      still_energy:
        name: g1 still energy
    g2:
      move_energy:
        name: g2 move energy
      still_energy:
        name: g2 still energy
    g3:
      move_energy:
        name: g3 move energy
      still_energy:
        name: g3 still energy
    g4:
      move_energy:
        name: g4 move energy
      still_energy:
        name: g4 still energy
    g5:
      move_energy:
        name: g5 move energy
      still_energy:
        name: g5 still energy
    g6:
      move_energy:
        name: g6 move energy
      still_energy:
        name: g6 still energy
    g7:
      move_energy:
        name: g7 move energy
      still_energy:
        name: g7 still energy
    g8:
      move_energy:
        name: g8 move energy
      still_energy:
        name: g8 still energy

Bluetooth:

I’ve connected this HLK-DL2410B to Home Assistant before using Bluetooth. But I wanted to get them connected using Wifi.

You can install an App on your phone to connect to the sensor when powered on.
This way you can test the device, but also upgrade the firmware and make adjustments!

Just enable engineering mode and click more.

Testing another baud rate and upgrading the firmware:

2 thoughts on “HLK-LD2410B with a Wemos Mini D1 (v4) connected to Home Assistant using ESPHome”

  1. Important to note here, the author talks about RX/TX being swapped at numerous times, but they never updated the picture. So pay attention to the note under the diagram that says ” TURN YELLOW AND BLUE AROUND”. This means the picture is NOT accurate. you need to swap the wires.

    I finally got it to show up in HA but it’s seemingly going haywire. it constantly shows motion every couple seconds despite nothing moving. I’ve tried to play with the configuration sliders but it doesn’t seem to do anything. It’d help if there was some more info about how to configure it. Can you really just mess with the sliders or do you have to do something else? And I don’t see any values for the Diagnostic part either.

    The LD2410 seems promising but in practice it’s been way too squirrely for me to use. It doesn’t seem to have a front face and detects motion all around it (and even when nothing is really there sometimes).

  2. Good to know someone read the post thoroughly and sends some feedback.
    Thanks
    I will go through this post again and update where needed.
    That’s the problem using this as a lab log.

Leave a Reply

Your email address will not be published. Required fields are marked *