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

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:

Did anyone ever get to the bottom of the “unknown” sensors, glad to see others have the same issue at least? I’m using the minimal examples from the esphome documentation and it’s still giving me unknown for the sensors. I know the device is working as I can see it in the bluetooth app. I’ve tried the custom yaml in here (same problem) but I’d prefer to stay as simple as possible ideally. TX on the board is wired to RX on the d1 mini and RX is wired to TX on the v3 d1_mini as per the above examples.

esphome:
  name: living_room_ld2410

# Enable Home Assistant API
api:

esp8266:
  board: d1_mini

logger:
  baud_rate: 0

ota:

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

  ap:
    ssid: "LD2410 Fallback Hotspot"

captive_portal:

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

ld2410:
  timeout: 150s
  max_move_distance : 6m
  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: Presence
    has_moving_target:
      name: Moving Target
    has_still_target:
      name: Still Target

I already had a problem with cables several times. I do not recommend soldering directly to the pins. Use a plug. Replace the cables.

Check this:
TX Pin: GPIO1
RX Pin: GPIO3

uart:
  id: uart1
  tx_pin: TX
  rx_pin: RX

Alas I’m almost certain I have a bad board, I’ve tried everything I can think of now. I’ve not had a problem with any of my other esphome projects.

  • 5 different sets of micro JST connectors
  • Connected to TX and RX pins on the D1 and also to D7, D8.
  • Two D1 minis of different versions
  • Multiple different versions of esphome config.

I’ve resorted to putting a ESP32 bluetooth beacon nearby which seems to be working okay. Although not an ideal setup.

Same here. Will also debug this weekend. I’m not sure the board is broken. Maybe we can create a normal arduino script for the sensor and see by logging to the serial port if the measurements are stable and keep coming. Because in my case I fully loose connection to the espboard and therefore have no logs anymore