ESP32-C3 and LD2450 – A Quick Look

If you’re looking for cheap presence-movement-sensing in ESP-Home, you may have, like me spent a while looking at YouTube only to get disappointed. Several videos on the subject are by one guy who leads you to his LD2450 project on the basis of subscribing to his channel to get source code – only to find there is a paid subscription level to get that far. I wasted FAR too much time on this..

So the SHORT answer is – I wanted LD2450 sensing – and an RGB LED and the webUI running. And here it is…

This page down at sub-heading EXAMPLE CONFIGURATION has almost all of the above.

I added in a fixed IP as the project in ESP-HOME was only working intermittently… I then added in the WEB SERVer and LIGHT sections at the bottom – check out this code..

esphome:
  name: ld2450-radar-1
  ld2450_id: my_ld2450_radar_1
  friendly_name: ld2450-radar-1

esp32:
  board: esp32-c3-devkitm-1

logger:

api:

ota:
  - platform: esphome

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

  manual_ip:
    static_ip: 192.168.1.199
    gateway: 192.168.1.1
    subnet: 255.255.255.0

uart:
  id: uart_ld2450
  tx_pin: GPIO21
  rx_pin: GPIO20
  baud_rate: 256000
  parity: NONE
  stop_bits: 1

ld2450:
  id: ld2450_radar
  uart_id: uart_ld2450

binary_sensor:
  - platform: ld2450
    ld2450_id: ld2450_radar
    has_target:
      name: Presence
    has_moving_target:
      name: Moving Target
    has_still_target:
      name: Still Target

number:
  - platform: ld2450
    ld2450_id: ld2450_radar
    presence_timeout:
      name: "Timeout"
    zone_1:
      x1:
        name: Zone-1 X1
      y1:
        name: Zone-1 Y1
      x2:
        name: Zone-1 X2
      y2:
        name: Zone-1 Y2
    zone_2:
      x1:
        name: Zone-2 X1
      y1:
        name: Zone-2 Y1
      x2:
        name: Zone-2 X2
      y2:
        name: Zone-2 Y2
    zone_3:
      x1:
        name: Zone-3 X1
      y1:
        name: Zone-3 Y1
      x2:
        name: Zone-3 X2
      y2:
        name: Zone-3 Y2

switch:
  - platform: ld2450
    ld2450_id: ld2450_radar
    bluetooth:
      name: "Bluetooth"
    multi_target:
      name: "Multi Target Tracking"

select:
  - platform: ld2450
    ld2450_id: ld2450_radar
    baud_rate:
      name: "Baud rate"
    zone_type:
      name: "Zone Type"

button:
  - platform: ld2450
    ld2450_id: ld2450_radar
    factory_reset:
      name: "LD2450 Factory Reset"
      entity_category: "config"
    restart:
      name: "LD2450 Restart"
      entity_category: "config"

text_sensor:
  - platform: ld2450
    ld2450_id: ld2450_radar
    version:
      name: "LD2450 Firmware"
    mac_address:
      name: "LD2450 BT MAC"
    target_1:
      direction:
        name: "Target-1 Direction"
    target_2:
      direction:
        name: "Target-2 Direction"
    target_3:
      direction:
        name: "Target-3 Direction"

sensor:
  - platform: ld2450
    ld2450_id: ld2450_radar
    target_count:
      name: Presence Target Count
  - platform: ld2450
    ld2450_id: ld2450_radar
    still_target_count:
      name: Still Target Count
  - platform: ld2450
    ld2450_id: ld2450_radar
    moving_target_count:
      name: Moving Target Count
  - platform: ld2450
    ld2450_id: ld2450_radar
    target_1:
      x:
        name: Target-1 X
      y:
        name: Target-1 Y
      speed:
        name: Target-1 Speed
      angle:
        name: Target-1 Angle
      distance:
        name: Target-1 Distance
      resolution:
        name: Target-1 Resolution
    target_2:
      x:
        name: Target-2 X
      y:
        name: Target-2 Y
      speed:
        name: Target-2 Speed
      angle:
        name: Target-2 Angle
      distance:
        name: Target-2 Distance
      resolution:
        name: Target-2 Resolution
    target_3:
      x:
        name: Target-3 X
      y:
        name: Target-3 Y
      speed:
        name: Target-3 Speed
      angle:
        name: Target-3 Angle
      distance:
        name: Target-3 Distance
      resolution:
        name: Target-3 Resolution
    zone_1:
      target_count:
        name: Zone-1 All Target Count
      still_target_count:
        name: Zone-1 Still Target Count
      moving_target_count:
        name: Zone-1 Moving Target Count
    zone_2:
      target_count:
        name: Zone-2 All Target Count
      still_target_count:
        name: Zone-2 Still Target Count
      moving_target_count:
        name: Zone-2 Moving Target Count
    zone_3:
      target_count:
        name: Zone-3 All Target Count
      still_target_count:
        name: Zone-3 Still Target Count
      moving_target_count:
        name: Zone-3 Moving Target Count

  
web_server:
  port: 80
  version: 3

light:
  - platform: esp32_rmt_led_strip
    id: rgb_light
    name: "RGB Light"
    pin: GPIO3
    default_transition_length: 0s
    chipset: WS2812
    num_leds: 3
    rgb_order: grb
    effects:
      - pulse:
          name: "Slow Pulse"
          transition_length: 1000ms
          update_interval: 1000ms
          min_brightness: 50%
          max_brightness: 100%
      - pulse:
          name: "Fast Pulse"
          transition_length: 100ms
          update_interval: 100ms
          min_brightness: 50%
          max_brightness: 100%
 

Oh, important – chosen Rx pin on the ESP to tx on the LD2450 – and tx to rx. The only difficulty I’m having with this (note: the WS2812b LED I added is on gpio 3) is.. ESPHOME keeps confusing the entities with my Apollo MTR1 entities – haven’t 100% figured out why – I can look at the entities in Home Assistant – fine – but then I hit the cog to dig in deeper, HA shows me the Apollo versions. However the logs work, the webUI works and I can control the RGB light as well as seeing valid readings… according to ChatGPT, you need to prefix the names of the entities in the YAML to make them unique…. that works but I’m going to go check on that to see if you really need to rename the lot – seems OTT.

Meanwhile I’ve been reading about using the HLK LD2410C – that looks potentially even easier. For my purposes I don’t need multi-zones or multi-people… just the simplest but reliable static and moving detection – something I coul never completely count on with other solutions.

Ordering LD2410Cs now and mini-ESP32-S3 – for the built-in RGB LED (for wiring simplicity). Feel free to send feedback in the comments:-)

Leave a Reply

Your email address will not be published. Required fields are marked *

Leave the field below empty!


The maximum upload file size: 512 MB. You can upload: image, audio, video, document, spreadsheet, interactive, text, archive, code, other. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here