How to work with HLK-LD1115H and Wemos D1 Mini for Human Presence Detection

So this sensor is now officially supported on ESPHome? Did that just happen? I feel as though this was not true as recently as a month ago! Great news if I’m reading this correctly.

Hi Ryan,

I don’t know about “officially.” Is there such a thing? But, yes, it’s working fine in Home Assistant using the ESPHome integration put together by crlogic.

Here’s the LD2410 on an ESP32-TTGO Mini32.

It runs just fine on the ESP8266 too. That’s an Adafruit Huzzah. The easiest set-up for me is to use hardware serial and disable the logger.

I use that little 12-pin header board adapter to run it on the breadboard.

The sensor works very well and can be configured for all sorts of use cases. I’ve received the “B” version and the Bluetooth configuration works well. My only complaint is the current consumption; it runs at about 80mA. That leaves you in about the same position as the Aqara FP1 or the Everything Presence One; on the short end of a long power cable.

I won’t get excited about any of these mm radar units until I can get one running on battery for 6 months or better.

Looking at some of the new chips (like Acconeer A121), we might see something soon but I won’t hold my breath. :smiley:

Cheers,
Larz

That’s excellent. Are you using the yaml here?

Because I tried using that but I get an error: “Component not found: LD2410” and it won’t validate.

I think it is not yet added to esphome. The pull request is still open.

After that it should be working. There is a way to already use this code but I’m not sure how and will wait for the merge and then update esphome asap :wink:

I received 400 of these in the post today. 400? Why not? Only £3 more than the 10 I needed.

What’s the best way to get them out to people who want them? Maybe PayPal for postage plus a pound to say thanks?

Hi Ryan, I’ve seen that YAML, but have not used it.

I’m using this YAML From CRLOGIC posting on 23-Aug-2022

This is an example from my ESP-01 setup. I use the ESP-01’s TX, Rx, and GPIO2 for the mmWave pin.

I’ll set up another two or three on breadboard to prove them out around the house, then draw up a little PCB to tighten it up. It looks like it will be about 40 x 20 x 15cm with a USB micro or C socket in the end.

P.S. This is pretty nice, but I’m waiting for something I can power with a battery for the better part of a year.

esphome:
  name: esphome-web-111111b
  includes:
    - ld2410_uart.h
  on_boot:
    priority: 600
    # ...
    then:
      - lambda: |-
          auto uart_component = static_cast<LD2410 *>(ld2410);
          uart_component->setNumbers(maxMovingDistanceRange, maxStillDistanceRange, noneDuration);

esp8266:
  board: esp01_1m

# Disable logging
logger:
    baud_rate: 0
    level: none

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

ota:
  password: "secret"

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esphome-Web-3B24Ec"
    password: "1ZJLbjd8PPzk"

captive_portal:

uart:
  id: uart1
  tx_pin: TX
  rx_pin: RX
  baud_rate: 256000 # Change this according to your setting
  parity: NONE
  stop_bits: 1
  
#debug:
  #  direction: BOTH
  #  dummy_receiver: false
  #  after:
  #    delimiter: [0xF8,0xF7,0xF6,0xF5]
      
custom_component:
  - lambda: |-
      return {new LD2410(id(uart1))};
    components:
      - id: ld2410
      
binary_sensor:
  - platform: custom
    lambda: |-
      auto uart_component = static_cast<LD2410 *>(ld2410);
      return {uart_component->hasTarget,uart_component->hasMovingTarget,uart_component->hasStillTarget,uart_component->lastCommandSuccess};
    binary_sensors:
      - name: "Has Target"
      - name: "Has Moving Target"
      - name: "Has Still Target"
      - name: "Last Command Success"
  - platform: gpio
    id: MovOcc_Gpio
    pin:
      number: GPIO2
      mode:
        input: true
        pullup: true
    name: "mmWave Pin"
    filters:
      - delayed_on: 10ms
    device_class: occupancy

