LD2410 esphome tips

my yaml also includes a ledstrip, so you can ignore that part if you don’t need it (basically what @Holdestmade posted)

esphome:
  name: naambord-esp8266
  friendly_name: Naambord-ESP8266

esp8266:
  board: esp01_1m

external_components:
  source: github://regevbr/esphome@ld2410
  components: [ld2410]

# Enable logging
logger:
  baud_rate: 0

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

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

  manual_ip:
    static_ip: x.x.x.x
    gateway: x.x.x.x
    subnet: x.x.x.x
    dns1: x.x.x.x
    dns2: x.x.x.x

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Naambord-ESP8266"
    password: "ap-pass"

captive_portal:
    
ota:
  password: "ota-pass"

# LED strip
light:
  - platform: neopixelbus
    type: GRB
    variant: WS2812X
    pin: GPIO2
    num_leds: 34
    name: "NeoPixel Light"

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

ld2410:
  uart_id: ld2410_uart
  throttle: 1500ms
  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

button:
  - platform: ld2410
    factory_reset:
      name: "factory reset"
    restart:
      name: "restart"
    query_params:
      name: query params

number:
  - platform: ld2410
    timeout:
      name: timeout
    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
    light_threshold:
      name: light threshold

text_sensor:
  - platform: ld2410
    version:
      name: "presenece sensor version" 
    mac_address:
      name: "presenece sensor mac address"

switch:
  - platform: ld2410
    engineering_mode:
      name: "engineering mode" 

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: GPIO1
    name: gpio out pin presence
    device_class: presence

sensor:
  - platform: ld2410
    moving_distance:
      name: "Moving distance (cm)"
    still_distance:
      name: "Still Distance (cm)"
    moving_energy:
      name: "Move Energy (%)"
    still_energy:
      name: "Still Energy (%)"
    detection_distance:
      name: "Distance Detection (cm)"
    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
    light:
      name: light
1 Like

Dont know why, but new config broke my sensor completely.

  1. It stops reporting any data
  2. When I try to access device through web interface it resets it.
  3. When I try to flash updated firmware it resets it and it stops connecting to wifi, just blinks status led
esphome:
  name: presence-sensor04
  friendly_name: Presence_Sensor04
  on_boot:
    priority: 300
    then:
      lambda: |-
        WiFi.setPhyMode(WIFI_PHY_MODE_11G);
        
esp8266:
  board: esp01_1m

# Enable logging
logger:

external_components:
  source: github://regevbr/esphome@ld2410
  components: [ld2410]

# Enable Home Assistant API
api:
  encryption:
    key: !secret prsensor04_enckey
  services:
    - service: set_ld2410_bluetooth_password
      variables:
        password: string
      then:
        - bluetooth_password.set:
            id: ld2410_comp
            password: !lambda 'return password;'

ota:
  password: !secret wifistereo04_otapass

wifi:
  ssid: !secret wifi_ssid2
  password: !secret wifi_password2

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Presence-Sensor04"
    password: !secret wifistereo01_fallbackpass

captive_portal:
  
web_server:
  port: 80
  version: 2
  include_internal: true
  auth:
    username: !secret mqtt_user
    password: !secret mqtt_password

# Enable HTTP/HTTPS requests
http_request:
  # default ESPHome
  useragent: esphome/$device_name
  # request time out / default 5s
  timeout: 2s
  
status_led:
  pin:
    number: GPIO02
    inverted: true

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

ld2410:
  uart_id: ld2410_uart
  throttle: 1500ms
  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

button:
  - platform: ld2410
    factory_reset:
      name: "factory reset"
    restart:
      name: "restart"
    query_params:
      name: query params

number:
  - platform: ld2410
    timeout:
      name: timeout
    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
    light_threshold:
      name: light threshold

text_sensor:
  - platform: ld2410
    version:
      name: "presenece sensor version" 
    mac_address:
      name: "presenece sensor mac address"

switch:
  - platform: ld2410
    engineering_mode:
      name: "engineering mode" 
    bluetooth:
      name: control Bluetooth

binary_sensor:
  - platform: ld2410
    has_target:
      name: "presence"
    has_moving_target:
      name: "movement"
    has_still_target:
      name: "still"
    out_pin_presence_status:
      name: out pin presence status
  - platform: gpio
    pin: GPIO13
    name: gpio out pin presence
    device_class: presence

sensor:
  - platform: ld2410
    moving_distance:
      name: "Moving distance (cm)"
    still_distance:
      name: "Still Distance (cm)"
    moving_energy:
      name: "Move Energy (%)"
    still_energy:
      name: "Still Energy (%)"
    detection_distance:
      name: "Distance Detection (cm)"
    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
    light:
      name: light

  - 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"

  - platform: adc
    pin: VCC
    name: "VCC Voltage"
    accuracy_decimals: 3
    filters:
      - multiply: 1.287

Damn

Can you try removing the following from your YAML:

external_components:
  source: github://regevbr/esphome@ld2410
  components: [ld2410]

Hello, is there any side effects to leave engineering mode on for extended periods in ESPHome?

I’m thinking of charting the energy of all gates and doing some funky processing on the data over a month.

Just a short how did you get this software in an english version, all I see and can find is the Chinese which is gibberish to me.

i have the same problem with the last update of LD2410 and Esphome, there is always 3-4% still energy and my sensor is always in “detect” mode…

I try your settings, its better but still the same problem, the “still energy” take a while to enventually go to 0%, what make the “detect” state false.

Is someone has experiment a similar behaviour please?

EDIT : noob am i…just set the timeout to 10s and work great lol

Tried, same, not working.

[13:12:21][W][ota:102]: Last Boot was an unhandled reset, will proceed to safe mode in 7 restarts

Hoping there comes a new video soon on youtube that explains what just happen and what these new setting do

Older versions defaulted to Chinese if the phone language was not English.
The very most recent one fixed that in the sense that the app defaults to English, now.

esp8266 d1mini. all parameters are not available!

Updated to esp 2023.8.0? Have you read the changelog?

2023.8.1
what is in there? It does not say that device will be highly unstable rebooting at every opportunity.

I think this component made esp32 unusuable.
receiving this error:

[12:43:15][C][ld2410:075]:   Throttle_ : 1500ms
[12:43:15][D][sensor:094]: 'R_Distancia Quieto (cm)': Sending state 50.00000 cm with 0 decimals of accuracy
[12:43:15][E][ld2410:336]: Error with last command : incorrect Header

and then:

WARNING 192.168.1.62: Connection error occurred: [Errno 104] Connection reset by peer
INFO Processing unexpected disconnect from ESPHome API for 192.168.1.62
WARNING Disconnected from API
WARNING 192.168.1.62: Connection error occurred: EOF received
WARNING Can't connect to ESPHome API for 192.168.1.62: Connection closed (APIConnectionError)
INFO Trying to connect to 192.168.1.62 in the background
WARNING 192.168.1.62: Connection error occurred: [Errno 104] Connection reset by peer

Damn how to return back to previous versıon of firmware? Restore HA from backup?

INFO ESPHome 2023.8.1
INFO Reading configuration /config/esphome/presence-sensor04.yaml...
INFO Starting log output from presence-sensor04.local using esphome API
INFO Successfully connected to presence-sensor04.local
[14:05:12][I][app:102]: ESPHome version 2023.8.1 compiled on Aug 18 2023, 13:33:12
[14:05:12][C][status_led:019]: Status LED:
[14:05:12][C][logger:301]: Logger:
[14:05:12][C][uart.arduino_esp8266:102]: UART Bus:
[14:05:12][C][uart.arduino_esp8266:103]:   TX Pin: GPIO1
[14:05:12][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'gpio out pin presence'
[14:05:12][C][ld2410:022]: LD2410:
[14:05:12][C][ld2410:026]:     Device Class: 'occupancy'
[14:05:12][C][ld2410:034]:     Icon: 'mdi:restart-alert'
[14:05:12][C][ld2410:041]:     Device Class: 'distance'
[14:05:12][C][ld2410:041]:     Icon: 'mdi:signal-distance-variant'
[14:05:12][C][ld2410:044]:     Device Class: 'distance'
[14:05:12][C][ld2410:046]:     State Class: ''
[14:05:12][C][ld2410:046]:     Icon: 'mdi:flash'
[14:05:12][C][ld2410:046]:   NthGateStillSesnsor 'g7 still energy'
[14:05:12][C][ld2410:049]:     State Class: ''
[14:05:12][C][ld2410:049]:   NthGateMoveSesnsor 'g2 move energy'
[14:05:12][C][ld2410:049]:     State Class: ''
[14:05:12][C][ld2410:053]:   VersionTextSensor 'presenece sensor version'
[14:05:12][C][ld2410:064]:     Icon: 'mdi:motion-sensor'
[14:05:12][C][ld2410:068]:     Unit of Measurement: '%'
[14:05:12][C][ld2410:068]:     Icon: 'mdi:motion-sensor'
[14:05:12][C][ld2410:071]:     Icon: 'mdi:motion-sensor'
[14:05:13][C][ld2410:071]:     Unit of Measurement: '%'
[14:05:13][C][ld2410:071]:     Icon: 'mdi:motion-sensor'
[14:05:13][C][ld2410:071]:     Device Class: 'signal_strength'
[14:05:13][C][ld2410:075]:   Throttle_ : 1500ms
[14:05:13][C][copy.sensor:015]: Copy Sensor 'WiFi Signal Percent'
[14:05:13][C][adc:094]: ADC Sensor 'VCC Voltage'
[14:05:13][C][captive_portal:088]: Captive Portal:
[14:05:13][C][web_server:161]: Web Server:
[14:05:13][C][web_server:162]:   Address: presence-sensor04.local:80
[14:05:13][C][mdns:112]: mDNS:
[14:05:13][C][ota:093]: Over-The-Air Updates:
[14:05:13][C][api:138]: API Server:
[14:05:13][C][http_request:014]: HTTP Request:
[14:05:13][C][http_request:017]:   Follow Redirects: 1
[14:05:13][C][wifi_signal.sensor:009]: WiFi Signal 'WiFi Signal dB'
[14:05:13][C][wifi_signal.sensor:009]:   Unit of Measurement: 'dBm'

updated my two sensors.
the one in the kitchen works like it always have worked.

my livingroom sensor does not work.


translation for “Onbekend” is “Unknown”

they both use the exact same yaml.

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

ld2410:
  uart_id: ld2410_uart

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

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

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

no matter what i do, i can not get the livingroom sensor to work.
when i press the (soft) restart button i get the following.

and then nothing really is changed.
i think i swap out the LD2410 sensor for a new one and see what will change.

edit
oke, so i disconected the LD2410 sensor from the board.
let the board boot without the LD2410 sensor.
disconnected the board from power, and connected the LD2410 sensor.
restarted the board by connecting the power.
and there it goes, works like a charme.

next question, what does control bluetooth does?
image

and what does engineering mode does?
image

Control Bluetooth: Toggles the Bluetooth Power on LD2410B. If off, you can’t configure it using the app.

Engineering Mode: Turns on tracking of each gate energy, and allows changing of threshold values. Basically facilitates all you need to calibrate the device to its environment.

Question adding on to engineering mode, are there any cons to leaving engineering mode on all the time?

1 Like

Tried without success, can’t access to the ESP ip.

Ping works, but it’s not starting

Catch the error:

[D][api.connection:1031]: Home Assistant 2023.8.2 (192.168.1.30): Connected successfully

abort() was called at PC 0x401f7847 on core 1


Backtrace:0x40083815:0x3ffd20200x400931f9:0x3ffd2040 0x400987bd:0x3ffd2060 0x401f7847:0x3ffd20e0 0x401f788e:0x3ffd2100 0x401f7987:0x3ffd2120 0x401f78e6:0x3ffd2140 0x400d47bb:0x3ffd2160 0x400d7ed6:0x3ffd2190 0x400d810d:0x3ffd21c0 0x40210cce:0x3ffd21f0 0x400d4a2f:0x3ffd2210 0x400d93cd:0x3ffd22f0 0x400ec836:0x3ffd2310 0x400d3ccb:0x3ffd2330 0x400d9365:0x3ffd23c0 0x40211a75:0x3ffd2430 0x40211afd:0x3ffd2450 0x400eb458:0x3ffd2470 0x400edada:0x3ffd24a0 0x400fcec9:0x3ffd24c0 




ELF file SHA256: 0000000000000000

Rebooting...
ets Jul 29 2019 12:21:46

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13132
load:0x40080400,len:3036
entry 0x400805e4

don’t know if this has any sense

EDIT:

As stated in github, removed webserver and now esp boots fine.

let’s check if it works fine

I wonder about the volume of sensor updates that engineering mode creates, since it seems like leaving it on all the time might cause a lot of unnecessary writing to the logbook. I can’t quantify the performance impact of that, but my gut instinct is that it’s better to turn it off when not actively tuning the sensor.

Is it possible just to hardcode the gate values like before (see below)? I didn’t solder a wire on the out pin and I assume that’s required for the engineering mode to work correctly?

g0_move_threshold: 40
g0_still_threshold: 41

I don’t believe that the out pin is required unless you want to use it the way you would a single-wire PIR. Engineering mode should still allow you to tune the values that trigger the presence, has_moving_target, and has_still_target binary sensors, which come in over the UART pins.