LD2410 esphome tips

Here is another way of doing it and I think this way is immediate:

binary_sensor:
  - platform: ld2410
    has_target:
      name: "Presence"
      on_press:
        then:
          lambda: |-
            id(presence_boolean).publish_state(1);
      on_release:
        then:
          lambda: |-
            id(presence_boolean).publish_state(0);
    has_moving_target:
      name: "Moving Target"
      on_press:
        then:
          lambda: |-
            id(movingtarget_boolean).publish_state(1);
      on_release:
        then:
          lambda: |-
            id(movingtarget_boolean).publish_state(0);

sensor:
  - platform: template
    name: Presence-Boolean
    id: presence_boolean
  - platform: template
    name: MovingTarget-Boolean
    id: movingtarget_boolean
3 Likes

success - publish_state was the solution. now its fast acting and the :bulb: comes on in time :smiley: thanks a lot.

1 Like

Anyone using the ld2410 sensor and bluetooth proxy on the same board?
What board model are you using?
Could you post the yaml?

I would like to use 2 boards where I use the 2410 with BT proxy, but I am facing space and/or memory problems.

Just in case anyone struggles with a DFRobot SEN0557 (ld2410), I had to set the baud rate to 57000 and it started working. It is specified on their data site - 24GHz Human Presence Sensing Module Wiki - DFRobot

Hi All
I wonder if somebody can help me or put me in the right direction. I am having an issue where g0 & g1 Still Energy is always set to zero.

Code was copied from “Smart Home Scene” with name changed

substitutions:
  name: ld2410-openplan
  friendly_name: LD2410-OPENPLAN-Presence_Sensor

esphome:
  name: "${name}"
  friendly_name: "${friendly_name}"

esp32:
  board: esp32dev
  framework:
    type: esp-idf

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: !secret ld2410_openplan_api_key

ota:
  - platform: esphome
    password: !secret ld2410_openplan_ota_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.1.*
    gateway: 192.168.1.*
    subnet: 255.255.255.0

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: !secret ld_2410_openplan_fbh_ssid
    password: !secret ld_2410_openplan_fbh_password

captive_portal:

 #Open web port for browser access
web_server:
  port: 80

uart:
  tx_pin: GPIO16
  rx_pin: GPIO17
  baud_rate: 256000
  parity: NONE
  stop_bits: 1

globals:
  - id: cpu_speed
    type: int
    restore_value: no
    initial_value: "0"

ld2410:

#Configuration entities
number:
  - platform: ld2410
    timeout:
      name: "Timeout"
      id: timeout
    
    max_move_distance_gate:
      name: "Max Move Distance"
      id: max_move_distance_gate

    max_still_distance_gate:
      name: "Max Still Distance"
      id: 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"

  # Setting ending of zone 1 occupancy
  - platform: template
    name: "End Zone 1"
    id: z1_end
    device_class: distance
    min_value: 0
    max_value: 600
    step: 10
    mode: box
    update_interval: never
    optimistic: true
    restore_value: true
    initial_value: 100
    icon: "mdi:arrow-collapse-right"
    entity_category: CONFIG

  # Setting ending of zone 2 occupancy
  - platform: template
    name: "End Zone 2"
    id: z2_end
    device_class: distance
    min_value: 0
    max_value: 600
    step: 10
    mode: box
    update_interval: never
    optimistic: true
    restore_value: true
    initial_value: 300
    icon: "mdi:arrow-collapse-right"
    entity_category: CONFIG

  # Setting ending of zone 3 occupancy
  - platform: template
    name: "End Zone 3"
    id: z3_end
    device_class: distance
    min_value: 0
    max_value: 600
    step: 10
    mode: box
    update_interval: never
    optimistic: true
    restore_value: true
    initial_value: 600
    icon: "mdi:arrow-collapse-right"
    entity_category: CONFIG

#Occupancy sensor
binary_sensor:
  - platform: ld2410
    has_target:
      name: "Target"
      id: has_target
    has_moving_target:
      name: "Moving Target"
    has_still_target:
      name: "Still Target"
  ## Set Up Radar Zones Based On Distance
  - platform: template
    name: "Zone 1 Occupancy"
    device_class: occupancy
    icon: mdi:motion-sensor
    lambda: |-
      if ((id(has_target).state) && (id(detection_distance).state < id(z1_end).state)) {
        return true;
      } else {
        return false;
      }
  - platform: template
    name: "Zone 2 Occupancy"
    device_class: occupancy
    icon: mdi:motion-sensor
    lambda: |-
      if ((id(has_target).state) && ((id(z1_end).state < id(detection_distance).state) && (id(detection_distance).state < id(z2_end).state))) {
        return true;
      } else {
        return false;
      }
  - platform: template
    name: "Zone 3 Occupancy"
    device_class: occupancy
    icon: mdi:motion-sensor
    lambda: |-
      if ((id(has_target).state) && ((id(z2_end).state < id(detection_distance).state) && (id(detection_distance).state < id(z3_end).state))) {
        return true;
      } else {
        return false;
      }

#Exposes configuration and status sensors
sensor:
# Device UPTIME
  - platform: uptime
    name: "Uptime"
    id: sys_uptime
    update_interval: 60s

# Device CPU Speed
  - platform: template
    name: "ESP Cpu Speed"
    accuracy_decimals: 0
    unit_of_measurement: Mhz
    lambda: |-
      return (id(cpu_speed));
    entity_category: "diagnostic"

# Device Memory
  - platform: template
    id: esp_memory
    icon: mdi:memory
    name: "ESP Free Memory"
    lambda: return heap_caps_get_free_size(MALLOC_CAP_INTERNAL) / 1024;
    unit_of_measurement: "kB"
    state_class: measurement
    entity_category: "diagnostic"

# Device RSSI
  - platform: wifi_signal
    name: RSSI
    id: wifi_signal_db
    update_interval: 60s
    entity_category: "diagnostic"
  
  - platform: ld2410
    moving_distance:
      name: "Moving Distance"
      id: moving_distance
    still_distance:
      name: "Still Distance"
      id: still_distance
    moving_energy:
      name: "Move Energy"
    still_energy:
      name: "Still Energy"
    detection_distance:
      name: "Detection Distance"
      id: 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"

#Exposes control buttons
button:
  - platform: restart
    icon: mdi:power-cycle
    name: "ESP Reboot"

  - platform: factory_reset
    disabled_by_default: True
    name: "Factory Reset ESP"
    id: factory_reset_all

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

# Exposes Control Switches
switch:
  - platform: ld2410
    bluetooth:
      name: "Control Bluetooth"
      id: bluetooth
    engineering_mode:
      name: "Engineering Mode"
time:
  - platform: sntp
    id: time_sntp

# Firmware Version
text_sensor:
  - platform: ld2410
    version:
      name: "Firmware Version"

# Set Distance Resolution - 0.75m or 0.2m
select:
  - platform: ld2410
    distance_resolution:
      name: "Distance Resolution"

image

Thank you

Have you considered reading the documentation? It doesnt report by magic, you have to tell it what to report.

For your information, I have read the documentation. All my other gates, except gate 0 and gate 1, works fine, hence the question. Pls don’t answer if you don’t want to, I am not forcing you. Just don’t be rude about it.

Justin didn’t respond to you, he responded to Peyo.

The sensor doesn’t report G0 and G1 Still, this is normal.

Wow… should I post my managers number for someone to call now?

Muchas gracias por esta información, ahora he eliminado de la tarjeta toda la info numérica y la he cambiado por estas 2 gráficas. Ahora puedo prescindir hasta de configurar el LD2410 por bluetooth ya que con la misma tarjeta se hace muy fácil hacerlo, es hasta más cómodo.


Thank you very much for this information, I have now removed all the numerical information from the card and replaced it with these 2 graphics. Now I can even do without having to configure the LD2410 via Bluetooth, since it is very easy to do so with the same card, it is even more comfortable.

1 Like

Nice!
Thank you for sharing

Hello,

Did you find a solution for engineering mode turning off directly ?

hi. Is this code for 2 LD2410C sensors still working for you? I have similar code, but the second uart_1 does not work. The only difference I see is the board type. I set it to

board: lolin_s2_mini

hello Danktankk, have you fix this ? can you Send you .yaml ? i have this stuff and my ld2410 Stuck in presence … Reboot help this ist no funny.

thx you

Hi, thanks for this
Couldn’t figure why my previous bars keep going outside the box but yours work fine.
I changed it slightly to show the threshold value instead of the name (g1/g2 etc)
Is it possible to still label both gates number & thrsehold value?

image

type: custom:config-template-card
variables:
  g0MT: states['number.wemos_esp12_mmwave_g0_still_threshold'].state
  g1MT: states['number.wemos_esp12_mmwave_g1_still_threshold'].state
  g2MT: states['number.wemos_esp12_mmwave_g2_still_threshold'].state
  g3MT: states['number.wemos_esp12_mmwave_g3_still_threshold'].state
  g4MT: states['number.wemos_esp12_mmwave_g4_still_threshold'].state
  g5MT: states['number.wemos_esp12_mmwave_g5_still_threshold'].state
  g6MT: states['number.wemos_esp12_mmwave_g6_still_threshold'].state
  g7MT: states['number.wemos_esp12_mmwave_g7_still_threshold'].state
  g8MT: states['number.wemos_esp12_mmwave_g8_still_threshold'].state
