LD2410 esphome tips

Hi all,
I have tried to build my first presence detector but I found my Esp32 S2 mini off line this morning although the device seems to work correctly.
I explained the issue here:

Thanks for your support

Fail to open device. This is the message when I try to open my LD2410


Is there any setting to be done before run the tool?

As i know no.
In my experience not all esp32 boards works great with ld2410b.
Esp32-c3 works the best for me.

If it was working, have you tried restarting it? Unplug and plug :slight_smile:

Which ESP32 have you got?

image

This one?

This is what I’m using for my S2s and they have been super reliable.

Your mileage may vary though lol

esp32:
  board: lolin_s2_mini
  variant: ESP32S2
  framework:
    type: arduino
    version: 2.0.6
    platform_version: 5.3.0

I have tried to restart it several times but without success.
I have also Esp Reboot with the integration but it cointinues to appear offline in Esphome.

I’m using the ESP32 S2 mini wemos (maybe a clone) like in your picture.

esp32:
  board: lolin_s2_mini
  framework:
    type: arduino
    version: 2.0.9
    platform_version: 6.3.2

The yaml seems similar to your one but without

variant: ESP32S2

What I should do now? restart the installation process via USB?

If I were you, I would make sure that you have the same esp32, do some digging and make sure and then here is my complete config file.

  1. I normally delete the old device
  2. create a new device but don’t try to connect to it
  3. Edit the config of the new device make sure you specify the right GPIO pins
  4. paste my config into that new device and make sure you use the api keys and wifi settings from the new device
  5. compile and download the bin file
  6. use the adafruit web tool linked below to connect the esp and upload the bin
  7. profit lol

Upload Instructions

Tool
https://adafruit.github.io/Adafruit_WebSerial_ESPTool/

esphome:
  name: put_your_own
  friendly_name: put_your_own
  platformio_options:
    board_build.extra_flags:
      - "-DARDUINO_USB_CDC_ON_BOOT=0"  

esp32:
  board: lolin_s2_mini
  variant: ESP32S2
  framework:
    type: arduino
    version: 2.0.6
    platform_version: 5.3.0

# Enable logging
logger:

create a new device and copy the keys and wifi settings here and delete this line 

captive_portal:

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

ld2410:

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  

sensor:
  - platform: ld2410
    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"

binary_sensor:
  - platform: ld2410
    has_target:
      name: "Occupancy"
    has_moving_target:
      name: "Movement"
    has_still_target:
      name: "Still"
1 Like

Also a question to everyone else. The config that I pasted, are there any cool things I could be doing differently? Im not sure what lol, but im always open to make it better or what the latest things are.

Well you can use setting for device internal temperature uptime and wifi signal like

sensor:
  - platform: internal_temperature
    name: "Internal Temperature"

  - 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

Then it will be nice to have some light sensor for it like bh1750fvl

i2c:
  sda: GPIO18
  scl: GPIO19
  scan: True
  id: bus_a

...

sensor:
  - platform: bh1750
    name: "Illuminance"
    address: 0x23
    update_interval: 1s
    accuracy_decimals: 2

And some restart and reset buttons

button:
  - platform: ld2410
    factory_reset:
      name: "factory reset"
    restart:
      name: "restart"
2 Likes

These may be possible with LD2420, which has somehow a lighter component, on ESP32,with ld2410 it will crash with insufficient ram.

How are you using the internal temp sensor? This thing runs pretty hot

Thanks for all that :slight_smile:

Ive seen this referenced, but cant find out any info?

I ever have some kind of reference in the config for it

    light_threshold:
      name: light threshold

Right so it looks like the light sensor only works in engineering mode?

from the ESPHome doco

light (Optional, int): When in engineering mode, indicates the light sensitivity, otherwise unknown. Value between 0 and 255 inclusive. Though it seems that the value 85 is the lowest value at complete darkness. All options from Sensor.

yes, to use the builtin light sensor aka ldr you have to use engineering mode.

1 Like

the internal temperature sensor is on the esp board, not the sensor itself.

1 Like

can’t find bar-card in hacs.

Yeah, depends on the board. Esp32 wroom is running very hot, above 70 degrees even more than 80. I switched to esp32-c3 that is running much cooler, around 35 degrees.
I use temperature sensor for alerting on the device. If temperature start to go too high send notification before fire start.

1 Like

Hi,

I’m new here, signed up for an account to ask a question. I hope this is a suitable thread to ask in?

I have two home made d1 mini / LD2410c sensors which I’ve had running reliably in Home Assistant for quite a while. When I made them the current version of esphome at the time was 2023.3.2. Recently I made two more sensors and got them working with esphome 2023.10.6 (which required a different yaml configuration). It is actually much better as it allows the LD2410 to be configured from HA, so I updated my two older sensors to the same esphome version.

Everything works fine, but I have one annoying issue I can’t seem to work out. With the older version of esphome the icons for the has_target binary sensor showed up correctly using the given device_class of “occupancy” (the icons for this are mdi:home when occupied and mdi:home_outline when vacant). This worked well for the badges I have on my main HA dashboard and I could tell if a room was occupied at a glance. With the newer version of esphome the has_target binary sensor appears with icon mdi:account and seems to ignore the device_class entirely. If I use a lovelace glance card the colour of the icon changes when a room is occupied as expected, but my badges are now useless because they show the same icon whether a room is occupied or not.

Could anybody give me a clue on how I can fix it? I don’t really care much about what icon is displayed, but reinstating the solid / outline state change is what I am hoping for.

Thanks in advance.

I made a housing for HLK-LD2410 with a BH1750 light sensor + WeMos D1 Mini.

7 Likes

Hm… just wandering… why additional light sensor? LD has one already built-in… for better sensitivity?
Also - it’s not exactly good for wifi range to have wires across wifi antenna… you might want to move them to th bottom side of wemos.

otherwise: excellent job!

  • engineering_mode (Optional): enable/disable engineering mode. Defaults to false. Notice this requires more resources and is not recommended to be enabled when not necessary.

without engineering_mode NO light sensor

1 Like