Esphome + LD2410 sensor troubles

Hi all,

I’ve been trying to set up the LD2410 sensor with a D1 Mini V4.0
But sadly enough without any positive results…

I already order an second LD2410 with the thought the first one would be malfunctioning.
Also tried a different min connector cable but also no success.
Only thing that I have not tried it is a different D1 Mini module…

Although both I can read you through bluetooth with the chinese app on my phone.

Here is a small read out of the logs regarding the sensor:
I’ve enabled the UART debbugging to see the data coming in but that seems not usable?

I also notice that sensor gets pretty warm/hot dont if any users experience this?

Hope you guys may have any tips :slight_smile:

[08:53:04][C][web_server:161]: Web Server:
[08:53:04][C][web_server:162]:   Address: livingroom.local:80
[08:53:04][D][uart_debug:158]: >>> "\xFD\xFC\xFB\xFA\x04\x00\xFF\x00\x01\x00\x04\x03\x02\x01\xFD\xFC\xFB\xFA\x02\x00\xA0\x00\x04\x03\x02\x01\xFD\xFC\xFB\xFA\x04\x00\xA5\x00\x01\x00\x04\x03\x02\x01\xFD\xFC\xFB\xFA\x02\x00\xAB\x00\x04\x03\x02\x01\xFD\xFC\xFB\xFA\x02\x00\xAE\x00\x04\x03\x02\x01\xFD\xFC\xFB\xFA\x02\x00a\x00\x04\x03\x02\x01\xFD\xFC\xFB\xFA\x02\x00\xFE\x00\x04\x03\x02\x01"
[08:53:04][C][mdns:112]: mDNS:
[08:53:04][C][mdns:113]:   Hostname: livingroom
[08:53:04][C][ota:093]: Over-The-Air Updates:
[08:53:04][C][ota:094]:   Address: livingroom.local:8266
[08:53:04][C][api:138]: API Server:
[08:53:04][C][api:139]:   Address: livingroom.local:6053
[08:53:04][C][api:141]:   Using noise encryption: YES
[08:53:06][D][api:102]: Accepted 192.168.0.11
[08:53:06][W][component:204]: Component api took a long time for an operation (0.28 s).
[08:53:06][W][component:205]: Components should block for at most 20-30ms.
[08:53:08][D][api.connection:1031]: Home Assistant 2023.8.4 (192.168.0.11): Connected successfully

And here a printout the esp file:

substitutions:
  device_name: livingroom

esphome:
  name: ${device_name}
  friendly_name: "mmWave-huiskamer"
  platform: esp8266
  board: d1_mini
  esp8266_restore_from_flash: true 

# Disable logging to enable RX/TX
logger:
  baud_rate: 0
  level: debug

# Enable Home Assistant API
api:
  encryption:
    key: "IuZYWyPxlpzOl3Offew4NAZHqeb8qekGK2bwP1f+JJQ="

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_pass

# power_save_mode: none

captive_portal:

web_server:
  port: 80

# Enable Home Assistant API

ota:


uart:
  tx_pin: TX  
  rx_pin: RX
  baud_rate: 115200
  parity: NONE
  stop_bits: 1

  debug:
    direction: BOTH
    dummy_receiver: false
    after:
      delimiter: "\n"
    sequence:
      - lambda: UARTDebug::log_string(direction, bytes);

ld2410:

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

switch:
  - platform: ld2410
    engineering_mode:
      name: "engineering mode"
    bluetooth:
      name: "control bluetooth"
      
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

I have a few working with D1 minis my code for the uart looks a bit different to yours may be worth a try :slight_smile: The only real difference is baud_rate.

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

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

Sure someone with more knowledge will come along with better help soon.

Gave it a shot but sadly enough doesnt work…

Uch I tried a different board.
And ofcourse this seems to be working…

Dang those fake chinese board must have something changed why the UART bus is not working properly…

Alright I’ve got it working !
Apperently the physical RX/TX pins aren’t that good.

Luckly we have another option on the D1 board so I’ve moved over tx_pin: GPIO15 and rx_pin: GPIO13

That didnt work right away and that was because I was powering the board with USB from my laptop so that must have used something regarding the communcation which interrupted the UART

So now powering it just through a power source its working fine :slight_smile:

I’m still struggling with LD2410 on an ESP8266. Can you explain what you mean by changing the power source to get the other UART GPIO working?

Just a guess but, as USB also contains data cables which connect to the UART (probably). I would say they have either powered from just a USB wall plug or power only cable.

Mine are all powered from a USB cable but the wires are soldered to the power pads on the board. I do this because it takes up a lot less space.

I think the main reason for getting it to work from my side was switching from GPIO01 / GPIO03 to GPIO15/GPIO13

And after that I had some troubles becacuse I was powering the board through a USB connected to the laptop :slight_smile:
And therefore there must have been some data interference on the UART bus

