LD2450 Sensor

Component

The ld2450 component allows you to use the HLK-LD2450 human presence, motion detection and tracking radar module with ESPHome.

Target tracking involves real-time tracking of the position of a (moving) target within a specific area, enabling measurement of the target’s distance, angle and speed (relative to the sensor).

The LD2450 is a sensor module for motion target tracking within the Hi-link 24G millimeter-wave radar series. This module features simplified 24 GHz radar sensor hardware and intelligent algorithm firmware. It’s primarily intended for use indoors to enable the location tracking of moving human targets.

HLK-LD2450 official data sheet and user manuals

HLKRadarTool Android App

HLKRadarTool iOS App

Note

Ensure that the LD2450 firmware version is V2.02.23090617 or later for proper integration functionality. You can use the HLKRadarTool mobile app to update the firmware.

../../_images/ld2450.png

HLK-LD2450 radar module

The UART is required to be set up in your configuration for this sensor to work, parity and stop_bits must be respectively NONE and 1. Use of hardware a UART is highly recommended in order to properly support the default 256000 baud rate of the LD2450 module.

# ld2450 configuration
ld2450:
  id: ld2450_radar
  throttle: 1000ms

Configuration variables:

  • id (Optional, ID): Manually specify the ID for this LD2450 Sensor component.

  • uart_id (Optional, ID): Manually specify the ID of the UART Component to use. Required if you have multiple UARTs configured.

  • throttle (Optional, int): Time in milliseconds to control the rate of data updates. Defaults to 1000ms.

Binary Sensor

The ld2450 binary sensor offers presence states for the targets.

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

Configuration variables:

  • ld2450_id (Optional, ID): Manually specify the ID for the LD2450 Sensor component.

  • has_target (Optional): True if either target is still or in movement. All options from Binary Sensor.

  • has_moving_target (Optional): True if a moving target is detected. All options from Binary Sensor.

  • has_still_target (Optional): True if a still target is detected. All options from Binary Sensor.

Sensor

The ld2450 sensor provides you with information about the states and attributes of detected targets.

sensor:
  - platform: ld2450
    ld2450_id: ld2450_radar
    target_count:
      name: Presence Target Count
    still_target_count:
      name: Still Target Count
    moving_target_count:
      name: Moving Target Count
    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

Configuration variables:

  • ld2450_id (Optional, ID): Manually specify the ID for the LD2450 Sensor component.

  • target_count (Optional, int): Total targets detected, whether they are stationary or in motion. All options from Sensor.

  • still_target_count (Optional, int): Count of stationary targets. All options from Sensor.

  • moving_target_count (Optional, int): Count of moving targets. All options from Sensor.

  • target_N (Optional): Details about the targets (N = 1 to 3). A maximum of 3 targets can be detected: target_1, target_2, target_3.

    • x (Optional, int): Distance in millimeter (mm) of the target from the ld2450 sensor along the X-axis (negative for left side of the sensor, positive for right side of the sensor). The ld2450 module can detect targets from -3000 to 3000 mm in X direction. All options from Sensor.

    • y (Optional, int): Distance in millimeter (mm) of the target from the ld2450 sensor in the Y direction (near/far). The ld2450 module can detect targets from 0 to 6000 mm in Y direction. All options from Sensor.

    • speed (Optional, int): Speed of the moving target in mm/s. All options from Sensor.

    • angle (Optional, int): Angle of target in degrees (°) relative to the ld2450 sensor. All options from Sensor.

    • distance (Optional, int): Distance in millimeter (mm) of the target from the ld2450 sensor along the X-axis (negative for left side of the sensor, positive for right side of the sensor). All options from Sensor.

    • resolution (Optional, int): The ld2450 target detection range resolution in millimeter (mm). All options from Sensor.

  • zone_N (Optional): Target count details in the defined zones (N = 1 to 3). A maximum of three zones: zone_1, zone_2, zone_3.

    • target_count (Optional, int): Total targets detected in the zone, whether they are stationary or in motion. All options from Sensor.

    • still_target_count (Optional, int): Count of stationary targets in the zone. All options from Sensor.

    • moving_target_count (Optional, int): Count of moving targets in the zone. All options from Sensor.

