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
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?
Suggested board
ESP32-C6-DevKitC-1
- 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
| Item | Quantity | Role and precautions |
|---|---|---|
| ESP32-C6-DevKitC-1 | 1 | Control board (see the box above). |
| HLK-LD2410C radar module (24 GHz) | 1 | Ships 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
| Item | Quantity | Role and precautions |
|---|---|---|
| USB-C data cable | 1 | For flashing and power. Charge-only cables do not carry data. |
| USB 5 V power supply (CE/UKCA-marked charger) | 1 | At least 1 A for the board alone; more if peripherals draw power from it. |
| Dupont jumper wires (male-female and female-female) | 1 | One mixed pack covers every prototype. |
| Breadboard | 1 | To test without soldering; replace with a soldered build if you need it permanent. |
| Vented plastic or 3D-printed enclosure | 1 | Protects 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
- 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.
- 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”.
- 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
- 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.
- 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.
- 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
- 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.
- 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.
- 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
- 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.
- Each “gate” is about 0.75 m. Lower them so the neighbouring corridor is not detected.
- 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
- 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.
- Avoid putting it behind a metal plate: metal blocks the waves.
- 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
| Symptom | Fix |
|---|---|
| No data, entities unavailable | TX 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 time | A fan or curtain moves in the field. Lower the ranges, aim the radar elsewhere or mask the area. |
| Presence lost when I sit still | Raise 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 errors | Shorten 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.
- Install ESPHome in Home Assistant (Device Builder)Install the add-on, prepare your passwords (secrets) and create the first device
- Flash an ESP32 with ESPHome (USB, drivers, boot mode)First upload over USB, CP210x and CH340 drivers, boot mode
- ESP32 wiring basics: GPIO, 3.3 V and pull-upsWhich pins to avoid, 3.3 V versus 5 V, pull-up resistors and common ground
- ESPHome OTA updates: flash without a cableUpdate the board without a cable, OTA password and recovery if something goes wrong
