LD2410 esphome tips

Has anybody managed to get the LD2410 working with the ESP32 minikit?

anyone was able get LD2410C to work with esp32 devkit v1 30pin ? I am getting unknowns for all the sensors. please send me the config and let me know which pins for TX and RX. Thanks!

I have it working with ESP32 Wemos D1 Mini. Nothing special that I recall while configuring it:

i2c:
  sda: 21
  scl: 22
  scan: true
  id: bus_a
 
uart:
  id: ld2410_uart
  tx_pin: RX
  rx_pin: TX
  baud_rate: 256000
  parity: NONE
  stop_bits: 1
 
ld2410:
  uart_id: ld2410_uart
  throttle: $throttle
  id: ld2410_comp
 
select:
  - platform: ld2410
    distance_resolution:
      name: distance resolution
    baud_rate:
      name: baud rate
    light_function:
      name: light function
    out_pin_level:
      name: out pin level

This is the part of the configuration relative to the connection between the ESP32 and the LD2410. In your case I think you should use pin 42 por SDA (gpio21) and pin 39 for SCL (gpio22)

1 Like

Thanks - I am going to try it. how do you decide to use PIN 39 and 41 instead of 25,27 for RX / TX? I used the latter because I assumed those are TX.RX pins

I’m really struggling to get the LD2410 to work for automating my lights. I’ve fitted it in an existing PIR and it all works but a little TOO well unfortunately.

I’ve done the calibration for the room and it all works perfect but then… it keeps detecting people in the next room and the floor above. Making it less sensitive means it doesn’t work as it should when I’m actually in the room so I’m a little stumped on how to proceed from here. Any tips?

turn the sensitively down or reduce the distance so your not picking people up in other rooms

The LD2410 can be tweaked quite extensively and can take some time to tune but once tuned, works very well.
You can change the number of gates used and that will reduce the effective detection range.
You can also adjust the still and movement thresholds for each gate and that will determine how much movement will trigger the detection for that gate.
A value of 100 will effectively turn off the detection of the gate and 0 means it will detect all the time. Finding the right balance will allow it to detect the desired movement and eliminate false detections.

I believe I copied the configuration from somewhere and then wired the ESP acording to this configuration. Worked fine from the begining…

In my case I tweaked the number of gates and then prepared a dashboard with some custom sensors that triggers when presence is detected in each gate so it records the value that made it trigger. The first step I took was to leave it enabled during the night when I know there should be movement only in the bedroom so I can filter every detection (false positives) during this period increasing the threshold of the gates that triggered. Repeating this (careful with the logs generated while engineering mode is enabled) in different situations can lead to a pretty polished detection ranges and minimize false positives while keeping the best possible detection sensitivity.

I’m using two LD2410c sensors in my garage, one at the dooropening where the light switch would be and one integrated in the casing of my alarm motion sensor, this way the garage is completely covered.
I’ve found that the minimum sensitivity (in my case) is 15, anything below results in false triggers.
I’m using all 8 gates and don’t have any false triggers.
but just out of curiosity, the lights in my garage are controlled using a relay connected to an espboard and is triggered by the ld2410 sensors, the opening of the garage doors, etc…
is there a way to delay the relay when turned off for x time before to be able to turn back on? like a condition when the relay is turned off it has to wait x seconds before it can be turned on again? (not a delayed turn on, the relay must be turned on immediately when triggered and the wait condition is over)

Hello all!
Not sure did someone manage to do it or not, but i’m trying to set up my esp32-c6 and ld2410C to report via MQTT.

This is my confing

esphome:
  name: "esp32-c6-mqtt"
  friendly_name: "MQTT test"

esp32:
  board: esp32-c6-devkitc-1
  variant: esp32c6
  framework:
    type: esp-idf
    version: 5.1.0
    platform_version: https://github.com/stintel/platform-espressif32#esp32-c6-test

logger:

mqtt:
  broker: xxx.xxx.xxx.xxx
  username: xxxxxxxx
  password: xxxxxxxx-mqtt_pwd
  discovery_prefix: "ha-mqtt-test"
  discovery_unique_id_generator: mac

status_led:
  pin:
    number: GPIO02
    inverted: true

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

wifi:
  ssid: "xxxxx"
  password: "xxxxx"

i2c:
   - id: bus_a
     sda: 21
     scl: 22
     scan: true

uart:
  id: uart_bus
  tx_pin: GPIO16
  rx_pin: GPIO17
  baud_rate: 256000
  parity: NONE
  stop_bits: 1
  debug:
    direction: BOTH
    dummy_receiver: false
    after:
      delimiter: [0xF8,0xF7,0xF6,0xF5]


