LD2410 esphome tips

I believe v2.05 was pulled as it turned off Bluetooth by default and the current ESPHome integration doesn’t allow you to turn it back on. Using the dev version of the ESPHome integration for the LD2410 allows you to turn Bluetooth back on but that will only work if you have connected the LD2410 to the ESP board using UART.

1 Like

The new version of regevbr’s library above comes with a lot of new features, it has a bluetooth switch.
github://regevbr/esphome@ld2410

In our most recent run of over 500 LD2410C and LD2410B modules, they were preloaded with the latest firmware 2.04, and their Bluetooth status was turned on, as we usually do to spot-check their Bluetooth functionality. This is at least the case with factory batches.

That’s weird about the 2.05 firmware, we haven’t seen it yet, it must have been withdrawn.

to Protoncek:
I think I can get feedback to the hlk devs on this one for you. Hopefully their newer versions will be improved for multiple languages.

just get back from hlk dev team:

  • this week will have a new app version public, which mush better language support.
  • v2.05 is a beta firmware, not stable firmware.
1 Like

Please to send the following 3 instructions in sequence:

  1. Enable configuration: FD FC FB FA 04 00 FF 00 01 00 04 03 02 01
  2. Open Bluetooth: FD FC FB FA 04 00 A4 00 01 00 04 03 02 01
  3. Restart module: FD FC FB FA 02 00 A3 00 04 03 02 01
4 Likes

HI,Please to send the following 3 instructions in sequence:

  1. Enable configuration: FD FC FB FA 04 00 FF 00 01 00 04 03 02 01
  2. Open Bluetooth: FD FC FB FA 04 00 A4 00 01 00 04 03 02 01
  3. Restart module: FD FC FB FA 02 00 A3 00 04 03 02 01

HI,Please try to send the following 3 instructions in sequence:

  1. Enable configuration: FD FC FB FA 04 00 FF 00 01 00 04 03 02 01
  2. Open Bluetooth: FD FC FB FA 04 00 A4 00 01 00 04 03 02 01
  3. Restart module: FD FC FB FA 02 00 A3 00 04 03 02 01

could you advise on the led wiring on the output please diagram if you have

I’m struggling with getting my LD2410B working with MH-ET Live ESP32 DevKit. All I’m seeing is ‘Unknown’ status for all the sensors.
I’m powering the board via USB 5v, tried crossing and uncrossing RX/TX; I’m not sure what else I can try.

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

esp32:
  board: esp32dev
  framework:
    type: esp-idf
# Enable logging
logger:
  baud_rate: 0

# Enable Home Assistant API
api:

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

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

ld2410:

  timeout: 5s

  max_move_distance: 2.25m

  max_still_distance: 2.25m

  g0_move_threshold: 40  # 0m / 0'

  g0_still_threshold: 10 # 0m / 0'

  g1_move_threshold: 40  # 0 - 0.75m / 0 - 2.46'

  g1_still_threshold: 10 # 0 - 0.75m / 0 - 2.46'

  g2_move_threshold: 40  # 0.75 - 1.5m / 2.46' - 4.92'

  g2_still_threshold: 10 # 0.75 - 1.5m / 2.46' - 4.92'

  g3_move_threshold: 40  # 1.5 - 2.25m / 4.92' - 7.38'

  g3_still_threshold: 10 # 1.5 - 2.25m / 4.92' - 7.38'

  g4_move_threshold: 40  # 2.25 - 3m' / 7.38' - 9.84'

  g4_still_threshold: 40 # 2.25 - 3m' / 7.38' - 9.84'

  g5_move_threshold: 40  # 3 - 3.75 / 9.84' - 12.30'

  g5_still_threshold: 40 # 3 - 3.75 / 9.84' - 12.30'

  g6_move_threshold: 30  # 3.75 - 4.5m / 12.30' - 14.76'

  g6_still_threshold: 15 # 3.75 - 4.5m / 12.30' - 14.76'

  g7_move_threshold: 30  # 4.5 - 5.25m / 14.76' - 17.22'

  g7_still_threshold: 15 # 4.5 - 5.25m / 14.76' - 17.22'

  g8_move_threshold: 30  # 5.25 - 6m / 17.22' - 19.68'

  g8_still_threshold: 15 # 5.25 - 6m / 17.22' - 19.68'

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

binary_sensor:

  - platform: ld2410

    has_target:

      name: Presence

    has_moving_target:

      name: Moving Target

    has_still_target:

      name: Still Target

Thanks for any assistance

Try to change these wires and config

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

Looking at the pin outs for your board on the following site, you can try using GPIO9/GPIO10 for the TX/RX pins. On some ESP32 boards, like the one I have, a Wemos D1 mini compatible ESP32 board, UART0 cannot be used and UART1 should be used instead.

https://doc.riot-os.org/group__boards__esp32__mh-et-live-minikit.html

rx0 pin is on many esp32 boards with usb unusable because usb chip holds it at certain level (it’s not high impedance), so no other device can communicate becase of that - esp sends request, but never gets an answer. So, use any other but 1 and 3.

Hi
How to use number entity to set max distance in esphome official component:
Here is how it looks like on an external library:

esphome:
  name: "sample"
  includes:
    - ld2410.h

