Skip to content

Instantly share code, notes, and snippets.

@peyanski
Last active December 8, 2024 15:51
Show Gist options
  • Save peyanski/5d46c7323385b38c64235f88e43df8c4 to your computer and use it in GitHub Desktop.
Save peyanski/5d46c7323385b38c64235f88e43df8c4 to your computer and use it in GitHub Desktop.
Use this code to make your LD2410 sensor to work with ESP32 or ESP8266 board
esphome:
name: ld2410-esp32
friendly_name: ld2410-esp32
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "IArm3ZGuqL1HLZXXbu4/L0ciw1TDSagu6THKP8LnFdo="
ota:
password: "3373716c7967d461cf4bd0ce1ba42e9a"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Ld2410-Esp32 Fallback Hotspot"
password: "AhxmD317i7r1"
captive_portal:
light:
- platform: binary
name: "Blue Status Light"
output: light_output
id: led_light
restore_mode: ALWAYS_OFF
output:
- platform: gpio
pin: GPIO2
id: light_output
i2c:
sda: 21
scl: 22
scan: true
id: bus_a
uart:
id: ld2410_uart
tx_pin: RX
rx_pin: TX
baud_rate: 256000
parity: NONE
stop_bits: 1
ld2410:
uart_id: ld2410_uart
throttle: 1500ms
id: ld2410_comp
select:
- platform: ld2410
distance_resolution:
name: distance resolution
baud_rate:
name: baud rate
light_function:
name: light function
out_pin_level:
name: out pin level
button:
- platform: ld2410
factory_reset:
name: "factory reset"
restart:
name: "restart"
query_params:
name: query params
number:
- platform: ld2410
timeout:
name: timeout
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
light_threshold:
name: light threshold
text_sensor:
- platform: ld2410
version:
name: "presenece sensor version"
mac_address:
name: "presenece sensor mac address"
switch:
- platform: ld2410
engineering_mode:
name: "engineering mode"
bluetooth:
name: control Bluetooth
sensor:
- platform: ld2410
moving_distance:
name: "Moving distance (cm)"
still_distance:
name: "Still Distance (cm)"
moving_energy:
name: "Move Energy (%)"
still_energy:
name: "Still Energy (%)"
detection_distance:
name: "Distance Detection (cm)"
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
light:
name: light
- platform: bh1750
name: "Illuminance"
address: 0x23
update_interval: 30s
binary_sensor:
- platform: ld2410
has_target:
name: Presence
has_moving_target:
name: Moving Target
has_still_target:
name: Still Target
@calbu
Copy link

calbu commented Dec 28, 2023

Has anyone a working yaml file for NodeMMCU v3? Both of the above configs are not working for it.

@sixoremenos
Copy link

@CTEBAvuk Thank you very much! Your suggestions worked fine with my D1 mini.

@lylydang
Copy link

lylydang commented Jan 26, 2024

I still cannot be able to get my Esp Vroom32 to work, all configs came out Unknown for my sensor, anyone have the same issue :(?
Nvm swapped out the TX and RX pins, it works now.

@ashoktvm
Copy link

ashoktvm commented Feb 9, 2024

Can I get zone options in this?

@superaviator
Copy link

I still cannot be able to get my Esp Vroom32 to work, all configs came out Unknown for my sensor, anyone have the same issue :(? Nvm swapped out the TX and RX pins, it works now.

Swapped out in which way?

@giuseppe-93
Copy link

giuseppe-93 commented Apr 29, 2024

Hello. This Yaml code that you published is fine for D1 mini right?

@Jacks5000
Copy link

I've try different Yaml files and still getting Unknown I'm using D1 mini and LD2410c , I have confirmed my wiring is correct but no go

any ideas

@dargoninio
Copy link

dargoninio commented May 7, 2024

I get this message, I can count on help,
ERROR Running command failed: device reports readiness to read but returned no data (device disconnected or multiple access on port?)
ERROR Please try running esptool.py --before default_reset --after hard_reset --baud 460800 --port /dev/ttyUSB0 --chip esp32 write_flash -z --flash_size detect 0x10000 /data/build/ld2410-esp32/.pioenvs/ld2410-esp32/firmware.bin 0x1000 /data/build/ld2410-esp32/.pioenvs/ld2410-esp32/bootloader.bin 0x8000 /data/build/ld2410-esp32/.pioenvs/ld2410-esp32/partitions.bin 0xe000 /data/cache/platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin locally.
INFO Upload with baud rate 460800 failed. Trying again with baud rate 115200.

@qpaulson
Copy link

It doesn't work for me either using a D1 Mini and the LD2410 without Bluetooth. I also get "Found no i2c devices!" so disabled that already as well as "platform: bh1750" that wasn't detected either

This is most likely because the device uses the same rx/tx as the usb. Try flashing a base ESPHome firmware before attaching the device. Once flashed, you can perform subsequent updates via OTA updates.

@Jacks5000
Copy link

Jacks5000 commented Aug 27, 2024

I managed to get it working using a D1 mini and a LD2410 , the Yaml files is below

` captive_portal:

uart:
id: ld2410_uart
tx_pin: GPIO15
rx_pin: GPIO13
baud_rate: 256000
parity: NONE
stop_bits: 1

ld2410:
uart_id: ld2410_uart

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

select:

  • platform: ld2410
    distance_resolution:
    name: Distance Resolution
    baud_rate:
    name: Baud Rate
    light_function:
    name: Light Function
    out_pin_level:
    name: Out Pin Level

sensor:

  • platform: ld2410
    light:
    name: Light
    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

binary_sensor:

  • platform: ld2410
    has_target:
    name: Presence
    has_moving_target:
    name: Moving Target
    has_still_target:
    name: Still Target
    out_pin_presence_status:
    name: Out Pin Presence Status
    `

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment