LD2410 esphome tips

Got it, thanks for sharing!

Thanks @koldogut for your insight on Espresense with ld2410.

May I ask any of you with experience with Espesense with ld2410… one question about “output” pin on ld2410? You get “moving” or “motionless” or both?
I get only moving… like PIR sensor then… :frowning_face:

Thank you!

PS: I’m not keen on sensors so I beg your pardon for such noob question…wiring - I connected power and ground to esp32 and then out pin to GPIO2, then selected in GUI of Espresense under GPIO (and radar sensor) pin - > 2 and Pullup. Is there any other way to get motion / occupied into Espresense and HA?
I tried to decypher this line in docs since I’m not keen on electronics…

To use these devices with ESPresense, we connect the power and ground and the ‘Occupied’ pin with a high value of occupied and a low value of unoccupied.

Can someone help me with this …‘Occupied’ pin with a high value of occupied and a low value of unoccupied?

EDIT: is it possible to select 2 pins in GUI of Espresense?

Hi All,

I am getting following error, tried everything but not able to figure out why it keeps failing. Any help will be appreciated. Thank you:

Wrote 972912 bytes (634945 compressed) at 0x00010000 in 14.5 seconds (effective 536.6 kbit/s)...
Hash of data verified.
Compressed 17440 bytes to 12128...
Wrote 17440 bytes (12128 compressed) at 0x00001000 in 0.4 seconds (effective 355.6 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 144...
Wrote 3072 bytes (144 compressed) at 0x00008000 in 0.0 seconds (effective 1056.8 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 1647.3 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
INFO Successfully uploaded program.
INFO Starting log output from /dev/ttyUSB1 with baud rate 115200
[09:47:38][I][logger:268]: Log initialized
[09:47:38][C][ota:473]: There have been 0 suspected unsuccessful boot attempts.
[09:47:38][D][esp32.preferences:114]: Saving 1 preferences to flash...
[09:47:38][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[09:47:38][I][app:029]: Running through setup()...
[09:47:38][C][uart.arduino_esp32:077]: Setting up UART...
[09:47:38][C][ld2410:081]: Setting up LD2410...
[09:47:39][D][select:015]: 'Baud Rate': Sending state 256000 (index 6)
[09:47:39][C][ld2410:083]: Mac Address : 
[09:47:39][C][ld2410:084]: Firmware Version : 
[09:47:39][C][ld2410:085]: LD2410 setup complete.
[09:47:39][C][wifi:038]: Setting up WiFi...
[09:47:39][C][wifi:051]: Starting WiFi...
[09:47:39][C][wifi:052]:   Local MAC: B0:A7:32:28:6E:A0
[09:47:39][D][wifi:428]: Starting scan...
**[09:47:39][E][ld2410:336]: Error with last command : incorrect Header**
[09:47:39][D][text_sensor:064]: 'Presence Sensor Version': Sending state '1.07.22091516'
[09:47:39][D][text_sensor:064]: 'Presence Sensor MAC Address': Sending state 'A5:01:61:C9:5C:4B'
[09:47:39][D][switch:055]: 'Control Bluetooth': Sending state ON

Here is ESPHome Code:

esphome:
  name: bathroom-presence
  friendly_name: bathroom-presence

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

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

ota:
  password: "**********"

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Bathroom-Presence"
    password: "**********"

captive_portal:

ld2410:
  uart_id: ld2410_uart
  throttle: 1500ms
  id: ld2410_comp

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

sensor:
  - platform: ld2410
    light:
      name: Light
    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

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

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

text_sensor:
  - platform: ld2410
    version:
      name: "Presence Sensor Version"
    mac_address:
      name: "Presence Sensor MAC Address"

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

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

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



Which ESP board are you using?

Hi, Thanks

It is an ESP32 (ESP-WROOM-32)

Oh…just re-read your post. I think that’s kind of a “known issue” where it pops up once but everything works fine. Maybe just an issue with the native LD2410 component? There is an issue open for it on Github: Error with last command : incorrect Header · Issue #4897 · esphome/issues · GitHub

Hi, Thank you.

My LD2410 in espHome stays “OFFLINE”, I don’t understand why?

In the ESPhome dashboard or from the device page in the ESPhome integration? Can you see it connected to WiFi from your router? If yes, what do the logs show from the ESPhome dashboard?

Hi Ryan

Following is for the network connection:

[10:46:08][C][mdns:115]: mDNS:
[10:46:08][C][mdns:116]:   Hostname: bathroom-presence
[10:46:08][C][ota:097]: Over-The-Air Updates:
[10:46:08][C][ota:098]:   Address: 192.168.1.121:3232
[10:46:08][C][ota:101]:   Using Password.
[10:46:08][C][api:138]: API Server:
[10:46:08][C][api:139]:   Address: 192.168.1.121:6053
[10:46:08][C][api:141]:   Using noise encryption: YES

I also gave it a fixed IP address, and for a brief moment it showed “Online” and back to “Offline”.

Hi Ryan

It is working now. I am not sure what the issue was. I upgraded today to 2023.9.3? That seems to have sorted it out.

Thank you for your help.

1 Like

Is bluetooth_proxy integration supposed to work in configuration if setup with ld2410 sensor attached to rx tx pins of esp32? I tried also with esp32_ble_tracker and it doesn’t work either…well it works for couple of minites and then hangs.
Anyone managed to get it setup bluetooth proxy and ld2410 sensor on same device?

Template all the things!!!

type: custom:config-template-card
variables:
  gType: t => { return "move"; }
  gEntity: t => { return "motion_01"; }
  getE: t => { return "sensor." + vars.gEntity() + "_mmwave_g" + t + "_" + vars.gType() + "_energy"; }
  getTE: t => { return "number." + vars.gEntity() + "_mmwave_g" + t + "_" + vars.gType() + "_threshold"; }
  getT: t => { return states[vars.getTE(t)].state; }
entities:
  - ${vars.getE(1)}
  - ${vars.getE(2)}
  - ${vars.getE(3)}
  - ${vars.getE(4)}
  - ${vars.getE(5)}
  - ${vars.getE(6)}
  - ${vars.getE(7)}
  - ${vars.getE(8)}
  - ${vars.getTE(0)}
  - ${vars.getTE(1)}
  - ${vars.getTE(2)}
  - ${vars.getTE(3)}
  - ${vars.getTE(4)}
  - ${vars.getTE(5)}
  - ${vars.getTE(6)}
  - ${vars.getTE(7)}
  - ${vars.getTE(8)}
card:
  type: custom:bar-card
  title: Move Energy
  direction: up
  columns: 9
  height: 150px
  width: 100%
  positions:
    icon: 'off'
    indicator: 'off'
    value: none
  entities:
    - entity: ${getE(0)}
      target: ${getT(0)}
      limit_value: true
      complementary: true
      name: g0
    - entity: ${getE(1)}
      target: ${getT(1)}
      limit_value: true
      complementary: true
      name: g1
    - entity: ${getE(2)}
      target: ${getT(2)}
      limit_value: true
      complementary: true
      name: g2
    - entity: ${getE(3)}
      target: ${getT(3)}
      limit_value: true
      complementary: true
      name: g3
    - entity: ${getE(4)}
      target: ${getT(4)}
      limit_value: true
      complementary: true
      name: g4
    - entity: ${getE(5)}
      target: ${getT(5)}
      limit_value: true
      complementary: true
      name: g5
    - entity: ${getE(6)}
      target: ${getT(6)}
      limit_value: true
      complementary: true
      name: g6
    - entity: ${getE(7)}
      target: ${getT(7)}
      limit_value: true
      complementary: true
      name: g7
    - entity: ${getE(8)}
      target: ${getT(8)}
      limit_value: true
      complementary: true
      name: g8
1 Like

Hey HA Community,

I’m trying to tweak my LD2410 (non bluetooth) so that I’m not getting any false triggers. I’ve created a history graph to see which gate is being triggered, but I don’t see any of them passing the thresholds when the Still Presence is triggered. Any tips for tweaking this? There are no thesholds between 0 and 20

Thanks

You can try to adjust max move and still distance. I saw your post and went to check my sensor out. And it does detect presence in the room although none is in the room. But its windy out and trees are moving. My sensor distance was set to 8 meters but obviously 6 is more than enough.
Or maybe we just have a ghost.

Thanks for the reply. I’ve already reduced the max-disance to 4m. Even so, shouldn’t the energy show passing a threshold in the chart?

I don’t know, I’m still learning about this device. For example I have one ld2410 sensor connected to esp32 board. It’s plugged in outlet next to the bedroom door. If I close the door and pass the bedroom no presence is detected. Ok, I have thick masonry walls. But if I stand in front of closed door it start to detect presence. It seems to me that position of the sensor is also very important it you want to avoid false detection.

I have the opposite problem where it is detecting presence when it shouldn’t be. Right now I’m thinking it is reflections from the 3D printed case it is in. Experiments in progress…

I have another sensor I’m testing and you can clearly see the difference with and without the case. The latest part of the graph is without.

You should be aware that microwaves go through (thin) wood (like doors), thin walls, even glass… all that is needed to be taken into account when positioning. And they can reflect from certain things, sure.
Positioning MW sensor is not s easy as positioning IR sensor. Many times combination of both works best - like both need to be triggered to start an instance, then only MW is monitored for continous presence.

Someone else is having a lot of freezes?

I had it working fine, but since the new integration in esphome, it just doesn’t start or works only few moments.

I have it connected to an esp32 wroom via cable, power + uart

If I disconnect the rx/tx cables and connect via Bluetooth with it’s apk, it works fine.

I will try to connect it via bt to esp or change the esp, but I think it’s something related to the ld integration in esphome

Ideas ?

I found out how to tweak sensor for still presence detection. I set g3, g4 and g5 threshold to 10 and set timeout to 3 seconds. I stayed still as much as possible as little breathing as possible and it does detection presence without a problem. So tweaking settings and correctly positioning the sensor will go a long way.