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