entities:
  - sensor.wemos_esp12_mmwave_g0_still_energy
  - sensor.wemos_esp12_mmwave_g1_still_energy
  - sensor.wemos_esp12_mmwave_g2_still_energy
  - sensor.wemos_esp12_mmwave_g3_still_energy
  - sensor.wemos_esp12_mmwave_g4_still_energy
  - sensor.wemos_esp12_mmwave_g5_still_energy
  - sensor.wemos_esp12_mmwave_g6_still_energy
  - sensor.wemos_esp12_mmwave_g7_still_energy
  - sensor.wemos_esp12_mmwave_g8_still_energy
card:
  type: custom:bar-card
  title: Still Energy Test
  direction: up
  columns: 9
  height: 150px
  width: 100%
  positions:
    icon: "off"
    indicator: "off"
    value: inside
  entities:
    - entity: sensor.wemos_esp12_mmwave_g0_still_energy
      target: ${g0MT}
      limit_value: true
      name: ${g0MT}
      severity:
        - color: Red
          from: ${g0MT}
          to: 100
    - entity: sensor.wemos_esp12_mmwave_g1_still_energy
      target: ${g1MT}
      limit_value: true
      name: ${g1MT}
      severity:
        - color: Red
          from: ${g1MT}
          to: 100
    - entity: sensor.wemos_esp12_mmwave_g2_still_energy
      target: ${g2MT}
      limit_value: true
      name: ${g2MT}
      severity:
        - color: Red
          from: ${g2MT}
          to: 100
    - entity: sensor.wemos_esp12_mmwave_g3_still_energy
      target: ${g3MT}
      limit_value: true
      name: ${g3MT}
      severity:
        - color: Red
          from: ${g3MT}
          to: 100
    - entity: sensor.wemos_esp12_mmwave_g4_still_energy
      target: ${g4MT}
      limit_value: true
      name: ${g4MT}
      severity:
        - color: Red
          from: ${g4MT}
          to: 100
    - entity: sensor.wemos_esp12_mmwave_g5_still_energy
      target: ${g5MT}
      limit_value: true
      name: ${g5MT}
      severity:
        - color: Red
          from: ${g5MT}
          to: 100
    - entity: sensor.wemos_esp12_mmwave_g6_still_energy
      target: ${g6MT}
      limit_value: true
      name: ${g6MT}
      severity:
        - color: Red
          from: ${g6MT}
          to: 100
    - entity: sensor.wemos_esp12_mmwave_g7_still_energy
      target: ${g7MT}
      limit_value: true
      name: ${g7MT}
      severity:
        - color: Red
          from: ${g7MT}
          to: 100
    - entity: sensor.wemos_esp12_mmwave_g8_still_energy
      target: ${g8MT}
      limit_value: true
      name: ${g8MT}
      severity:
        - color: Red
          from: ${g8MT}
          to: 100

1 Like

Anyone using this sensor with 0.2m Distance Resolution?
When I use 0.2m Still Energy is always stuck at 100%, but returns to normal when using 0.75m.

My devices:
– LD2410C
– ESP32C3 Super mini


Strangely, when I installed it (turned it on) for the first time (new) and then changed it to 0.2m Still Energy was still normal, not long after that it got stuck at 100%.
This has been happening for a long time, even though I have replaced the ESP32 and/or LD2410 with another one, but the results are still the same.
Now it has been several months, although it does not affect its performance, it still feels like there is something bothering me.

Hi to everyone,
I’m a starter in home automation ad i wanted to ask here for some help with the ld2410 (bluetooth version).

I managed to configure the sensor both ways, via bluetooth and via wifi with an esp32 wroom ad it works well either way (i have good wifi and a bluetooth proxy right next to it).
My only problem is the responsive time: i use the ld2410 to turn on the lights in the kitchen with WLED and home assistant. The fact is that it takes quite a few seconds to turn on the lights (4/5s in bluetooth, 2/3s in wifi).
Is there something i can do to improve this or its something that can be resolved with a combo: ld2410 + zigbee pir sensor?
Thanks

I’d start with looking at your thresholds. I have a few that pick up motion instantly and a few that are a little lazier because of having the thresholds higher for the range that covers the point of entry into the room.

I just installed LD2410 on my hallway. I didn’t work with them for a while, so when i updated hlk radar tool i see that now app has “auto” mode, where sensor calibrates itself to it’s best situation. Then only small corrections are needed (fw update was also necesarry since sensors were sitting a copulle of years in my drawer).
But, i install my LD’s so that light is controlled with ld’s out pin, not with esp. This way i ensure that light will go on even if esp is broken. So i only ise HA monitoring, settings and eventual additional automations.