Smart home

mmWave LD2410 presence sensor ESPHome

Detect presence even when still with LD2410C, ESP32-C6 and ESPHome: UART wiring, YAML, range and Home Assistant. Parts list, GPIO wiring, ESPHome YAML and

Updated · Emmanuel SAUVAGE

  • LevelIntermediate
  • Time1–2 h
  • Budgetabout £15–35 depending on the seller

Rough estimate, check with your seller: prices vary by shop and period.

Project goal

You will build a presence detector that stays “occupied” as long as someone is in the room, even if they sit without moving. The LD2410C radar, a small sensor that emits millimetre waves (“mmWave”) and measures both movement and stillness, is wired to an ESP32, a small electronic board with Wi-Fi. The board passes the presence, the distances and the strength of the detected signal to Home Assistant, the software that gathers your connected devices.

Why build it

A classic infrared detector, known as a PIR, only sees movement: it turns the light off while you read or work without moving. The mmWave radar avoids this flaw, which makes it very useful in an office, a bathroom, a bedroom or a toilet. It also lets you switch off the heating in a room that is really empty, instead of relying on a timetable.

Useful terms for this project: ESP32 (small Wi-Fi board) · ESPHome (prepares the board’s program) · GPIO (the board’s pins) · OTA (update without a USB cable)

Prerequisites

  • Home Assistant with ESPHome and a 5 V supply near the install spot.
  • An LD2410C (or LD2410B) module: the radar board runs on 5 V while its serial link stays 3.3 V, compatible with the ESP32.
  • Knowing TX from RX: the radar’s TX goes to the ESP32’s RX, and vice versa.

Diagrams

Wiring diagram : mmWave presence sensor (LD2410)
Wiring diagram : mmWave presence sensor (LD2410)5V → LD2410C radar 5V; GND → LD2410C radar GND; GPIO19 (RX) → LD2410C radar TX; GPIO20 (TX) → LD2410C radar RXESP32-C6 DevKitC-1LD2410C radar5V5VGNDGNDGPIO19 (RX)TXGPIO20 (TX)RXPowerGround (GND)Data or signal
Principle diagram : mmWave presence sensor (LD2410)
Principle diagram : mmWave presence sensor (LD2410)LD2410C radar → ESP32-C6 + ESPHome → Home AssistantLD2410C radar24 GHz radar: motion and stillnessSends measurements over serial (UART)UART 256000 baudESP32-C6 + ESPHomeDecodes distance, energy, presence2.4 GHz Wi-Fi + encrypted APIHome Assistant“Presence” entity and range settingsSwitches lights, cuts heating

Parts list

This ESP32 board is the base for every project in the series. ESPHome also works with other ESP32 boards: the board-choice guide helps you compare them. Which ESP32 board to choose?

ESP32-C6-DevKitC-1

Suggested board

ESP32-C6-DevKitC-1

check with the seller
  • Wi-Fi 6, Bluetooth 5, Zigbee and Thread (at hardware level)
  • Supported by ESPHome (ESP-IDF framework)
  • USB-C for flashing and power

Watch-outs

  • 2.4 GHz Wi-Fi only
  • Use a USB cable that carries data

Main components

ItemQuantityRole and precautions
ESP32-C6-DevKitC-11Control board (see the box above).
HLK-LD2410C radar module (24 GHz)1Ships with a small fine-pitch connector: plan an adapter cable or pin headers to solder. Powered at 5 V. Main component: search for « HLK-LD2410C 24GHz mmWave presence sensor » at your seller (affiliate link, check price and availability).

Small parts

ItemQuantityRole and precautions
USB-C data cable1For flashing and power. Charge-only cables do not carry data.
USB 5 V power supply (CE/UKCA-marked charger)1At least 1 A for the board alone; more if peripherals draw power from it.
Dupont jumper wires (male-female and female-female)1One mixed pack covers every prototype.
Breadboard1To test without soldering; replace with a soldered build if you need it permanent.
Vented plastic or 3D-printed enclosure1Protects the board; leave a cable gland and vents if the sensor measures air.