sensor:
  - platform: custom
    lambda: |-
      auto uart_component = static_cast<LD2410 *>(ld2410);
      return {uart_component->movingTargetDistance,uart_component->movingTargetEnergy,uart_component->stillTargetDistance,uart_component->stillTargetEnergy,uart_component->detectDistance};
    sensors:
      - name: "Moving Target Distance"
        unit_of_measurement: "cm"
        accuracy_decimals: 0
      - name: "Moving Target Energy"
        unit_of_measurement: "%"
        accuracy_decimals: 0
      - name: "Still Target Distance"
        unit_of_measurement: "cm"
        accuracy_decimals: 0
      - name: "Still Target Energy"
        unit_of_measurement: "%"
        accuracy_decimals: 0
      - name: "Detect Distance"
        unit_of_measurement: "cm"
        accuracy_decimals: 0

number:        
  - platform: template
    name: "Max Moving Distance Range"
    id: maxMovingDistanceRange
    min_value: 1
    max_value: 8
    step: 1
    update_interval: never
    optimistic: true
    set_action:
      - lambda: |-
          auto uart_component = static_cast<LD2410 *>(ld2410);
          uart_component->setMaxDistancesAndNoneDuration(x,id(maxStillDistanceRange).state,id(noneDuration).state);
  - platform: template
    name: "Max Still Distance Range"
    id: maxStillDistanceRange
    min_value: 1
    max_value: 8
    step: 1
    update_interval: never
    optimistic: true
    set_action:
      - lambda: |-
          auto uart_component = static_cast<LD2410 *>(ld2410);
          uart_component->setMaxDistancesAndNoneDuration(id(maxMovingDistanceRange).state,x,id(noneDuration).state);
  - platform: template
    name: "None Duration"
    id: noneDuration
    min_value: 0
    max_value: 32767
    step: 1
    mode: box
    update_interval: never
    optimistic: true
    set_action:
      - lambda: |-
          auto uart_component = static_cast<LD2410 *>(ld2410);
          uart_component->setMaxDistancesAndNoneDuration(id(maxMovingDistanceRange).state,id(maxStillDistanceRange).state,x);
      
button:
  - platform: template
    name: "Reboot LD2410"
    on_press:
      lambda: 'static_cast<LD2410 *>(ld2410)->reboot();'
  - platform: template
    name: "Turn on config mode"
    on_press:
      - lambda: 'static_cast<LD2410 *>(ld2410)->setConfigMode(true);'
  - platform: template
    name: "Turn off config mode"
    on_press:
      - lambda: 'static_cast<LD2410 *>(ld2410)->setConfigMode(false);'
  - platform: template
    name: "Get config"
    on_press:
      - lambda: 'static_cast<LD2410 *>(ld2410)->queryParameters();'
  - platform: template
    name: "Set baud rate to 256000"
    on_press:
      - lambda: 'static_cast<LD2410 *>(ld2410)->setBaudrate(7);'
  - platform: template
    name: "Set baud rate to 115200"
    on_press:
      - lambda: 'static_cast<LD2410 *>(ld2410)->setBaudrate(5);'
  - platform: template
    name: "Set baud rate to 9600"
    on_press:
      - lambda: 'static_cast<LD2410 *>(ld2410)->setBaudrate(1);'

Thank you for sharing this. Definitely interested to see what you come up with on the PCB. Is there anyway to know or get feedback on whether a change to the sensitivity on this sensor has taken? I think I’m adjusting it but not seeing a lot difference in behavior so maybe I’m not actually changing anything?

The d1 mini v3.0 seems to have a problem with uart1.

Try using uart2 .
Works great.

uart:
  id: uart2
  tx_pin: 15
  rx_pin: 13
  baud_rate: 256000 # Change this according to your setting
  parity: NONE
  stop_bits: 1
  debug:
    direction: BOTH
    dummy_receiver: false
    after:
      delimiter: [0xF8,0xF7,0xF6,0xF5]
      
custom_component:
  - lambda: |-
      return {new LD2410(id(uart2))};
    components:
      - id: ld2410
2 Likes

first time i heard about these “M5Stack Atom”. they look really cool! what do you use them for?
Do you use the HDMI port? it seems like an overkill to run these for a Rador sensor.

I just use them for esphome at the moment - radars and ibeacon catchers.

Lite doesn’t have HDMI. Alternatively, you can flash Tasmota32, and have an interpreted language on-chip.

As to overkill - it’s $8 with an enclosure, come on :wink:

Hi all. I think I read this thread 16 times. haha. Now I´m just confused. Which configuration/yaml and pins should I use for a Wemos D1 Mini and HLK-LD1115H? This is my first ESP project so please bare with me :wink:

Regards

Very very late reply, to use the code before official integration you can use external component.

external_components:

source: github://sebcaps/esphome@ld2410-nocore
components: [ld2410]

Hope it will be merged soon.

1 Like

See this for wiring and code: How to work with HLK-LD1115H and Wemos D1 Mini for Human Presence Detection - #43 by patrick339

I just built one myself and loving the results. Thanks again @patrick339

Thanks. Got it working. Trying to figure out the sensitivity now. Tried putting it in a pringles can to make it not pickup detection from the sides. LoL. Works pretty good.

hello,

EspHome 2023.2.0 is out today, i try it because in the doc seems the ld2410 support is ok, but it doesnt compile because component ld2410 still unknow…

seems its still only in EspHome-dev…

Im right?

Thanks @sebcaps for your great work on this component!

After the ESPhome 2023.2.0 update, I tried the compilation on the D1 mini and it passed without errors.
I will try everything when I connect the sensor.

can you provide your code please?

Here is. Change the sensor names to your native language.
It will take some fiddling with the zone settings, but it works for now.

esphome:
  name: radar-ld2410-1
  friendly_name: radar-ld2410-1

esp8266:
  board: esp01_1m

# Enable logging
logger:
  baud_rate: 0

# Enable Home Assistant API
api:

ota:
  password: "f1fc1dd8782116f1fd13d8c5f3092c"

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Radar-Ld2410-1 Fallback Hotspot"
    password: "lQGe1BWnVOcs"

captive_portal:

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

ld2410:
  timeout: 5s
  max_move_distance : 6m
  max_still_distance: 0.75m
  g0_move_threshold: 50
  g0_still_threshold: 0
  g1_move_threshold: 50
  g1_still_threshold: 0
  g2_move_threshold: 40
  g2_still_threshold: 40
  g3_move_threshold: 40
  g3_still_threshold: 40
  g4_move_threshold: 40
  g4_still_threshold: 40
  g5_move_threshold: 40
  g5_still_threshold: 40
  g6_move_threshold: 30
  g6_still_threshold: 15
  g7_move_threshold: 30
  g7_still_threshold: 15
  g8_move_threshold: 30
  g8_still_threshold: 15

sensor:
  - platform: ld2410
    moving_distance:
      name : Pohyb cíl vzdálenost
    still_distance:
      name: Statický cíl vzdálenost
    moving_energy:
      name: Pohyb cíl energie
    still_energy:
      name: Statický cíl energie
    detection_distance:
      name: Detekční vzdálenost

binary_sensor:
  - platform: ld2410
    has_target:
      name: Přítomnost
    has_moving_target:
      name: Pohybující se cíl
    has_still_target:
      name: Statický cíl

i dont see any difference with my code…

Nope doesnt compile…same error : complaining about ld2410 component not found…

i think there is something missing in my EspHome update…i delete addon and reinstall…same problem…

ld2410: [source /config/esphome/capteur-presence-sejournew.yaml:41]
Component ld2410 cannot be loaded via YAML (no CONFIG_SCHEMA).
Platform not found: 'binary_sensor.ld2410'
Platform not found: 'sensor.ld2410'.

I found a solution: for those having problems with ld2410 component in EspHome 2023.2.1, add this to your node did the trick :

external_components:
  - source: github://esphome/esphome@dev
    components: [ ld2410 ]

i dont understand why i am the only one who having trouble with LD2410 component in the last EspHome 2023.2.1 or 2023.2.2 of today, same problem…

I use the “standard” AddOn : EspHome, not “Beta” or “Dev” version, and it seems that LD2410 is, for the moment, only on the Dev version of the EspHome AddOn, that why the component LD2410 is not found on the basic version of EspHome :smile: