LD2410 mmWave sensor configured correctly but not everything works

I am confident this post will help some in the future looking to setup LD2410s. I still have some issues that hopefully some of you can help me resolve.

What I’ve learned so far. If working with ESP8266’s (D1 Minis in my case) I found two ways to set them up. With Tasmota and with ESPHome.

If you use Tasmota you have to compile your own bin to include the LD2410. Once you flashed your Tasmota YOU HAVE to use pins TX and RX on the ESP8266 and you can’t invert them. When you go into configure module, for TX you have to select the TX LD2410 from the dropdown, and for RX you select the RX. If you set up TX as RX and RX as TX it won’t work. You then connect the TX pin of the LD2410 device to the RX pin of the ESP8266, and the RX pin to the TX pin.

If you use ESPHome to set up the ESP8266 the connections are backwards. With ESPHome configuration you connect the RX pin of the LD2410 to the RX pin of the ESP8266, and the TX to the TX.

So basically if you flash your ESP8266 and you are able to integrate into home assistant and you are able to see the list of sensors but with no values try inverting the wires that connect the LD2410 to the ESP8266.

this part is actually wrong If you are using an ESP32 with ESPHome things are a bit different. I didn’t try ESP32 with tasmota, only with ESPHome. From documentation it seems you can use any of the pins of the ESP32. I used the TX and RX pins. Also you can switch the pins via code. You can assign TX to be RX, and RX to be TX, or TX to TX and RX to RX. When connecting the LD2410 to the ESP32 you put the TX from the LD2410 to the pin you configured as TX. (Turns out I was wrong in my assumptions, read my reply to my own post)

After figuring that pins swap from tasmota to esphome I was able to set up my ESP32. On that ESP32 I am also running I2S Audio. (Pictures and code I am using will be below).

As you will be able to see on pictures it seems everything is configured properly. I am able to use the Audio part as expected, and I am able to detect motion, presence, distance, etc. But the more advanced features such as turning on engineering mode, turning off bluetooth, restarting device, etc. don’t seem to be working. Could someone help me fix it?

My yaml code:

  name: espaudiommwave
  friendly_name: EspAudiommWave
  

esp32:
  board: esp32dev


# Enable logging
logger:
  baud_rate: 0
# Enable Home Assistant API
api:
  encryption:
    key: "5EQmST0NJP+H0HJQCMtCWo="

ota:
  - platform: esphome
    password: "41b15b05"

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Espentrada Fallback Hotspot"
    password: "maire"


i2s_audio:
  i2s_lrclk_pin: GPIO16
  i2s_bclk_pin: GPIO17

media_player:
  - platform: i2s_audio
    name: ESPHome I2S Media Player
    dac_type: external
    i2s_dout_pin: GPIO21
    mode: mono

captive_portal:

uart:
  id: ld2410_uart
  tx_pin: TX
  rx_pin: RX
  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

 
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

 

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

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

Here are the pictures of what my menu looks like

When I toggle the engineering mode the slider goes to the “on” position, then turns off a couple of seconds later. It shows this on the log. I am assuming it is supposed to stay on until I turn it off or reboot the device. Just noticed that if I access the LD2410 via the bluetooth app, if I turn engineering to “on” it updates to “on” in HA, and if I turn it off, it also updates on HA.

When I toggle the control bluetooth the switch does stay in the position I put it on, and on the logbook it shows the command, however it doesn’t matter if it is on or off I am still able to access the LD2410 via the Hilink App. I am assuming the bluetooth control is for the LD2410 not for the ESP32. I haven’t checked if the ESP32 ble is the one turning off and on.

On the timeout. If I set it to 1 then access the LD2410 via the ble app it changes it back to 5. If I change it to 1 via the app it does update to 1 on HA.

Changing distance resolution in HA doesn’t seem to do anything. If I change it via the BLE app it reboots the LD2410 and once it starts up again it does update in the HA

When I click on the restart button, it shows on the log but device doesn’t restart. I know it doesn’t restarts because it keeps showing accurate distances when it should be rebooting.

Any ideas of what might be going on? Seem changes done via the BLE do get pushed to HA, but changes done on HA don’t make it to the LD2410.

So I was finally able to figure it out, well ssied from the ESPHome discord was able to figure it out for me. The issue was with my TX line. I was able to get info from the LD2410 but I wasn’t able to send info to the LD2410.

Also found an interesting “glitch”. As you can see on my config uart: I had txpin set to TX and rxpin set to RX. I was assuming it was setting the Txpin to GPIO1 and the Rxpin to GPIO3, but in reality it was setting Txpin to GPIO3 and Rxpin to GPIO1. That is why I mentioned on the original post that you plug the tx from LD2410 to the pin set up as TX on the ESP, but that is wrong!

Same as in tasmota. You always connect the TX pin on LD2410 to the RX pin of the ESP and RX pin to the TX pin of the ESP.