ld2410:
  id: my_ld2410

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: Presence
    has_moving_target:
      name: Moving Target
    has_still_target:
      name: Still Target


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
  - platform: wifi_signal # Reports the WiFi signal strength/RSSI in dB
    name: "WiFi Signal dB"
    id: wifi_signal_db
    update_interval: 60s
    entity_category: "diagnostic"

  - platform: copy # Reports the WiFi signal strength in %
    source_id: wifi_signal_db
    name: "WiFi Signal Percent"
    filters:
      - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
    unit_of_measurement: "Signal %"
    entity_category: "diagnostic"
  
text_sensor:
  - platform: ld2410
    version:
      name: "mmWave Firmware Version"
    mac_address:
      name: "mmWave MAC Address"
  - platform: wifi_info
    ip_address:
      name: ESP IP Address
      icon: mdi:ip
    ssid:
      name: ESP Connected SSID
      icon: mdi:wifi
    bssid:
      name: ESP Connected BSSID
    mac_address:
      name: ESP Mac Wifi Address
    scan_results:
      name: ESP Latest Scan Results
    dns_address:
      name: ESP DNS Address

switch:
  - platform: restart
    name: "Presence Sensor Restart"

It’s not reporting anyting at all, and there is nothing in the logs

The only thing that it’s reporting is the wifi stuff

Any idea what may be the issue?

Hey @Still_ill how did you get the lux value reading?
I’m going nuts as the BH1750 sensor does not return any value, it’s unknown state!

Don’t know about c6
But made mqtt for my s2 (using API for now)
But if i’m correct - you don’t declare “state_topic” for values to publish.

This is just part of code, I have all substitutions in separate yaml.

esphome:
  name: ${esp_name}
  friendly_name: ${esp_friendly}
  platformio_options:
    board_build.f_cpu: 80000000L
#    board_build.flash_mode: dio

esp32:
  board: lolin_s2_mini
  variant: esp32s2

logger:
  level: WARN
  baud_rate: 0 #Important. You can't use serial port
#  hardware_uart: UART0

debug:
  update_interval: 30s

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  output_power: 15dB
  reboot_timeout: 10min

  #important, otherwise the IP could change and then the entity is unavailable from home assistant.
  manual_ip:
    static_ip: ${ipstatic}
    gateway: IP
    subnet: MASK

# Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: ${esp_friendly}
    password: !secret ap_wifi_pass
captive_portal:

# Enable Home Assistant API
api:
  encryption:
    key: !secret api_key
    
ota:

# Web config
#web_server:
#  include_internal: true
#  ota: false

uart:
  #HLK
  - id: ${hlk_uart}
    tx_pin: GPIO18
    rx_pin: GPIO33
    baud_rate: 256000 # Change this according to your setting
    parity: NONE
    stop_bits: 1

mqtt:
# HLK
  broker: MQTT IP adress 
  username: !secret ha_mqtt_user
  password: !secret ha_mqtt_pass
  discovery: false
  client_id: ${hlk_id}
  topic_prefix: null
  id: ${hlk_id}_mqtt

light:
  - platform: status_led
    name: ESP status led
    pin: GPIO15
    internal: True
    restore_mode: ALWAYS_OFF

ld2410:
  id: ${hlk_id}
  uart_id: ${hlk_uart}
  throttle: 1000ms

text_sensor:
  # Common
  - platform: debug
    reset_reason:
      name: "ESP Reset Reason"
      icon: mdi:anchor
  - platform: wifi_info
    ip_address:
      name: "ESP WiFi IP"
      icon: mdi:ip-network
    ssid:
      name: "ESP WiFi SSID"
      icon: mdi:wifi
    mac_address:
      name: "ESP WiFi Mac"
      icon: mdi:ip-network
  # HLK
  - platform: ld2410
    version:
      name: "HLK Firmware"
    mac_address:
      name: "HLK BT Mac"

binary_sensor:
  # Common
  - platform: status
    name: ESP Online
    id: ha_connected
  # HLK
  - platform: ld2410
    has_target:
      name: "HLK Presence"
      state_topic: ${hlk_topic_prefix}/${hlk_id}
    has_moving_target:
      name: "HLK Moving Target"
      filters:
        - delayed_off: 1s
      state_topic: ${hlk_topic_prefix}/${hlk_id}
    has_still_target:
      name: "HLK Still Target"
      state_topic: ${hlk_topic_prefix}/${hlk_id}
    out_pin_presence_status:
      name: HLK Out Pin Status
  - platform: gpio
    pin:
      number: GPIO16
      mode:
        input: true
        pullup: true
    name: HLK Out Pin Presence
    device_class: presence