I tried to connect LD2410 with pins on it to d1 mini. At first it worked. I connected GPIO1 and GPIO3. But as I messed something up it stoped working and I’m unable to make it work with d1 mini. I tried GPIO13 and GPIO15 but nothing changed. Try to reverse tx and rx wires, the same. It doesn’t work. I changed the board to esp32 wroom and it’s working flawlessly for a few days now. I connected board to 3.3v and GPIO1 and GPIO3 pins on esp32. In my opinion there is probably problem with connection on d1 mini. This is the only thing that comes to my mind. For a price difference of 1.5 € its better to get esp32 board. I ordered a BH1750 light sensor and will connect it to the board. If this work it will be a pritty neat presence sensor.
This is my working code for esp32

esphome:
  name: xxxxxxxxx
  friendly_name: xxxxxxxxxxxx
external_components:
  - source: github://esphome/esphome@dev
    components: [ ld2410 ]

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:
  baud_rate: 0

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

ota:


wifi:
  ssid: "xxxx"
  password: "xxxxxx"
  power_save_mode: NONE

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "xxxxxx"
    password: "xxxxx"

captive_portal:

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

sensor:
  - platform: uptime
    name: Uptime
    entity_category: "diagnostic"
    update_interval: 300s
  - platform: wifi_signal
    name: "WiFi Signal"
    accuracy_decimals: 1
    entity_category: "diagnostic"
    update_interval: 5s
    filters:
      - exponential_moving_average:
          alpha: 0.05
          send_every: 2
          send_first_at: 2
      - or:
        - throttle: 600s
        - delta: 2
  - 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

switch:
  - platform: ld2410
    bluetooth:
      name: "control bluetooth"

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

binary_sensor:
  - platform: ld2410
    has_target:
      name: Presence
    has_moving_target:
      name: Moving Target
    has_still_target:
      name: Still Target

hi @ddaniel in my case works only if delete the following section.

button:

  • platform: ld2410
    factory_reset:
    name: “factory reset”
    restart:
    name: “restart”
    query_params:
    name: query params

my config is the following

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

ld2410:
id: my_ld2410
uart_id: ld2410_uart

switch:

  • platform: ld2410
    engineering_mode:
    name: Engineering Mode
    bluetooth:
    name: Control Bluetooth

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

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

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

text_sensor:

  • platform: ld2410
    version:
    name: “firmware version”
    mac_address:
    name: “mac address”

Most likely cause, both for you and maybe others above too:

TX and RX stand for transmit and receive. When you connect them to another device, tying TX to TX and RX to RX won’t work, because both devices send on the same line, and both devices listen on the same line. Those need to be swapped. If one side transmits (TX) the other side must listen (RX) on both lines.

So: swap pin 1 and 3 and try again. It will probably work.

Another thing to note:
If you have an ESb32 device with a USB port, then the USB almost always also uses pin 1 and 3 for serial communication. So, while you flash over USB, don’t connect the LD2410 to the same pins (that is one of the reasons why another uart might be more convenient).

Once you flashed and discunnect USB from a PC (an adapter is fine, that won’t use the uart). Now you can connect to pins 1 and 3, and do firmware updates OTA.

And last but not least, if you post yaml, format it correctly, between three backticks:

Tnx for heads up, but I know that and probably do others. For me d1 mini just doesnt work,
But I found out better board.

esp32-c3-devkitm-1

is in my opinion is the best, at least for my small projects. There is a lot info online about this board, but what I like the the most is that this board is running on low temperature compared to esp32.
It runs on basically the same firmware and the same hardware attached to it nearly 50% cooler.
And this is great because it will harder cache fire than high temp running esp32.

I cannot look in your head to see what you know and I’m not trying to offend. I just read a lot of posts of people who had trouble getting the LD2410 to work, until they switched RX/TX.

If you are worried about temperatures then maybe you should know LD2410 will feel hot to the touch when operating. Hotter than an I ever experienced with all of my esp32’s, mini or otherwise.

Yeah I know, I tried it and it is hot. But speaking about the board I was really impressed with esp32-c3-devkitm-1. And it works better than a standard esp32 board.

I’m not offended, dont worry about it, just saying. If you done one upload using cables you will never ever forget to swap tx/rx.

Hi to all again at last the d1 mini works stable , looks like this chip have memory issues … or something else have no idea , sort the code more and works very stable now.

esp8266:
  board: esp12e
  framework:
    version: recommended

# Enable logging
logger:
  baud_rate: 0

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

ld2410:
  id: my_ld2410
  uart_id: ld2410_uart

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

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

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

select:
  - platform: ld2410
    distance_resolution:
      name: "distance resolution"
    baud_rate:
      name: "baud rate"
    light_function:
      name: light function

binary_sensor:
  - platform: ld2410
    has_target:
      name: Presence
    has_moving_target:
      name: Moving Target
    has_still_target:
      name: Still Target

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