LD2410 esphome tips

Yes. The functionality you’re searching for is implemented there - and still didn’t make it to main ESPHome, despite being highly requested…

Has anyone got multiple ld2410 to work on a single esp32? I have this working perfectly on an esp8266 and esp32 with only 1 ld2410 on each, but would like to run 3 off of 1 esp32. The esp32 has 3 hardware UARTs, so I believe it should work. However, I either have the code wrong of maybe the ESPHome-LD2410 code doesn’t support this function yet? Could anyone review my sample code below and let me know if I’m defining my multiple sensors and binary sensors incorrectly? Thanks!

The error is [uart_id] is an invalid option for [sensor.ld2410]. Please check the indentation. If I try just id: instead of uart_id:, I get the same message telling my it’s an invalid option.

esphome:
  name: test-esp32
  friendly_name: test-esp32

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:
  level: INFO
  baud_rate: 0

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

ota:
  password: "removed"

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Test-Esp32 Fallback Hotspot"
    password: "removed"

captive_portal:

uart:
  - id: UART0
    tx_pin: 1
    rx_pin: 3
    baud_rate: 256000
    parity: NONE
    stop_bits: 1

  - id: UART1
    tx_pin: 9
    rx_pin: 10
    baud_rate: 256000
    parity: NONE
    stop_bits: 1

ld2410:
  - uart_id: UART0
    timeout: 150s
    max_move_distance: 6m
    max_still_distance: 6m
    g0_move_threshold: 50
    g1_move_threshold: 50  
    g2_move_threshold: 40  
    g3_move_threshold: 30  
    g4_move_threshold: 30  
    g5_move_threshold: 20
    g6_move_threshold: 20
    g7_move_threshold: 40
    g8_move_threshold: 40
    g0_still_threshold: 20
    g1_still_threshold: 20
    g2_still_threshold: 20
    g3_still_threshold: 20
    g4_still_threshold: 20
    g5_still_threshold: 20
    g6_still_threshold: 20
    g7_still_threshold: 30
    g8_still_threshold: 30

  - uart_id: UART1
    timeout: 150s
    max_move_distance: 6m
    max_still_distance: 6m
    g0_move_threshold: 50
    g1_move_threshold: 50  
    g2_move_threshold: 40  
    g3_move_threshold: 30  
    g4_move_threshold: 30  
    g5_move_threshold: 20
    g6_move_threshold: 20
    g7_move_threshold: 40
    g8_move_threshold: 40
    g0_still_threshold: 20
    g1_still_threshold: 20
    g2_still_threshold: 20
    g3_still_threshold: 20
    g4_still_threshold: 20
    g5_still_threshold: 20
    g6_still_threshold: 20
    g7_still_threshold: 30
    g8_still_threshold: 30

sensor:
  - platform: ld2410
    uart_id: UART0
    moving_distance:
      name : Moving Distance s1
    still_distance:
      name: Still Distance s1
    moving_energy:
      name: Move Energy s1
    still_energy:
      name: Still Energy s1
    detection_distance:
      name: Detection Distance s1

  - platform: ld2410
    uart_id: UART1
    moving_distance:
      name : Moving Distance s2
    still_distance:
      name: Still Distance s2
    moving_energy:
      name: Move Energy s2
    still_energy:
      name: Still Energy s2
    detection_distance:
      name: Detection Distance s2

binary_sensor:
  - platform: ld2410
    uart_id: UART0
    has_target:
      name: Presence s1
    has_moving_target:
      name: Moving Target s1
    has_still_target:
      name: Still Target s1

  - platform: ld2410
    uart_id: UART1
    has_target:
      name: Presence s2
    has_moving_target:
      name: Moving Target s2
    has_still_target:
      name: Still Target s2

Source - esp32 3 hardware UARTs: Logger Component — ESPHome

Perhaps I need to post on the project’s github page, but thought I’d start here. Thank you in advance. GitHub - rain931215/ESPHome-LD2410: ESPHome LD2410 mmWave Radar Sensor Custom Component

Update: I realized I can program the LD2410C with my FTDI adapter and a program via computer, or use the Android app to program via Bluetooth. This allowed me to do an OTA firmware update via the Android app, set the sensitivity, then just use the 1 “out” pin on the sensor to monitor for human presence. Source: Using the 4G Network to Save my Friends Treasures! - YouTube

After completing testing and finding I got the same presence detection results, I switched to using the following for a 1 wire sensor setup (plus power and ground).

binary_sensor:
  - platform: gpio
    name: "Motion Presence test"
    pin:
      number: D5
      mode: INPUT_PULLUP
    device_class: motion

I can do more of a write up on how to use the app for Android if anyone is interest. I bought 12 of these ld2410c to replace the PIR sensors around my house, so I’m trying to get away from needing 12 d1 mini’s to run all these using uart! This will allow me to run 5 of these from one d1 mini.

Use these links at your own risk, but these are the most official links I could find.

HLK’s Android app to configure these sensors over BT (There is an English version link in the bottom right corner of page) - HLKRadarTool The app supports firmware updates; beta 2.04.x enables the photosensor and allows it to be configured. The photosensor allows you to require the light brightness to be above or below a set threshold before motion will make the out pin go high. Example, this could be used if you wanted the pin to turn on a relay that powers a light and you only want motion to turn on the light if it’s dark in the room. BTW, some of my sensors came with current firmware and some came with new beta firmware. I tested the OTA firmware update and it worked great; just requires a power cycle of the sensor after.

HLK’s Windows tool to configure these sensors over serial via FTDI adapter (HLK-LD2410B works for C also) - Radar Module_ Docs Download _ Shenzhen Hi-Link Electronic Co., Ltd. (direct link do download page HLK-LD2410B - Google Drive)

Final tip to share; after factory resetting the sensor in the app, these are the gate thresholds it reset to and I think they are the best I’ve tested yet if you want to get max distance and accuracy from the sensor! It can detect me breathing from 6 meters away and keep the presence sensor active!

    timeout: 150s
    max_move_distance: 6m
    max_still_distance: 6m
    g0_move_threshold: 50
    g1_move_threshold: 50  
    g2_move_threshold: 40  
    g3_move_threshold: 30  
    g4_move_threshold: 20  
    g5_move_threshold: 15
    g6_move_threshold: 15
    g7_move_threshold: 15
    g8_move_threshold: 15
    g0_still_threshold: 60
    g1_still_threshold: 60
    g2_still_threshold: 40
    g3_still_threshold: 40
    g4_still_threshold: 30
    g5_still_threshold: 30
    g6_still_threshold: 20
    g7_still_threshold: 20
    g8_still_threshold: 20
1 Like

How did you adjust the sensitivity range? I don’t see anywhere for this option, I also have no idea where you were able to get this pic/screenshot from. Some help would be very much appreciated as I’m looking to do exactly the same thing.

First error i see is uart’s names: from 2023.4 it’s not allowed to name it “uart0” anymore, but you must name it “uart_0”. Uart0, uart1….is reserved for variables.

Are you sure timeout: 150s is there in factory settings?
When I use this option on my sensor it only turns off the presence binary sensor 150 sec after the last detection event. Which, if used to trigger lights, is a very long time to wait for the light to turn off after you have left the room.

Other than that, I agree on these settings being quite good.
In any case, do not use the ones from the yaml sample on esphome page! These are really bad.

@Wayne_Perryman If you’re using Android like me, I linked to the Android APK I sideloaded on my phone, to configure each of these ld2410c via Bluetooth.

This has worked great, especially since I can name each sensor in the app. If you’re using iOS, the documentation says the app can be found in the store with the name “HLKRadarTools”. This app isn’t in the Google Play Store, hence the sideloading.

Here are some screenshots from the app after I picked one of my sensors from the list. Toggling on Engineering mode allows you to see the graphs with real-time data. The purple line for moving and static are the settings at each “gate”; with each gate being distance from the sensor from 0 to 6 meters. The blue line is detected motion. You can tap on each line graph to get exact numerical values; which would help if you’re trying to fine tune this.

When you click More in the top right corner, you get this configuration page. From here, you can set the “unattended” value, which is how long the “out” pin will stay high after it detects presence. So far, I like 150 seconds so it has enough time to continue to detect motion without my room lights overly cycling on and off.

“Photosensitive set” value sets the threshold of the photosensor on the first image, at the bottom of the page. You set that as your cutoff for the “under” or “overtop” options. The “close” option seems to disable this feature. I could have this reversed from when I tested this, but I think overtop meant the photosensor value/reading has to be over the threshold value, otherwise presence will not set the out pin to high. The under option meant the photosensor value/reading has to be under the threshold value, otherwise presence will not set the out pin to high. Example: if you have the out pin control a relay that turns a light on, then you can have it only turn the relay/light on if the room is dark enough.

The “energy” settings are for how sensitive you want the sensor to be at each gate, or distance from 0 to 6 meters from the sensor. 0 is the most sensitive and 100 is the least sensitive. The sensor will always require a trigger from “energy of motion” to detect presence, then “energy at rest” will keep it active (or keep the pin high). This helps to keep false positives from “energy at rest” from triggering presence.

Hopefully I explained that well enough, but this is what I’ve figured out from playing with this sensor for a bit. I’ve now replaced 3 of my PIR sensors with this ld2410c sensor and I’m only using 3 wires (power, ground, out) to detect presence in Home Assistance using ESPHome.

11 Likes

@Rafaille Correct, those are only the gate thresholds it reset to. The default timeout was 5 seconds on my sensor. I am using 150 seconds to give the sensor enough time to detect me walking around a room and account for any blind spots, so my lights don’t turn off inadvertently. Glad you like these setting as well and I agree, the default settings suggested on the sample yaml were not good for my use either. :slight_smile:

@Protoncek Thanks for pointing out that ESPHome change. UART id change I had tested other names initially in my config and tested your recommendation also, but still get the same error in the ESPHome editor. I provided a full copy of the esphome config, if anyone would like to try and copy/paste the full config details into your editor, if anyone would like to try and get around the error? It seems to not like uart_id as a valid option under sensor and binary_sensor for the ld2410 platform. This is what makes me wonder if the ld2410 code has to support this multiple uart feature?

Did anyone succeeded to connect the LD2410 (Non B variant) via the LD2410 Tool on Windows? When I use an USB FTDI Adapter (genuine one) it fails to open the port… Set the baud rate to 9600 in the tool but that also fails. Any hints? I want to change the gate settings.

@muffin44 - I was able to connect to my LD2410C with the LD2410 Tool on Windows using an USB FTDI Adapter. RX on the adapter goes to TX on the sensor and TX to RX. Note: make sure you set the jumper on the FTDI Adapter to 5v since 3.3v is too low and it won’t work; just confirmed this. :wink: The baud rate should be 256000. See what COM ports are listed in the dropdown before you connect the USB adapter to Windows, then connect the adapter and hit refresh. The new COM port will be your adapter.

1 Like

A Few Questions
I have a ld2410 (not b or c) just plain.
It is working in conjuction with a d1 mini. At least it shows me data.

I have looked for an explaination of the data it shows in esp home, can some one show me where I might find it to understand what all the things do.

Also are there any automations using it. This is a lot different than my pir sensors and am having trouble wrapping my head around what data I need to take into account to create an automation.

Lastly is there an HLK app for a non bluetooth version. The link shown in many posts above is only for a bluetooth version.

Thanks to the community for any help or links.

I did exactly the same. Funny that it worked today maybe after I shut down and freshly booted my pc…

Look at my post and smoke.007 post. You have to connect the sensor via an USB FTDI adapter to your pc and use the LD2410 Tool. on Windows.

Also have a look at the link on the manual.

@carltonb In HA, under Devices & Services, find your esp device (d1 mini) that you brought into HA. You should see all your new sensors created for the ld2410. I recommend the threshold and other settings from my post LD2410 esphome tips - #251 by smoke.007. These should be configured within your esphome config for your d1 mini. Once you have these values working well for presence detection, I was simply using only the binary_sensor.%yourESPdevicename%_presence sensor. I think it’s value was only on or off, depending if it detected human presence. Honestly, for a simple automation that does something if there is human movement, use that sensor as a trigger when the value = on, then value = off means no human movement. This will work just like your PIR sensor.

For testing, use a small value for timeout in your esphome device code, like 5 seconds, then increase to something like 150 seconds later to keep it from cycling on/off too often.

Only app for ld2410 (non-BT) version is the Windows tool; however, you’d only use that if you want to program the ld2410 so you can use the out pin, not the uart tx/rx pins. Programing it and using the out pin allows you to use the sensor just like your PIR sensor; this is what I’m doing now for my all my ld2410c sensors since I don’t need all the other sensor values that I can get with uart. I just wanted presence detection that’s tons better than PIR sensor, can detect me breathing from 18ft away, and keep the presence sensor activated while I’m sitting at my desk.

Same here , using ESP32 , could you solve this ?

I have to buy a bluetooth proxy to connect and it’s working

All my LD’s are with BT, i won’t even buy one without it. The price difference is so minimal than it’s not worthed even to think of buying anything but with BT. IF you have it you can use it …or not. If you don’t have it, you’re stuck…
It’s super easy to configure/alter settings, and you can always use it standalone (without ESP) - just attach a relay and voila - light goes on (and off…).

Firmware 2.05.xxxx for the LD2410 was released but after updating 3 of my sensors I can no longer see them via BT. They appear to keep working via UART but are no longer visible in the Android app (1.1.15). Anyone else have this issue?

Unrelated but just plain funny: HLK-LD2411 24Ghz intelligent toilet radar sensor module gesture recognition induction automatic flipping and flushing_Radar Module_Products_ Shenzhen Hi-Link Electronic Co., Ltd.
Made to detect your toilet action… by “microwaving” your rear end… ROFL

EDIT: For anyone who installed firmware 2.05.xxxx (now pulled), BT is turned off by default. I installed the dev version of ESPHome so that I could use the pending upgrade to the ld2410 integration which support turning BT on and off via serial. Once turned back on, the sensor was back to normal… The manual does say that you can reset the sensor by powering it up and down 5 times in 2-3s but either I was unable to do it that fast or the default is off so resetting it does not turn it back on. Either way, doing it via serial works… too bad we are still waiting for the new integration to be merged in otherwise it would have been a super easy fix.

1 Like

Hi guys. Can someone please post the yaml integration of this LD2410 as a simple binary sensor for presence detection if only connected via th OUT GPIO to an ESP32 GPIO pin without the UART serial protocol?
Thank you

Thanks to @lukcz . I don’t know if it is a bug or a printing error on the boards. My hardware combination is the following,

  • ESP32 D1 Mini
  • LD2410C

RX → RX
TX → TX

All is detected now. I have an issue of presence always ON. Might be too sensitive.

binary_sensor:
  - platform: gpio
    pin: GPIO5
    name: gpio out pin presence
    device_class: presence