Switch

The ld2450 switch allows you to control your LD2450 Sensor Bluetooth and Multi/Single Target Tracking.

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

Configuration variables:

  • ld2450_id (Optional, ID): Manually specify the ID for the LD2450 Sensor component if you are using multiple components.

  • bluetooth (Optional): Turn on/off the bluetooth adapter. Defaults to true. All options from Switch.

  • multi_target (Optional): Turn on/off the Multi Target Tracking option. The initial state set based on the corresponding setting as read from LD2450 module at boot. All options from Switch.

Number

The ld2450 number allows you to control the presence timeout and zone area configuration of your LD2450 Sensor.

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

Configuration variables:

  • ld2450_id (Optional, ID): Manually specify the ID for the LD2450 Sensor component.

  • presence_timeout (Required, int): The duration, in seconds, for which the presence states will persist even after the detection is cleared. Default is 5 seconds. All options from Number.

  • zone_N (Optional): Configuration of the zone (N = 1 to 3), defined as a rectangular area. A maximum of three zones can be configured: zone_1, zone_2, zone_3. The zone coordinates consist of x1, y1 (near-left) to x2, y2 (far-right) relative to the ld2450 sensor.

    • x1 (Optional, int): Start X coordinate in millimeter (mm) of the zone from the ld2450 sensor along the X-axis (negative for left side (-3000) of the sensor, positive for right side (3000) of the sensor). All options from Number.

    • y1 (Optional, int): Start Y coordinate in millimeter (mm) of the zone from the ld2450 sensor along the Y-axis, values range from 0 to 6000. All options from Sensor.

    • x2 (Optional, int): End X coordinate in millimeter (mm) of the zone from the ld2450 sensor along the X-axis (negative for left side (-3000) of the sensor, positive for right side (3000) of the sensor). All options from Number.

    • y1 (Optional, int): Start Y coordinate in millimeter (mm) of the zone from the ld2450 sensor along the Y-axis, values range from 0 to 6000. All options from Sensor.

Button

The ld2450 button allows you to perfrom restart and factory reset actions on your LD2450 Sensor.

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

Configuration variables:

  • ld2450_id (Optional, ID): Manually specify the ID for the LD2450 Sensor component.

  • factory_reset (Optional): Resets the ld2450 to its factory default configuration/values. All options from Button.

  • restart (Optional): Restart the ld2450 device. All options from Button.

Text Sensor

The ld2450 text sensor allows you to get information about your LD2450 Sensor.

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"

Configuration variables:

  • ld2450_id (Optional, ID): Manually specify the ID for the LD2450 Sensor component.

  • version (Optional): The ld2450 firmware version. All options from Text Sensor.

  • mac_address (Optional): The ld2450 Bluetooth MAC address. All options from Text Sensor.

  • target_N (Optional): Targets (N = 1 to 3). A maximum of 3 targets can be detected: target_1, target_2, target_3.

    • direction (Optional): Direction of the target relative to the ld2450 sensor. Possible values are: Stationary, Moving away, Approaching, NA. All options from Sensor.

Select

The ld2450 select allows you to control baud rate and zone type of your LD2450 Sensor.

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

Configuration variables:

  • ld2450_id (Optional, ID): Manually specify the ID for the LD2450 Sensor component.

  • baud_rate (Optional): Control the UART serial port baud rate. Defaults to 256000. Once changed, all sensors will stop working until a fresh install with an updated UART Component configuration. All options from Select.

  • zone_type (Optional): Control the zone detection modes. It can be set to Disabled, Detection or Filter. Selecting the Disabled option will disable zone area detection. Detection mode is used to detect only targets in the specified area, while Filter mode can be used to exclude an area from detection. All options from Select.

Example configuration:

Here is the complete example configuration for LD2450 Sensor.

esphome:
  name: ld2540-radar
  friendly_name: ld2540-radar

esp32:
  board: wemos_d1_mini32

logger:

api:

ota:
  - platform: esphome

wifi:
  ap:

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

ld2450:
  id: ld2450_radar
  uart_id: uart_ld2450
  throttle: 1000ms

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

See Also