Amazon links are affiliate links: the site may earn a commission at no extra cost to you.

Step-by-step build

Step 1. Prepare ESPHome and create the device

  1. In Home Assistant, open the ESPHome Device Builder add-on (see the tutorial “Install ESPHome in Home Assistant (Device Builder)”). ESPHome is the software that turns a simple settings file into the program for your ESP32 board, without you having to write any code.
  2. Open “Secrets” (top right): this file keeps your passwords apart, so you can share your configurations without revealing them. Check that wifi_ssid (the name of your Wi-Fi network), wifi_password, api_encryption_key (the key that encrypts the link with Home Assistant), ota_password (for updates without a cable) and ap_password (for the board’s fallback Wi-Fi network) exist, and add any missing line. A valid API key is a long 32-byte string encoded in base64, which you can generate with “openssl rand -base64 32”.
  3. Click “New device”, name it “presence-ld2410”, pick ESP32-C6, skip the flash for now, then replace the file content with the YAML from this page (“Edit”). YAML is a configuration file written in plain text: it describes, line by line, what the board must do.

What you should see: The file opens in the editor with syntax highlighting and no red underline.

Check: The “Validate” action (⋮ menu) answers “Configuration is valid”.

Step 2. Wire the radar over serial

  1. Wire the radar with the USB power unplugged. The radar talks to the board through a serial link, that is two wires that each carry data in one direction, called TX (transmit) and RX (receive). First connect the radar’s 5V to the 5V pin of the board and the radar’s GND to a GND pin.
  2. Then cross the data wires, like two people talking to each other: the radar’s TX goes to GPIO19, the board’s receive pin (RX), and the radar’s RX goes to GPIO20, the board’s transmit pin (TX). GPIO refers to the metal pins lined up along the edge of the board.
  3. Leave the OUT pin unconnected: it is not used here, presence comes over the serial link.

What you should see: Nothing blinks on the module when you plug it in: the radar is silent until it is powered.

Check: TX and RX are not on the same side: the TX→RX wire is crossed.

Step 3. Flash the board and add it to Home Assistant

  1. Connect the board to your computer with the USB-C data cable: “flashing” means writing the program into the board’s memory, and this first write must be done over a cable. The board can already be wired or sitting on the breadboard, but any external peripheral with its own power supply must stay switched off.
  2. In ESPHome click “Install”, then “Plug into this computer” (Chrome or Edge over HTTPS) or “Manual download” and upload the file with ESPHome Web (web.esphome.io). If the port is missing, follow the flashing tutorial.
  3. After the reboot open Settings → Devices & services: the ESPHome device is discovered; click “Configure” and paste the API encryption key.

What you should see: The “Logs” show the Wi-Fi connection and then “Successfully connected to Home Assistant”.

Check: The device appears under Devices & services → ESPHome with its entities; later updates need no cable and go over Wi-Fi (this is OTA, “Over The Air”).

Step 4. Set the range and hold time

  1. In Home Assistant, open the ESPHome device to find the radar settings: the entities “Max moving gate” (maximum range for movement), “Max still gate” (maximum range for stillness) and “Hold time” (how long presence is kept) appear.
  2. Each “gate” is about 0.75 m. Lower them so the neighbouring corridor is not detected.
  3. Set “Hold time” to 10–30 s for a light, longer for heating.

What you should see: When you leave the room, “Presence” stays on until the delay ends, then turns off.

Check: Sit still for 2 minutes: presence remains detected (“Still energy” > 0).

Step 5. Choose the position and disable Bluetooth

  1. Fix the radar facing the area to cover, away from fans, moving curtains and air conditioners: these objects create movement that the radar wrongly reads as presence.
  2. Avoid putting it behind a metal plate: metal blocks the waves.
  3. Once tuned, switch “LD2410 Bluetooth” off: the default password is public.

What you should see: No false detection for 24 hours in an empty room.

Check: Test with doors open: the radar passes through some light partitions, so you may need a shorter range.

ESPHome code (YAML)