#    filters:
#      - delayed_off: 10ms

switch:
  # HLK
  - platform: ld2410
    engineering_mode:
      name: "HLK engineering mode"
    bluetooth:
      name: "HLK bluetooth"

button:
  # Common
  - platform: restart
    name: "ESP Restart"
  - platform: safe_mode
    name: "ESP Restart (Safe Mode)"
  # HLK
  - platform: ld2410
    factory_reset:
      name: "HLK Factory reset"
    restart:
      name: "HLK Restart"
    query_params:
      name: "HLK Query params"

sensor:
  # Common
  - platform: wifi_signal
    name: "ESP WiFi RSSI"
    id: wifi_signal_rssi
    update_interval: 60s
    entity_category: "diagnostic" 
  - platform: internal_temperature
    name: "ESP Temperature"
    unit_of_measurement: °C
    device_class: TEMPERATURE
    update_interval: 30s
    entity_category: "diagnostic"
  - platform: uptime
    name: "ESP Uptime"
    id: sys_uptime
    update_interval: 60s
  - platform: debug
    free:
      id: esp_memory
      icon: mdi:memory
      name: ESP Free Memory
      filters:
        - lambda: return x / 1024;
      unit_of_measurement: 'kB'
      state_class: measurement
      entity_category: "diagnostic"

  #HLK
  - platform: ld2410
    light:
      name: HLK Light level
    moving_energy:
      name: "HLK Move Energy"
    still_energy:
      name: "HLK Still Energy"
    g0:
      move_energy:
        name: "HLK g0 move energy"
      still_energy:
        name: "HLK g0 still energy"
    g1:
      move_energy:
        name: "HLK g1 move energy"
      still_energy:
        name: "HLK g1 still energy"
    g2:
      move_energy:
        name: "HLK g2 move energy"
      still_energy:
        name: "HLK g2 still energy"
    g3:
      move_energy:
        name: "HLK g3 move energy"
      still_energy:
        name: "HLK g3 still energy"
    g4:
      move_energy:
        name: "HLK g4 move energy"
      still_energy:
        name: "HLK g4 still energy"
    g5:
      move_energy:
        name: "HLK g5 move energy"
      still_energy:
        name: "HLK g5 still energy"
    g6:
      move_energy:
        name: "HLK g6 move energy"
      still_energy:
        name: "HLK g6 still energy"
    g7:
      move_energy:
        name: "HLK g7 move energy"
      still_energy:
        name: "HLK g7 still energy"
    g8:
      move_energy:
        name: "HLK g8 move energy"
      still_energy:
        name: "HLK g8 still energy"

number:
  # HLK
  - platform: ld2410
    timeout:
      name: "HLK Timeout"
    light_threshold:
      name: HLK light threshold
    max_move_distance_gate:
      name: "HLK Move distance gate max"
    max_still_distance_gate:
      name: "HLK Still distance gate max"
    g0:
      move_threshold:
        name: "HLK g0 move threshold"
      still_threshold:
        name: "HLK g0 still threshold"
    g1:
      move_threshold:
        name: "HLK g1 move threshold"
      still_threshold:
        name: "HLK g1 still threshold"
    g2:
      move_threshold:
        name: "HLK g2 move threshold"
      still_threshold:
        name: "HLK g2 still threshold"
    g3:
      move_threshold:
        name: "HLK g3 move threshold"
      still_threshold:
        name: "HLK g3 still threshold"
    g4:
      move_threshold:
        name: "HLK g4 move threshold"
      still_threshold:
        name: "HLK g4 still threshold"
    g5:
      move_threshold:
        name: "HLK g5 move threshold"
      still_threshold:
        name: "HLK g5 still threshold"
    g6:
      move_threshold:
        name: "HLK g6 move threshold"
      still_threshold:
        name: "HLK g6 still threshold"
    g7:
      move_threshold:
        name: "HLK g7 move threshold"
      still_threshold:
        name: "HLK g7 still threshold"
    g8:
      move_threshold:
        name: "HLK g8 move threshold"
      still_threshold:
        name: "HLK g8 still threshold"

select:
  # HLK
  - platform: ld2410
    distance_resolution:
      name: "HLK distance resolution"
    baud_rate:
      name: "HLK baud rate"
    light_function:
      name: "HLK light function"
#    out_pin_level:
#      name: "HLK Out Pin Level"

The BH1750 must run via i2c. Here is the matching section of my yaml.

i2c:
  sda: 4
  scl: 5
  scan: true
  id: bus_a
sensor:
  - platform: bh1750
    name: "BH1750 Illuminance"
    address: 0x23
    update_interval: 10s

For wiring:

  • SCL to D1

  • SDA to D2

on the Esp8266

Here is the complete yaml, if necessary:

esphome:
  name: esphome-web-ee2675
  friendly_name: mmWave Bad
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.XX.XX
    gateway: 192.168.XX.XX
    subnet: 255.255.255.0
  ap:
    ssid: "Esphome-Web-Ee2675"
    password: "XXXXXXXXXX"

captive_portal:

logger:

api:
  encryption:
    key: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

ota:

i2c:
  sda: 4
  scl: 5
  scan: true
  id: bus_a

uart:
  id: ld2410_uart
  tx_pin: GPIO1
  rx_pin: GPIO3
  baud_rate: 256000
  parity: NONE
  stop_bits: 1

ld2410:
  uart_id: ld2410_uart
  id: ld2410_comp

number:
  - platform: ld2410
    timeout:
      name: "Timeout"
    light_threshold:
      name: "Light Threshold"
    max_move_distance_gate:
      name: "Max Move Distance Gate"
    max_still_distance_gate:
      name: "Max Still Distance Gate"
    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"

select:
  - platform: ld2410
    distance_resolution:
      name: "Distance Resolution"
    baud_rate:
      name: "Baud Rate"
    light_function:
      name: "Light Function"
    out_pin_level:
      name: "Out Pin Level"

sensor:
  - platform: ld2410
    light:
      name: "Light"
    moving_distance:
      name: "Moving Distance"
    still_distance:
      name: "Still Distance"
    moving_energy:
      name: "Move Energy"
    still_energy:
      name: "Still Energy"
    detection_distance:
      name: "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"

  - platform: bh1750
    name: "BH1750 Illuminance"
    address: 0x23
    update_interval: 10s

  - platform: bme280_i2c
    temperature:
      name: "BME280 Temperature"
      oversampling: 16x
    pressure:
      name: "BME280 Pressure"
    humidity:
      name: "BME280 Humidity"
    address: 0x76
    update_interval: 60s

binary_sensor:
  - platform: ld2410
    has_target:
      name: "Presence"
    has_moving_target:
      name: "Moving Target"
    has_still_target:
      name: "Still Target"
    out_pin_presence_status:
      name: "Out Pin Presence Status"

  - platform: gpio
    pin:
      number: 12
      mode: INPUT_PULLUP
      inverted: true
    name: "PIR Sensor"
    device_class: motion

switch:
  - platform: ld2410
    engineering_mode:
      name: "Engineering Mode"
    bluetooth:
      name: "Control Bluetooth"

button:
  - platform: ld2410
    factory_reset:
      name: "Factory Reset"
    restart:
      name: "Restart"
    query_params:
      name: "Query Params"

text_sensor:
  - platform: ld2410
    version:
      name: "Firmware Version"
    mac_address:
      name: "MAC"

Many many thanks for sharing, I’ve just used the i2c code modified as follow to match my esp32 Wroom-32D board but still getting no results :frowning:

i2c:
  sda: 21
  scl: 22
  scan: true
  id: bus_a
sensor:
  - platform: bh1750
    name: "BH1750 Illuminance"
    address: 0x23
    update_interval: 30s


I’ve just one Dupont to connect to the out pin on the ld2410c so tried both on SCL and SDA but not working.

Sorry if it sounds like a noob question but I’m approaching HA and the ESP32 world in these very days, read a lot but am practicing now!

Any tip?

Ok, you have used GPIO 21 and 23, which is good. I can’t see anything wrong with that either. Where did you connect your ld2410? These must be cross-connected to tx and rx. On the Esp32 and should be GPIO 17 and 16. But better check this again.

yep they are cross connected and all the entities on the ld2410c are working just fine but the infamous illumiance sensor!
Can’t figure out why!

Maybe is something with the soldering of pins from the BH1750. If you have the possibility to check with another BM1750. I had also problems with this sensor. After resoldering the pins everything works fine on my end.

I agree with itapower: In this case, I would check the soldering or test a new sensor directly. The configuration looks flawless to me

I have range problems with my ESP32 Wroom-32 LD2410C solution.
Soldered 5V, GND and TX, RX (Pin 16, 17) together and booted up next to my HA Server, it works just fine.
In my floor, round about 6m away, with 2 walls in between, I do not get a connection. I tried a bluetooth proxy and also a ESP32 Repeater to bridge between server and LD2410, but I am still not successful.
Can someone explan me, if the LD2410 works via Wifi, when connected to an ESP32 or still via the BT of the ESP?
What is the best strategy to hit the range problems?