Skip to content

No succes #17

@Princessalbert

Description

@Princessalbert

Hello all. Been trying everything i can find to get my HLK-LD2410B working with my D1 MINI V3.0.0 - Mini NodeMcu board. Only get unknown status whatever i do..

To make sure, i got 5 of each and all work on their own. However the LD2410 don't seem to work when powered from the 5v on the esp.. So using external power for both.
Then i also tried all combos of yaml files that i can find combined with the .h from https://github.com/rain931215/ESPHome-LD2410.
And tried all uart combos..
tx_pin: GPIO15, rx_pin: GPIO13
tx_pin: GPIO1, rx_pin: GPIO3
tx_pin: GPIO3, rx_pin: GPIO1
tx_pin: RX, rx_pin: TX
tx_pin: TX, rx_pin: RX

Using latest esphome 2023.5.0 (dev), and latest HA on a virtual machine.
Read that some had succes reverting to version 2023.3.2 of esphome but that seams impossible on a vm?

Currently my yaml looks like this

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

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

esp8266:
  board: esp01_1m

logger:
  baud_rate: 0

api:
  encryption:
    key: "="

ota:
  password: ""

wifi:
  ssid: 
  password: 

  manual_ip:
    static_ip: 192.168.1.124
    gateway: 192.168.1.1
    subnet: 255.255.255.0

uart:
  id: uart_1
  rx_pin: GPIO3
  tx_pin: GPIO1
  baud_rate: 256000
  data_bits: 8
  stop_bits: 1
  parity: NONE

custom_component:
  - lambda: |-
      return {new LD2410(id(uart_1))};
    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"

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);'

Anyone have a similar setup with any succes?
If not, any thips for a new esp board that might work better?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions