LW IT Solutions logo LW IT Solutions logo LW IT Solutions
« Blog Overview /Smart Home/Tutorials / Tutorial: Setting Up LD2450 Radar Zones in...
Read this article in other languages:

Tutorial: Setting Up LD2450 Radar Zones in ESPHome and Home Assistant

Tutorial: Setting Up LD2450 Radar Zones in ESPHome and Home Assistant

Management Summary

A radar sensor can distinguish activity near a desk from activity at a doorway, allowing home lighting to respond to specific parts of a room. The LD2450 follows up to three detected objects and supplies their positions to Home Assistant through ESPHome. The article explains how room zones turn those positions into useful automation. These are detected objects, not a dependable headcount, and a delay before switching off can bridge short gaps without ensuring detection of a completely still person.

Contents
  1. Hardware, coordinates and version
  2. A valid rectangular-zone configuration
  3. Measuring and saving the rectangle
  4. Hold time and automations
  5. Room tests and common limitations
  6. Frequently asked questions
  7. Sources

The LD2450 reports the positions of up to three radar targets: objects tracked from reflected radar signals. Rectangular zones can separate a desk from a doorway when the targets are reliably detected. A target is not a verified person, and a stationary person can disappear from tracking. Zone-based lighting therefore needs measurements and an appropriate hold time.

Illustrative rectangles in sensor coordinates. Zone 1 includes the example 200 mm margin; parts outside actual coverage remain undetectable.
Illustrative rectangles in sensor coordinates. Zone 1 includes the example 200 mm margin; parts outside actual coverage remain undetectable.

Hardware, coordinates and version

The manufacturer specifies 24 GHz, a maximum detection distance of 6 m, an azimuth angle of ±60° and a pitch angle of ±35°, with wall mounting. These are nominal specifications, not a guaranteed detection boundary in every room. Metal, furniture, mounting angle and reflections can alter the results.

The coordinate origin is the radar. X describes lateral position and Y the forward direction in the sensor frame, in millimetres. A short left/right walking test establishes the sign for the actual mounting orientation. Rotating or tilting the board changes the measurement geometry; a 90° rotation is not generally equivalent to simply swapping the floor-plan axes. Moving the sensor requires rechecking the zone boundaries.

The example below targets ESPHome 2026.10.0 and a classic ESP32 board with GPIO16 and GPIO17 available. ESPHome requires LD2450 firmware V2.02.23090617 or later. The UART uses 256000 baud, no parity and one stop bit. ESP TX connects to radar RX, ESP RX to radar TX, with a common ground. Power supply and signal levels must match the module and board specifications; the example pin assignment is not universal.

A valid rectangular-zone configuration

This complete example contains placeholder Wi-Fi credentials. Board selection, credentials and the Home Assistant API security settings require adaptation to the installation. Existing configuration sections are merged rather than duplicated. No firmware was flashed during the article check.

YAML
esphome:
  name: radar-zone-demo
esp32:
  board: esp32dev
  framework:
    type: esp-idf
logger:
  baud_rate: 0
api:
wifi:
  ssid: "ExampleNetwork"
  password: "ExamplePassword123"
uart:
  id: uart_radar
  tx_pin: GPIO17
  rx_pin: GPIO16
  baud_rate: 256000
  parity: NONE
  stop_bits: 1
ld2450:
  id: radar
  uart_id: uart_radar
binary_sensor:
  - platform: ld2450
    ld2450_id: radar
    has_target:
      name: "Overall presence"
  - platform: template
    id: desk_occupied
    name: "Desk occupied"
    device_class: occupancy
    lambda: |-
      if (!id(desk_count).has_state() || isnan(id(desk_count).state)) {
        return {};
      }
      return id(desk_count).state > 0;
    filters:
      - delayed_off: 20s
sensor:
  - platform: ld2450
    ld2450_id: radar
    target_1:
      x:
        name: "Target 1 X"
      y:
        name: "Target 1 Y"
    zone_1:
      target_count:
        id: desk_count
        name: "Desk target count"
number:
  - platform: ld2450
    ld2450_id: radar
    presence_timeout:
      name: "Overall presence timeout"
    zone_1:
      x1:
        name: "Zone 1 X1"
      y1:
        name: "Zone 1 Y1"
      x2:
        name: "Zone 1 X2"
      y2:
        name: "Zone 1 Y2"
select:
  - platform: ld2450
    ld2450_id: radar
    zone_type:
      name: "Hardware zone mode"
switch:
  - platform: ld2450
    ld2450_id: radar
    multi_target:
      name: "Multi-target tracking"

The native rectangular-zone settings are named x1, y1, x2 and y2. The component has no binary_sensor.zone_1.occupancy option in the tested version. Instead, a template calculates an occupied/unoccupied state from the zone’s target count. At least one detected target means occupied. Missing or invalid initial counts do not become a false measured zero.

The component-level throttle option has been removed. Numeric LD2450 entities already have default filters that limit ordinary updates to roughly one-second intervals while prioritizing particular changes. Custom filters replace the defaults. An update is not automatically a new Home Assistant state, and database growth cannot be predicted as a fixed number of megabytes per sensor.

Measuring and saving the rectangle

For an isolated measurement, one moving target is easier to identify. Target slots are not persistent person identities. Measurements at the corners and along the edges, while standing and sitting, reveal the usable boundary. With several targets, a display of all three slots is useful; the example exposes only the first slot for initial calibration.

Example corner readings, x / y in mm:
380 / 840     1760 / 810
420 / 2310    1780 / 2360

Measured bounds: x 380..1780, y 810..2360
With 200 mm on each side:
x1 = 180, x2 = 1980, y1 = 610, y2 = 2560

The 200 mm margin is an example, not a universal accuracy specification. A larger rectangle can include a nearby walkway. An entity is an individually addressable value or state in Home Assistant. The four number entities are adjustable values that set the radar’s hardware-zone coordinates; the values are not automatically written back into the YAML file. A separate record of coordinates, mounting position and zone mode makes replacement and recovery reproducible.

The hardware zone mode is independent of the template hold time: Detection limits reported targets to configured detection areas, Filter excludes configured areas, and Disabled disables hardware area filtering. These modes can alter all downstream target data. In the tested ESPHome implementation, zone counts are calculated from received coordinates and the configured rectangles; an excluded target cannot be recovered by a template. Calibration therefore includes the actual mode and all intended zones.

Hold time and automations

The example’s delayed_off: 20s postpones a change to unoccupied until the template has continuously reported false for 20 seconds. Renewed occupancy cancels the pending switch-off. This reduces short detection gaps but does not guarantee detection of a person sitting still for longer.

presence_timeout belongs to ESPHome’s overall presence binary states, not to the radar’s target-count reports. It does not add another five seconds to this template based on desk_count. Reporting filters, automation delays and the last actual detection can add other latency; an exact 25-second switch-off after a person leaves is not guaranteed.

A Home Assistant state trigger on the resulting occupancy entity is convenient. A numeric-state trigger is also valid, but fires on crossing a threshold, not on every coordinate update. Behavior after restart, unavailable entities and loss of the UART connection needs explicit testing. The template keeps the prior state when no valid count is available; it is not a communication watchdog, and a stale count requires separate availability monitoring.

Room tests and common limitations

The acceptance test includes entering, leaving, sitting still, walking just outside the zone, movement in an adjacent room, fans and curtains, and operation with another radar switched on and off. Wall penetration and interference depend on construction and installation; neither is an inevitable result. Phantom targets can move as well as remain still. A fixed coordinate alone does not prove a phantom, and a minimum-speed condition can reject the seated person that the automation needs to detect.

Frequently asked questions

Is Y equal to the slant range?

No general identity applies. The geometric distance √(x²+y²+h²) is a slant range for a known three-dimensional point; it is not a documented conversion formula for the module’s reported Y coordinate. Height, tilt and posture therefore need empirical checks instead of a promised correction based only on mounting height.

Can the zone count count people?

Only as an approximate count of detected targets, capped by the module’s three-target capacity. Occlusion, stationary targets, slot changes and reflections prevent a reliable people count.

Are diagnostic coordinates useful after calibration?

Yes, for later mounting or furniture changes and fault investigation. Excluding these entities from Home Assistant Recorder can reduce history storage while retaining live readings. Disabled entities need re-enabling before renewed measurement.

Sources

Lukas Wojcik

Lukas Wojcik

Systems architect and technology enthusiast specializing in scalable tracking solutions, GMP Stack (GA4 & GTM), and robust backend architectures. Advocate for clean code and privacy-first design.

Get in touch

A question or an idea for a web project? Tell me a little about it. This form uses reCAPTCHA to protect against spam.

Write a comment

Experience with other devices or integrations and questions about the setup are welcome here.

The email address is not published. Required fields are marked with an asterisk.