On this page (14 sections)
- Overview: Why I Built This
- Why mmWave Radar?
- Hardware and Software
- Wiring the Boards
- Configuring ESPHome
- What Else the Full YAML Exposes
- Compiling and Flashing
- Connecting to Home Assistant & Network Troubleshooting
- Fixing “Entities Unavailable” Across Subnets
- Closet Lighting Automation in Home Assistant
- Reference Specifications (HLK-LD2410B Datasheet)
- Lessons Learned
- References
- Get the Configuration & Explore More Builds
Project Snapshot
- Project Name: Presence Sensor (
xiao-presence)- Category: Smart Home / DIY Hardware Build
- Core Hardware: Seeed Studio XIAO ESP32-C3 + HI-LINK HLK-LD2410B (24 GHz mmWave Radar)
- Enclosure: Custom 3D-printed enclosure
- Firmware: ESPHome (ESP-IDF framework)
- Smart Home Platform: Home Assistant (Native Encrypted API)
- Controlled Lighting: Closet LED strip lights connected to a Kasa smart switch
- Status: Complete & running reliably
Overview: Why I Built This
Standard motion sensors work fine when you walk past them, but they fall short in a room like an office where you spend time sitting at a desk or standing still, turning the lights off while you are still there.
To bring reliable, hands-free lighting into my smart home, I built a local Presence Sensor using a Seeed Studio XIAO ESP32-C3 and a HI-LINK HLK-LD2410B millimeter-wave (mmWave) radar sensor flashed with ESPHome. Housed in a 3D-printed enclosure and connected to Home Assistant, the sensor now automatically turns on the LED strip lights in my closet through my existing Kasa smart switch whenever I’m in the room, and turns them off 30 seconds after occupancy clears.
I originally prototyped this build on an ESP32-C3 SuperMini, where everything worked on the workbench but struggled to keep a reliable Wi-Fi connection at the final mounting location. Switching to the Seeed Studio XIAO ESP32-C3 for its better antenna solved the connectivity problem, and the finished build now runs reliably day to day.
Why mmWave Radar?
The HLK-LD2410B uses 24 GHz FMCW (Frequency-Modulated Continuous Wave) radar designed to detect moving, micro-moving, and stationary human targets, not just big arm-waving motion.
In this build, each piece has a clear job:
- HLK-LD2410B handles presence detection and distance/energy measurements.
- Seeed Studio XIAO ESP32-C3 reads those measurements over a wired UART serial connection and publishes them over Wi-Fi via ESPHome’s encrypted native API.
- Home Assistant links the sensor’s
Occupancyentity to my existing Kasa smart switch to control the closet LED strip lights locally.
Hardware and Software
| Component | Role |
|---|---|
| Seeed Studio XIAO ESP32-C3 | Runs ESPHome (ESP-IDF) and provides reliable Wi-Fi connectivity with its antenna |
| HI-LINK HLK-LD2410B | 24 GHz mmWave radar module for moving & stationary presence detection |
| 3D-printed enclosure | Houses the XIAO ESP32-C3 and LD2410B cleanly |
| USB-C cable & 5 V USB power supply | Powers the sensor assembly (a data-capable cable is used for initial flashing) |
| Four connecting wires | Carry 5 V power, ground, and UART TX/RX between the boards |
| Kasa smart switch | Switches power to the closet LED strip lights via Home Assistant |
| ESPHome Device Builder | Compiles the firmware configuration |
| ESPHome Web | Flashes the initial compiled .bin over USB from the browser |
| Home Assistant | Receives occupancy/radar entities and runs the closet lighting automation |
Because the closet LED strip lights are already controlled through my Kasa smart switch, the presence sensor itself only needs low-voltage 5 V USB power and four wires between the two boards.
Wiring the Boards
The HLK-LD2410B communicates with the Seeed Studio XIAO ESP32-C3 over UART at 256000 baud. On the XIAO ESP32-C3, I wired the radar’s transmit pin to D2 (GPIO4) and its receive pin to D3 (GPIO5):
| HLK-LD2410B Pin | Function | Seeed Studio XIAO ESP32-C3 Connection |
|---|---|---|
VCC / 5V | 5 V DC Power Input (> 200 mA) | 5V (USB-powered 5 V pin) |
GND | Ground | GND |
TX | Serial Transmit (3.3 V logic) | D2 / GPIO4 (ESP32 rx_pin) |
RX | Serial Receive (3.3 V logic) | D3 / GPIO5 (ESP32 tx_pin) |
OUT | Digital Presence Output | Unconnected |
Wiring notes:
OUTpin unused: Because ESPHome reads full serial reports over UART, the digitalOUTpin is unnecessary, and UART exposes distance measurements, per-gate thresholds, and engineering mode directly in Home Assistant.- Power safety: The board is powered over USB-C, feeding the radar from the XIAO’s USB-powered
5Vpin. Disconnect power before wiring, verify your board supplies ~5 V between5VandGNDunder USB power, and keep the 5 V line away from3V3and GPIO pins.
Configuring ESPHome
The firmware runs on the esp32c3 variant using the ESP-IDF framework. Logging uses USB_SERIAL_JTAG, leaving the hardware UART dedicated to the HLK-LD2410B at 256000 baud (8N1). Wi-Fi power_save_mode: none keeps the connection responsive, and a fallback setup AP with captive_portal is included for recovery.
Below is a shortened excerpt of my xiao-presence.yaml covering connectivity, UART setup, occupancy filters, and core radar measurements:
esphome:
name: xiao-presence
friendly_name: XIAO Presence
esp32:
variant: esp32c3
framework:
type: esp-idf
logger:
hardware_uart: USB_SERIAL_JTAG
level: INFO
api:
encryption:
key: !secret api_encryption_key
ota:
- platform: esphome
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
power_save_mode: none
ap:
ssid: "XIAO Presence Setup"
password: !secret fallback_ap_password
captive_portal:
uart:
id: radar_uart
rx_pin: GPIO4 # XIAO D2 <- LD2410B TX
tx_pin: GPIO5 # XIAO D3 -> LD2410B RX
baud_rate: 256000
parity: NONE
stop_bits: 1
ld2410:
id: room_radar
uart_id: radar_uart
binary_sensor:
- platform: status
name: Device Status
entity_category: diagnostic
- platform: ld2410
ld2410_id: room_radar
has_target:
name: Occupancy
id: room_occupancy
device_class: occupancy
filters:
- delayed_on: 300ms
- delayed_off: 1s
has_moving_target:
name: Moving Target
has_still_target:
name: Stationary Target
sensor:
- platform: wifi_signal
name: WiFi Signal
update_interval: 60s
entity_category: diagnostic
- platform: uptime
name: Uptime
update_interval: 60s
entity_category: diagnostic
- platform: ld2410
ld2410_id: room_radar
moving_distance:
name: Moving Target Distance
still_distance:
name: Stationary Target Distance
detection_distance:
name: Detection Distance
moving_energy:
name: Moving Target Energy
still_energy:
name: Stationary Target Energy
Credentials stay out of the main config in ESPHome’s secrets.yaml (using a generated 32-byte base64 ESPHome API encryption key rather than an arbitrary password):
wifi_ssid: "YOUR_2_4_GHZ_WIFI_SSID"
wifi_password: "YOUR_WIFI_PASSWORD"
api_encryption_key: "YOUR_GENERATED_ESPHOME_API_KEY"
ota_password: "YOUR_OTA_PASSWORD"
fallback_ap_password: "YOUR_FALLBACK_AP_PASSWORD"
What Else the Full YAML Exposes
The full sanitized xiao-presence.yaml in my GitHub repository also exposes radar tuning and diagnostics right inside Home Assistant:
- Per-gate controls (Gates 0-8): Moving and stationary sensitivity thresholds for every distance gate, plus live per-gate moving and stationary energy readings when Radar Engineering Mode is enabled.
- Range & timeout controls:
Radar Clear Timeout,Maximum Moving Distance Gate, andMaximum Stationary Distance Gate. - Diagnostics & maintenance:
IP Address,Connected WiFi,Radar Firmware Version,WiFi Signal,Uptime, plusRestart,Restart Radar, andRefresh Radar Settingsbuttons.
On the Occupancy binary sensor, delayed_on: 300ms filters out brief spikes before reporting occupied, while delayed_off: 1s requires a full second of clear state before reporting unoccupied. Those short debounce filters stay separate from both the radar’s internal clear timeout and the Home Assistant lighting wait time.
Compiling and Flashing
- Create the device in ESPHome Device Builder and compile the YAML configuration into an installation
.binfile. - With Device Builder running on the server and the XIAO ESP32-C3 plugged into my computer with a USB-C data cable, download the compiled
.binand flash it using ESPHome Web in Chrome or Edge. - If a board needs help entering download mode, hold BOOT, press and release RESET, then release BOOT before flashing.
- Reset or reconnect USB after flashing so the firmware boots and connects to Wi-Fi. From that point on, future configuration updates can be pushed over the network via OTA.
Connecting to Home Assistant & Network Troubleshooting
The sensor connects to my IoT Wi-Fi network and is added in Home Assistant via Settings → Devices & services → ESPHome, using either discovery or the sensor’s IP address and API encryption key.
Fixing “Entities Unavailable” Across Subnets
During initial setup, I ran into a common segmented-network issue: the device appeared in Home Assistant with an IP address, yet all of its entities showed Unavailable. Discovery or having an IP address doesn’t prove Home Assistant can reach the live ESPHome API.
Because my Home Assistant host and IoT sensor sit on separate subnets, Home Assistant needed permission to initiate TCP port 6053 connections (ESPHome’s default native API port) to the sensor through my UniFi firewall, with return traffic permitted:
| Firewall Rule Field | Value |
|---|---|
| Source | Home Assistant host |
| Destination | Presence sensor |
| Protocol | TCP |
| Destination Port | 6053 |
| Action | Allow |
A quick way to confirm TCP reachability from the Home Assistant network before digging into ESPHome logs is:
python3 -c 'import socket; socket.create_connection(("SENSOR_IP", 6053), 5).close(); print("API reachable")'
(Replace SENSOR_IP with the sensor’s address. This verifies the network path; Home Assistant still needs the matching API encryption key to finish pairing.)
Once that firewall rule was in place, every occupancy and radar entity came online immediately.
Closet Lighting Automation in Home Assistant
Setting up the automation itself was refreshingly simple. I used Home Assistant’s built-in Motion-activated Light blueprint rather than writing custom YAML from scratch:
- Blueprint:
Motion-activated Light - Motion Sensor:
Occupancy(from the XIAO presence sensor in my office) - Light:
Closet lights(closet LED strip lights powered by my Kasa smart switch) - Wait time: 30 seconds (time to leave the lights on after occupancy clears)
Because the mmWave radar continuously maintains the Occupancy state while I am in the room, even when sitting still, a short 30-second wait time works cleanly without the lights shutting off on me prematurely.
Reference Specifications (HLK-LD2410B Datasheet)
Note: The figures below are Hi-Link’s published specifications for the HLK-LD2410B module itself, not measured performance inside my specific room.
- Operating Frequency: 24.000 to 24.250 GHz (24 GHz ISM band, FMCW)
- Detection Capability: Moving, micro-moving, and stationary human presence
- Rated Detection Range: 0.75 m to 6 m (configurable across distance gates)
- Rated Field of View: ±60°
- Power Supply: 5 V DC (> 200 mA supply capacity; ~79 mA average operating current)
- Interfaces: 3.3 V UART (default 256000 bps), 3.3 V GPIO
OUT, built-in BLE - Dimensions: 7 mm × 35 mm (1.27 mm pin pitch)
Lessons Learned
The biggest takeaway from this build is that a smart home presence sensor has three separate links to validate end to end:
- Radar → Microcontroller: Clean 5 V power and crossed UART TX/RX at 256000 baud.
- Microcontroller → Wi-Fi: Real-world signal strength at the actual mounting spot matters. Upgrading from the ESP32-C3 SuperMini to the Seeed Studio XIAO ESP32-C3 with its better antenna made the difference between spotty drops and rock-solid reliability.
- Home Assistant → Device API: On segmented IoT networks, make sure TCP port
6053is open from Home Assistant to the sensor.
With the 3D-printed enclosure fitting on the first try and Home Assistant’s built-in blueprint handling the Kasa switch automation cleanly, the finished sensor has become a reliable, hands-free part of my daily smart home setup.
References
- ESPHome LD2410 Component
- ESPHome Native API & Encryption
- ESPHome Web
- Home Assistant ESPHome Integration
Get the Configuration & Explore More Builds
Want to build your own? Grab the full sanitized xiao-presence.yaml and secrets.example.yaml on GitHub: View the Presence Sensor Config on GitHub.