custom_component:
  - lambda: |-
      auto c = new LD2410(uart_bus);
      App.register_component(c);
      return {c};
    components:
      - id: ld2410

number:
  - platform: template
    id: maxConfigDistance
    update_interval: never
    optimistic: true
    unit_of_measurement: "cm"
    min_value: 75
    max_value: 600
    step: 75
    set_action:
      - lambda: |-
          auto c = static_cast<LD2410 *>(ld2410);
          c->setMaxDistancesAndNoneDuration(x, x, id(noneDuration).state);

Hey guys,

My detection does not turn off. Can anyone see anything wrong with my YAML?

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

ld2410:
  uart_id: ld2410_uart  
  timeout: 150s
  max_move_distance : 2.25m
  max_still_distance: 0.75m
  g0_move_threshold: 10
  g0_still_threshold: 20
  g1_move_threshold: 10
  g1_still_threshold: 20
  g2_move_threshold: 20
  g2_still_threshold: 21
  g3_move_threshold: 30
  g3_still_threshold: 31
  g4_move_threshold: 40
  g4_still_threshold: 41
  g5_move_threshold: 50
  g5_still_threshold: 51
  g6_move_threshold: 60
  g6_still_threshold: 61
  g7_move_threshold: 70
  g7_still_threshold: 71
  g8_move_threshold: 80
  g8_still_threshold: 81

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

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

You probably need to tune the g1 to g8 move and still thresholds as each room is different and you may have something in your room triggering one of the movement/still gates so causing presence to be detected all the time.
I have my closer gates (g0 - g 4) set quite high at around 50 to 60 and the further away gates (g5 to g8) set lower at around 20 to 30. Think of the values as movement percentage required to trigger detection. So a value of say 90 will require lots of movement to trigger a detection.

If you have a LD2410B/C with bluetooth, you can use the HLKRadarTool phone app to connect to it and with Engineering Mode turned on, you can see which gate is being triggered on the graphs in the app.

2 Likes

Cool thank you for that :slight_smile:

I seem to have found a config that works. But ill keep the app in mind for further tweaking :slight_smile:

ld2410:
  timeout: 5s
  max_move_distance: 2.25m
  max_still_distance: 2.25m
  g0_move_threshold: 40  # 0m / 0'
  g0_still_threshold: 10 # 0m / 0'
  g1_move_threshold: 40  # 0 - 0.75m / 0 - 2.46'
  g1_still_threshold: 10 # 0 - 0.75m / 0 - 2.46'
  g2_move_threshold: 40  # 0.75 - 1.5m / 2.46' - 4.92'
  g2_still_threshold: 10 # 0.75 - 1.5m / 2.46' - 4.92'
  g3_move_threshold: 40  # 1.5 - 2.25m / 4.92' - 7.38'
  g3_still_threshold: 10 # 1.5 - 2.25m / 4.92' - 7.38'
  g4_move_threshold: 40  # 2.25 - 3m' / 7.38' - 9.84'
  g4_still_threshold: 40 # 2.25 - 3m' / 7.38' - 9.84'
  g5_move_threshold: 40  # 3 - 3.75 / 9.84' - 12.30'
  g5_still_threshold: 40 # 3 - 3.75 / 9.84' - 12.30'
  g6_move_threshold: 30  # 3.75 - 4.5m / 12.30' - 14.76'
  g6_still_threshold: 15 # 3.75 - 4.5m / 12.30' - 14.76'
  g7_move_threshold: 30  # 4.5 - 5.25m / 14.76' - 17.22'
  g7_still_threshold: 15 # 4.5 - 5.25m / 14.76' - 17.22'
  g8_move_threshold: 30  # 5.25 - 6m / 17.22' - 19.68'
  g8_still_threshold: 15 # 5.25 - 6m / 17.22' - 19.68'
2 Likes

depends of the led you use, this example is for a tiny red one.

image
Using the algebraic formula (above) and assuming {\displaystyle V_{switch}} is 0 (to simplify examples), the resistance is calculated as follows:

{\displaystyle I_{led}} = (5V - 1.8V) / 1K ohm = (5 - 1.8) / 1000 = 0.0032, which is 3.2mA

and here

{\displaystyle I_{led}} = (3.3V - 1.8V) / 220 ohm = 0.0032, which is 6.8mA
or less bright :slight_smile:
{\displaystyle I_{led}} = (3.3V - 1.8V) / 680 ohm = (3.3 - 1.8) / 680 = 0.0022, which is 2.2mA

and the 3D Print case on Thingiverse :slight_smile:

2 Likes

That’s cool, we just finished our new radar 1M as well, it’s pretty much the smallest radar we’ve ever done, a little smaller than the 1U.


2 Likes

Completed project as well - battery operated one!





Files for printing: Presence Sensor by elik745i - Thingiverse
More about project: Как использовать батарею одноразового вейпа с пользой — Сообщество «Сделай Сам» на DRIVE2

How long does it last on battery?
With 78mA power consumption shouldn’t be very battery-friendly

That’s cool, but the battery life is really an interesting issue, we tried it with a 10,000 mAh mobile power supply and it died in almost a day or so.
I found it and it shows five hours on the website.

What a pity!

The charge level could be displayed as a percentage, so it might be a bit more intuitive.