YAML is a configuration file written in plain text: it tells ESPHome what the board must do. Paste this one into ESPHome after creating the device. It targets an ESP32-C6 board; values to personalise are marked with “CHANGE” comments.

esphome:
  name: presence-ld2410
  friendly_name: mmWave presence

esp32:
  board: esp32-c6-devkitc-1   # XIAO ESP32C6: use board: seeed_xiao_esp32c6
  framework:
    type: esp-idf             # required for ESP32-C6

logger:                       # serial logs, also visible over Wi-Fi

api:
  encryption:
    key: !secret api_encryption_key

ota:
  - platform: esphome
    password: !secret ota_password

wifi:
  ssid: !secret wifi_ssid       # 2.4 GHz network only
  password: !secret wifi_password
  ap:                           # fallback hotspot if the Wi-Fi is unreachable
    ssid: "presence-ld2410 fallback"
    password: !secret ap_password

captive_portal:

uart:
  id: ld2410_uart
  tx_pin: GPIO20               # ESP32 TX -> LD2410 RX
  rx_pin: GPIO19               # ESP32 RX <- LD2410 TX
  baud_rate: 256000            # fixed by the LD2410 firmware
  data_bits: 8
  stop_bits: 1
  parity: NONE

ld2410:
  uart_id: ld2410_uart

binary_sensor:
  - platform: ld2410
    has_target:
      name: "Presence"
      device_class: occupancy
    has_moving_target:
      name: "Moving target"
    has_still_target:
      name: "Still target"

sensor:
  - platform: ld2410
    detection_distance:
      name: "Detection distance"
    moving_distance:
      name: "Moving distance"
    still_distance:
      name: "Still distance"
    moving_energy:
      name: "Moving energy"
    still_energy:
      name: "Still energy"

number:
  - platform: ld2410
    timeout:
      name: "Hold time"               # seconds the sensor keeps "presence" after the last detection
    max_move_distance_gate:
      name: "Max moving gate"         # each gate is about 0.75 m: lower it to ignore far areas
    max_still_distance_gate:
      name: "Max still gate"

switch:
  - platform: ld2410
    bluetooth:
      name: "LD2410 Bluetooth"        # CHANGE: switch it OFF once configured (public default password)

YAML comments are in English, as in the ESPHome documentation. This code has not been run on your hardware: use “Validate” before flashing and adjust pins and names.

Home Assistant integration

  • The “Presence” entity (occupancy type) is a binary sensor ready for lighting automations; “Moving target” and “Still target” refine the decision.
  • Typical automation: presence ON and low brightness → turn the light on; presence OFF for 2 minutes → turn it off. Combine with an illuminance sensor to avoid lighting in daytime.
  • For tuning, graph “Moving distance” and “Still energy” in history for a few days and adjust the ranges.

Common problems and troubleshooting

SymptomFix
No data, entities unavailableTX and RX are probably swapped, or the radar is not powered at 5 V. Check the wires; if the “Logs” show no radar data, the serial link is broken or reversed.
Presence detected all the timeA fan or curtain moves in the field. Lower the ranges, aim the radar elsewhere or mask the area.
Presence lost when I sit stillRaise the stillness sensitivity (“still” thresholds) in the manufacturer’s app or move the radar closer; still-person detection range is shorter than for motion.
UART receive errorsShorten the wires, use a stable 5 V supply (not a weak USB port) and check that the baud rate is 256000.

FAQ

mmWave or PIR: which one?

PIR is cheaper and enough for a corridor. mmWave also detects stillness, which suits living spaces, but needs tuning and a 5 V supply.

Is the radar a health risk?

It transmits at very low power (module sold for home use); check the manufacturer datasheet and the CE declaration of the module you buy for exact values.

Can the assembly run on a battery?

No: the radar draws power continuously and Wi-Fi stays on. Plan a permanent 5 V USB supply.

Related tutorials

These step-by-step guides explain the gestures common to every project in the series.

Other ESP32 projects

Sources and documentation

Cette page vous a-t-elle été utile ?

Have a question about this guide or need advice? Ask us here

Torn between two models or stuck on a build? Drop us a line and we will get back to you by email.