A corner presence box: two radars and a PIR on one board
Two radars and a PIR plugged into one small board in a printed corner box, plus temperature, humidity and light. Only a real person turns the lights on.

- Difficulty
- Advanced
- Parts cost
- One rev A board (factory-assembled), two radar modules, a PIR, a XIAO ESP32-C5 and about 72 g of PLA per box
- Build time
- About 5 hours of printing, then an hour or two soldering leads and plugging in
- Skills
- Soldering, ESPHome, 3D printing, Home Assistant
The problem
I don’t need to know where people are in a room. I want three things from a presence sensor: no lights coming on for nobody, no lights going off on someone sitting still, and the lights off reliably once the room really is empty.
One radar on its own can’t tell a person from a curtain moving in a breeze. Two of the same radar don’t help much either, because the same curtain fools both. What does help is sensors that fail in different ways. So this box carries three:
- a PIR (passive infrared), which only fires for a warm body moving;
- a 24 GHz radar (HLK-LD2412), which sees people moving or sitting still, out to several metres;
- a 60 GHz radar (HLK-LD6002B), which picks up very small movement, like breathing, and reports where each person is.
The two radars are on different bands, so they can’t interfere with each other. The box also reads the room’s temperature, humidity and light level, so one box per room replaces a handful of separate sensors.
This is the rev A build. The first boxes were hand-wired: 22 wires, a ground bus and a colour code that meant different things on different modules. Rev A puts everything on one small board. The three presence sensors plug in, the temperature and light sensors are on little tabs that snap off the same board, and the XIAO’s own USB-C port comes straight out of the case.
How it works
All the room logic runs on the ESP32, not in Home Assistant, so a Home Assistant restart can never lose a timer. Once a second, and the moment any sensor changes, it looks at all three:
- Empty to occupied: any two of the three must agree within 5 seconds of each other. One sensor on its own can never switch the lights on, whether it’s a radar or the PIR.
- Staying occupied: any of the three. Either radar keeps the room occupied while you sit still, read or sleep, long after the PIR has stopped seeing you.
- Occupied to empty: only when all three have been clear for the hold time. Mine is 5 minutes, and it’s a number you can change from Home Assistant.
Why two of three and not the PIR alone? A PIR sees through any doorway in its view, so on its own it could switch the room on for someone walking past outside. The 24 GHz radar usually fires in the same second as the PIR, so the second “yes” costs almost nothing: across ten walk-ins, the room came on at most 3 seconds after the first sensor fired.
Home Assistant gets one Occupied sensor from the box and puts it in a group with the area’s other sensors. The lights go off 3 minutes after the whole group is clear, the same as in my presence lighting guide.
There’s a second output for an alarm, Alarm Confirmed. It only comes on when the PIR and one of the radars in the same box both saw something within 10 seconds of each other.
Two start-up rules keep a reboot from causing trouble. The PIR is ignored for its first 30 seconds (it needs that long to settle). And for the first 90 seconds a radar on its own is allowed to set Occupied, so a reboot in the middle of the night doesn’t turn the lights off on someone asleep.
What you need
Per box:
- One rev A board with its two snap-off tabs. I had five made by JLCPCB with the small parts fitted at the factory (the board files are below).
- Seeed XIAO ESP32-C5, with its stick-on antenna. A XIAO ESP32-C3 fits the same board; only the firmware’s pin numbers change.
- HLK-LD2412 24 GHz radar module (5 V).
- HLK-LD6002B 60 GHz radar module (3.3 V). Not the LD6002 (a breathing monitor) or the LD6002C (fall detection).
- Panasonic EKMC1603111 PIR. It’s the “slight motion” model.
- JST-PH 2.0 mm pigtails: one 4-pin (24 GHz radar), one 5-pin (60 GHz radar) and one 3-pin (PIR).
- One Qwiic cable (JST-SH 4-pin), cut in half for the two sensor tabs.
- 2 × 0.1 µF ceramic capacitors: one at the PIR’s legs, one at the 60 GHz radar’s power pads.
- 2.54 mm male pin headers for the XIAO. Not sockets: they lift the USB-C port above the case opening.
- 2 × M3 × 8 self-tapping screws to join the halves.
- Double-sided mounting tape.
- A USB-C cable and a decent 2 A USB power supply.
- About 72 g of PLA for the case.
The board

The factory fits everything small. That’s the part that made hand-wiring slow:
- The 60 GHz radar gets its own 3.3 V regulator (an AMS1117-3.3) with 470 µF + 0.1 µF at its plug. It never runs off the XIAO’s 3V3 pin.
- A switch on the 60 GHz radar’s power (an AO3401A MOSFET). The LD6002B has no reset pin and no reset command, so if it ever hangs, the only cure is cutting its power. Now Home Assistant can do that with a button.
- 470 µF + 0.1 µF at the 24 GHz radar’s plug, a 10 kΩ pull-down on the 60 GHz radar’s P19 pin (it must be low when the radar powers up), the I²C pull-ups and a surge diode on the USB 5 V.
- The temperature and light chips (SHT40 and VEML7700) are on the two tabs, not on the board. The temperature tab sits away from the ESP’s heat, and the light tab sits behind the case’s light window.
Two XIAO footprints, one at each end, wired the same. Solder the XIAO into the end where you want the cable to come out, top or bottom. The case has a USB opening at both ends and the spare one gets a printed plug.
The pins work on both the C3 and the C5. Several of each chip’s pins have a job at power-up, and the two chips don’t agree on which ones. The board only uses pins that are safe on both:
| Signal | XIAO pin | C5 GPIO | C3 GPIO |
|---|---|---|---|
| 24 GHz radar TX → ESP | D7 | GPIO12 | GPIO20 |
| ESP → 24 GHz radar RX | D10 | GPIO10 | GPIO10 |
| 60 GHz radar TX0 → ESP | D2 | GPIO25 | GPIO4 |
| ESP → 60 GHz radar RX0 | D3 | GPIO7 | GPIO5 |
| I²C SDA (both tabs) | D4 | GPIO23 | GPIO6 |
| I²C SCL (both tabs) | D5 | GPIO24 | GPIO7 |
| PIR out | D1 | GPIO0 | GPIO3 |
| 60 GHz radar power switch | D0 | GPIO1 | GPIO2 |
| nothing | D6 |
D6 is left empty on purpose. Both chips print their start-up messages out of it before the firmware runs, and that text confuses the 60 GHz radar.
The 60 GHz radar’s power switch has a pull-up that keeps the radar off until the firmware turns it on. So the radar can’t hold any of the ESP’s start-up pins at the wrong level while it boots.
The case
It’s a two-piece case, about 10 cm tall. The back half fits into a 90° wall corner and sticks on with double-sided tape. The front half faces straight out of the corner, at 45° to each wall, and is tilted down 30° so the sensors aim at the middle of the room rather than the far wall.
The front half holds the sensors:
- The radar windows follow Hi-Link’s own numbers. A radar sees through plastic, but the thickness of the window and the gap to it matter. The LD2412 sits 12.4 mm behind a 3.8 mm window, and the LD6002B sits 2.5 mm behind a 1.5 mm window. Each radar clips into a printed carrier, so nothing presses the board against the window.
- The PIR lens pokes through the face. A PIR can’t see through plastic. It locks into a twist-in bayonet seat.
- The light tab sits behind its own small window, walled off from the rest of the box.

The back half holds the board:
- The board presses onto three pegs on one of the inner walls and clicks in. No glue, no screws.
- The temperature tab drops into two grooves in the end walls, down near the floor. It stands 4 mm off the wall with air on both sides, walled off from the rest of the box. Room air comes in through the bottom vents past the tab, and the electronics’ warm air leaves through the top.
- More vents in the floor than the hand-wired box had, so room air reaches the tab first.
- A USB-C opening at both ends. The XIAO’s own port lines up with one of them; the other gets the printed plug.
- Two snap arms at the top lock the front half on, and two M3 screws from underneath hold the bottom.

I print both halves together on one plate in PLA on an Elegoo Centauri Carbon, with supports: about 5¼ hours and 72 g.
Leads and colours
Each module gets one lead soldered to it, once. After that everything unplugs. I picked one colour rule and stuck to it, because on the hand-wired box the same colour meant power on one module and a signal on another:
- Black is every ground, red is every positive.
- Blue is a radar’s TX, yellow is a radar’s RX or the PIR’s output.
- White is the 60 GHz radar’s P19.
| Lead | Board plug | Pin 1 | Pin 2 | Pin 3 | Pin 4 | Pin 5 |
|---|---|---|---|---|---|---|
| 24 GHz radar (4-pin) | J1 5V G TX RX |
5V red | GND black | TX blue | RX yellow | |
| 60 GHz radar (5-pin) | J2 3V3 G TX0 RX0 P19 |
3V3 red | GND black | TX0 blue | RX0 yellow | P19 white |
| PIR (3-pin) | J3 V OUT G |
V red | OUT yellow | GND black | ||
| Light tab (Qwiic) | J6 → tab | GND | 3V3 | SDA | SCL | |
| Temperature tab (Qwiic) | J4 → tab | GND | 3V3 | SDA | SCL |
- TX goes to TX. The silk on the board names the radar’s own pins, so the radar’s TX wire goes to the pin marked TX. The board crosses them over to the ESP.
- The two radars’ red wires are different voltages: 5 V for the 24 GHz one, 3.3 V for the 60 GHz one. The plugs are different sizes, so they can’t be swapped.
- The PIR’s pins: GND is the pin joined to the metal can, V is opposite it, and OUT is the one in between. Keep a 0.1 µF across V and GND right at its legs.
- Put a 0.1 µF across the 60 GHz radar’s 3V3 and GND pads if there’s room. The board has its own, but one right at the radar costs nothing.
- The tabs: cut a Qwiic cable in half. Plug end into the board, bare end soldered into the tab’s four holes. The square hole is GND.
- Pin 1 is at the same end of every plug, so the black wires all sit at the same end.
Firmware and config
ESPHome 2026.8 or newer, which added the ld6002b component. I’m on 2026.10.
Each box has a short file of its own, and pulls in a file for its chip and the shared config. Here’s the lounge box:
# corner-box-lounge.yaml
substitutions:
name: corner-box-lounge
friendly_name: "Corner Box Lounge"
port: "bottom" # which end the XIAO's USB-C comes out
temp_offset: "0.0" # set once the box is in its corner (see Testing)
packages:
board: !include board_c5.yaml
base: !include corner_box_base.yaml
r60_power: !include r60_power.yaml
text_sensor:
- platform: template
name: "USB Port"
entity_category: diagnostic
lambda: return {"${port}"};
update_interval: 1h
The chip file holds the pin numbers. board_c5.yaml:
substitutions:
pin_ld2412_tx: GPIO10 # D10 -> 24 GHz radar RX
pin_ld2412_rx: GPIO12 # D7 <- 24 GHz radar TX
pin_r60_tx: GPIO7 # D3 -> 60 GHz radar RX0
pin_r60_rx: GPIO25 # D2 <- 60 GHz radar TX0
pin_sda: GPIO23 # D4
pin_scl: GPIO24 # D5
pin_pir: GPIO0 # D1
pin_r60_en: GPIO1 # D0 60 GHz radar power switch
esp32:
variant: ESP32C5
framework:
type: esp-idf
For a C3, board_c3.yaml is the same with the C3 numbers from the table above, and
board: seeed_xiao_esp32c3 and variant: esp32c3 in the esp32: block.
The 60 GHz radar’s power switch, r60_power.yaml:
switch:
- platform: gpio
id: ld6002b_power
name: "LD6002B Power"
pin:
number: ${pin_r60_en} # LOW = radar powered
inverted: true
restore_mode: ALWAYS_ON
entity_category: config
on_turn_on:
- script.execute: ld6002b_bring_up # set it up again after every power-up
on_turn_off:
- lambda: id(r60_settled) = false;
button:
- platform: template
name: "Restart 60 GHz Radar" # the only reset the LD6002B has
entity_category: config
on_press:
- switch.turn_off: ld6002b_power
- delay: 8s
- switch.turn_on: ld6002b_power
The room logic lives in two small header files next to the YAML.
corner_logic.h:
#pragma once
#include <cstdint>
namespace corner {
struct Occ {
bool occupied = false;
uint32_t last_seen_ms = 0;
uint32_t boot_ms = 0;
bool warmed = false; // PIR settled (latched, so a millis() wrap can't re-open the warm-up)
bool grace_over = false; // boot grace finished (latched for the same reason)
// when each sensor last saw someone; the *_seen flags stop a never-seen sensor's 0 counting near boot
uint32_t pir_ms = 0, r24_ms = 0, r60_ms = 0;
bool pir_seen = false, r24_seen = false, r60_seen = false;
};
constexpr uint32_t BOOT_GRACE_MS = 90000;
constexpr uint32_t AGREE_MS = 5000; // two sensors within this of each other = someone walked in
inline void occ_boot(Occ &s, bool r24, bool r60, uint32_t now_ms) {
s.boot_ms = now_ms;
s.warmed = false;
s.grace_over = false;
s.occupied = r24 || r60;
s.last_seen_ms = now_ms;
s.pir_seen = s.r24_seen = s.r60_seen = false;
}
// The PIR needs ~30 s to settle after power-up.
inline bool pir_usable(Occ &s, bool pir, uint32_t now_ms, uint32_t pir_warmup_ms = 30000) {
if (!s.warmed && now_ms - s.boot_ms >= pir_warmup_ms) s.warmed = true;
return pir && s.warmed;
}
// How many of the three sensors have seen someone within agree_ms of now.
inline int votes(const Occ &s, uint32_t now_ms, uint32_t agree_ms = AGREE_MS) {
return (s.pir_seen && now_ms - s.pir_ms <= agree_ms) + (s.r24_seen && now_ms - s.r24_ms <= agree_ms) +
(s.r60_seen && now_ms - s.r60_ms <= agree_ms);
}
// Any two of the three sensors within agree_ms turns the room on; any one keeps it on;
// all clear for hold_ms turns it off. Safe to call every second AND on every sensor change.
inline bool occ_step(Occ &s, bool pir, bool r24, bool r60, uint32_t now_ms, uint32_t hold_ms,
uint32_t pir_warmup_ms = 30000, uint32_t agree_ms = AGREE_MS) {
const bool pir_ok = pir_usable(s, pir, now_ms, pir_warmup_ms);
if (!s.grace_over && now_ms - s.boot_ms >= BOOT_GRACE_MS) s.grace_over = true;
if (pir_ok) { s.pir_ms = now_ms; s.pir_seen = true; }
if (r24) { s.r24_ms = now_ms; s.r24_seen = true; }
if (r60) { s.r60_ms = now_ms; s.r60_seen = true; }
if (!s.occupied) {
if (votes(s, now_ms, agree_ms) >= 2 || (!s.grace_over && (r24 || r60))) {
s.occupied = true;
s.last_seen_ms = now_ms;
}
return s.occupied;
}
if (pir_ok || r24 || r60) {
s.last_seen_ms = now_ms;
} else if (now_ms - s.last_seen_ms >= hold_ms) {
s.occupied = false;
}
return s.occupied;
}
// Alarm witness: the PIR and a radar in the SAME box both saw something within window_ms of now.
inline bool alarm_confirmed(bool pir_seen, uint32_t pir_ms, bool radar_seen, uint32_t radar_ms, uint32_t now_ms,
uint32_t window_ms = 10000) {
return pir_seen && radar_seen && (now_ms - pir_ms <= window_ms) && (now_ms - radar_ms <= window_ms);
}
} // namespace corner
corner_state.h (the state lives in a header because an ESPHome global of this type won’t compile):
#pragma once
#include "corner_logic.h"
namespace corner {
inline Occ box_state;
} // namespace corner
All the time maths is unsigned subtraction, so the millis() counter wrapping round after 49 days does no
harm.
The shared config, corner_box_base.yaml:
esphome:
name: ${name}
friendly_name: ${friendly_name}
includes:
- corner_logic.h
- corner_state.h
on_boot:
- priority: -90
then:
- script.execute: ld6002b_bring_up
- priority: -100
then:
- delay: 20s # give both radars time to report, then start the room logic from what they see
- lambda: |-
corner::occ_boot(corner::box_state, id(r24).has_state() && id(r24).state,
id(r60).has_state() && id(r60).state, millis());
id(logic_running) = true;
logger:
hardware_uart: USB_SERIAL_JTAG
level: INFO
api:
encryption:
key: !secret api_key
ota:
- platform: esphome
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
power_save_mode: none
globals:
- id: logic_running
type: bool
initial_value: "false"
- id: pir_latch # catches a PIR pulse shorter than the 1 s logic tick
type: bool
initial_value: "false"
- id: pir_seen
type: bool
initial_value: "false"
- id: last_pir_ms
type: uint32_t
initial_value: "0"
- id: radar_seen
type: bool
initial_value: "false"
- id: last_radar_ms
type: uint32_t
initial_value: "0"
- id: r60_settled # the 60 GHz radar has been set up since it powered on
type: bool
initial_value: "false"
uart:
- id: uart_ld2412
tx_pin: ${pin_ld2412_tx}
rx_pin: ${pin_ld2412_rx}
baud_rate: 115200
- id: uart_ld6002b
tx_pin: ${pin_r60_tx}
rx_pin: ${pin_r60_rx}
baud_rate: 115200
rx_buffer_size: 2048 # its messages are big
ld2412:
id: ld2412_radar
uart_id: uart_ld2412
ld6002b:
id: ld6002b_radar
uart_id: uart_ld6002b
i2c:
sda: ${pin_sda}
scl: ${pin_scl}
frequency: 100kHz
binary_sensor:
- platform: gpio
id: pir
name: "PIR"
device_class: motion
pin:
number: ${pin_pir}
mode:
input: true
pulldown: true # the PIR's output floats when idle
filters:
- delayed_off: 2s
on_press:
- lambda: id(pir_latch) = true;
- script.execute: logic_tick
- platform: ld2412
ld2412_id: ld2412_radar
has_target:
id: r24
name: "LD2412 Presence"
device_class: occupancy
on_state:
- script.execute: logic_tick
- platform: ld6002b
ld6002b_id: ld6002b_radar
target:
id: r60
name: "LD6002B Presence"
device_class: occupancy
on_state:
- script.execute: logic_tick
- platform: template
id: occupied
name: "Occupied"
device_class: occupancy
- platform: template
id: alarm_ok
name: "Alarm Confirmed"
device_class: motion
interval:
- interval: 1s
then:
- script.execute: logic_tick
sensor:
- platform: sht4x
temperature:
id: box_temp
name: "Temperature"
filters:
- offset: ${temp_offset}
humidity:
name: "Humidity"
filters:
# the tab reads slightly warm air, which makes humidity read low: re-state the same
# moisture at the corrected temperature
- lambda: |-
const float tr = id(box_temp).get_raw_state();
if (std::isnan(tr) || std::isnan(x)) return x;
const float tc = tr + (${temp_offset});
auto es = [](float t) { return expf(17.62f * t / (243.12f + t)); };
const float rh = x * es(tr) / es(tc);
return rh > 100.0f ? 100.0f : rh;
update_interval: 30s
- platform: veml7700
ambient_light:
name: "Illuminance"
update_interval: 30s
- platform: ld2412
ld2412_id: ld2412_radar
detection_distance:
name: "LD2412 Detection Distance"
filters: &radar_filters
- throttle: 2s
- delta: 5.0
still_energy:
name: "LD2412 Still Energy"
filters: *radar_filters
moving_energy:
name: "LD2412 Move Energy"
filters: *radar_filters
gate_0: # per-gate energies, for tuning (engineering mode only)
move_energy:
name: "Gate 0 Move Energy"
filters: *radar_filters
still_energy:
name: "Gate 0 Still Energy"
filters: *radar_filters
# ...and the same for gate_1 to gate_13
- platform: ld6002b
ld6002b_id: ld6002b_radar
target_count:
name: "LD6002B Target Count"
- platform: wifi_signal
name: "WiFi Signal"
update_interval: 60s
script:
- id: logic_tick # every second AND whenever the PIR or a radar changes
mode: queued
max_runs: 3
then:
- lambda: |-
if (!id(logic_running)) { id(pir_latch) = false; return; }
const uint32_t now = millis();
const bool pir_now = corner::pir_usable(corner::box_state, id(pir).state || id(pir_latch), now);
id(pir_latch) = false;
const bool a = id(r24).has_state() && id(r24).state;
const bool b = id(r60_settled) && id(r60).has_state() && id(r60).state;
if (pir_now) { id(pir_seen) = true; id(last_pir_ms) = now; }
if (a || b) { id(radar_seen) = true; id(last_radar_ms) = now; }
const uint32_t hold_ms = (uint32_t) (id(hold_minutes).state * 60000.0f);
const bool occ = corner::occ_step(corner::box_state, pir_now, a, b, now, hold_ms);
if (!id(occupied).has_state() || id(occupied).state != occ) id(occupied).publish_state(occ);
const bool al = corner::alarm_confirmed(id(pir_seen), id(last_pir_ms), id(radar_seen),
id(last_radar_ms), now);
if (!id(alarm_ok).has_state() || id(alarm_ok).state != al) id(alarm_ok).publish_state(al);
- id: ld6002b_bring_up
mode: restart
then:
- lambda: id(r60_settled) = false;
- delay: 8s
- switch.turn_on: ld6002b_targets # send targets
- switch.turn_off: ld6002b_points # no point cloud (big messages, not needed)
- lambda: |-
// wall or corner mount ("top" is for a ceiling)
id(ld6002b_install).make_call().set_option("side").perform();
- delay: 2s
- lambda: id(r60_settled) = true;
switch:
- platform: ld2412
ld2412_id: ld2412_radar
engineering_mode:
name: "LD2412 Engineering Mode" # on while tuning: the radar then sends every gate's energy
- platform: ld6002b
ld6002b_id: ld6002b_radar
target_display:
id: ld6002b_targets
name: "LD6002B Target Stream"
point_cloud:
id: ld6002b_points
name: "LD6002B Point Cloud"
button:
- platform: ld2412
ld2412_id: ld2412_radar
query_params:
id: radar_reread_settings
name: "Re-read Radar Settings"
entity_category: diagnostic
- platform: ld6002b
ld6002b_id: ld6002b_radar
auto_interference:
name: "LD6002B Learn Empty Room"
entity_category: config
clear_interference:
name: "LD6002B Clear Ignore Areas"
entity_category: config
- platform: restart
name: "Restart"
number:
- platform: template
id: hold_minutes
name: "Hold Minutes"
min_value: 1
max_value: 30
step: 1
initial_value: 5
restore_value: true
optimistic: true
entity_category: config
- platform: ld2412
ld2412_id: ld2412_radar
timeout:
name: "LD2412 Hold Time"
max_distance_gate:
name: "LD2412 Max Distance Gate"
min_distance_gate:
name: "LD2412 Min Distance Gate"
gate_0:
move_threshold:
name: "Gate 0 Move Threshold"
entity_category: config
still_threshold:
name: "Gate 0 Still Threshold"
entity_category: config
# ...and the same for gate_1 to gate_13
select:
- platform: ld2412
ld2412_id: ld2412_radar
distance_resolution:
name: "LD2412 Distance Resolution"
- platform: ld6002b
ld6002b_id: ld6002b_radar
installation_mode:
id: ld6002b_install
name: "LD6002B Installation Mode"
sensitivity:
name: "LD6002B Sensitivity"
When the 60 GHz radar powers on, the firmware waits 8 seconds, then switches its target stream on, turns its point cloud off and sets the installation mode to side (wall or corner). It does this every time the radar powers up, including after the Restart 60 GHz Radar button, so it never matters what the radar remembered.
In Home Assistant, add the box’s Occupied sensor to the area’s group (Settings → Devices & services → Helpers → your group → add the entity). Example group members:
binary_sensor.example_corner_box_occupied
binary_sensor.example_lounge_presence
binary_sensor.example_dining_presence


Step by step
- Print the case in PLA with supports: both halves on one plate, the two radar carriers and the USB plug.
- Snap the two tabs off the board and file the little nubs flat.
- Solder the XIAO on male pin headers, component side up, at the end you want the cable to come out. Trim the pins on the underside to 1 mm or less: the board lies against the case wall.
- Solder a lead to each module: the 4-pin to the 24 GHz radar, the 5-pin to the 60 GHz radar, the 3-pin to the PIR, with the 0.1 µF capacitors at the PIR’s legs and the 60 GHz radar’s power pads. Use the colours above.
- Make the two tab leads from the Qwiic cable, square hole = GND.
- Before plugging anything in, meter 5V to GND and 3V3 to GND on the board: neither should be shorted.
- Flash the XIAO over USB with nothing plugged in. Check it’s the chip you meant (C3 or C5).
- Fit the front half: clip each radar into its carrier and glue the carriers into their recesses, twist the PIR into its seat, and slide the light tab behind its window.
- Click the board onto its three pegs, drop the temperature tab into its grooves, stick the antenna to the case wall, and plug everything in.
- Check every sensor reports in Home Assistant: both radars, the PIR, temperature, humidity, light and USB Port.
- Close it: the front snaps on at the top and two M3 × 8 screws go in from underneath. Plug the unused USB opening.
- Stick it in the corner, top tucked up under the cornice, then tune it for the empty room (below).
Tuning
The LD2412 reports an energy level for each distance band (“gate”) and decides someone is there when a gate goes over its threshold. The thresholds that come out of the box aren’t set for your room. Here’s how I set mine:
- Turn on LD2412 Engineering Mode, then leave the room empty for a few minutes and record every gate’s moving and still energy from the Gate Energy sensors.
- Set each gate’s threshold to its empty-room peak plus 10. Never go below 25 for moving or 15 for still.
- Press Re-read Radar Settings and check the radar really holds the new numbers.
- Walk back in and check Occupied comes on, then sit still and check it holds.
Keep a note of the old values first, so you can put them back.
The 60 GHz radar has a Learn Empty Room button. With the room empty, it marks anything that still reflects or moves (a fan, a curtain) as a spot to ignore. If it keeps reporting a still “person” in one place with nobody there, that’s the fix.
Seeing what the radars see
Numbers in a list are hard to tune from, so I built a small page on my home server that draws what each box is picking up. It isn’t part of the download, but it’s how I tune mine, and the idea is easy to copy.
The trick is the room picture. I took a photo from where the box sits, at the same height and pointing the same way, with the phone on its wide (0.6×) lens and held sideways. The 60 GHz radar reports where each person is, as metres across and out from the box. The page works out where that spot lands in the photo, then draws a little figure standing there. It walks when the radar says they’re moving, and stands still when they’re not. So instead of reading x and y, you watch someone cross your own room on the screen.

To line the drawing up with the photo, the page needs a few numbers: how high the box is, how far it’s tilted down, the lens’s field of view and where the middle of the picture is. The phone saves which lens took the photo, which gives you the field of view. Then someone stands on a known spot and you nudge the numbers until the figure stands on their feet. One gotcha: the LD6002B’s left and right came out mirrored compared with the photo. One walk across the room showed it straight away.
That’s also how I found the 60 GHz radar’s odd one out in the dining room: now and then it would put a still “person” in the same spot with nobody there. It never got as far as turning anything on, because nothing else agreed with it. That’s the two-sensor rule doing its job.
Testing it
- Walk in. Two sensors agree and Occupied comes on within a second or two.
- Sit still for longer than the hold time. Occupied should stay on, held by the radars.
- Leave. Occupied goes off after the hold time, and the lights 3 minutes after that.
- Press Restart 60 GHz Radar. The 60 GHz radar drops out and is back within about 15 seconds.
- Pull the power ten times. It should boot, and every sensor report, every time.
- Set the temperature offset once the box is closed up in its corner: leave it a few hours, compare it with a
thermometer you trust, and put the difference in
temp_offset. - Leave it overnight and read the history in the morning.
The dining box, the hand-wired prototype of this design, has been running since 2 November. In that time Occupied hasn’t come on once in an empty room, and the lights haven’t gone off on anyone sitting still. The lounge box is the first rev A board: every sensor reported the first time it was plugged in.
Lessons learnt
Pick sensors that fail differently. A PIR can’t see someone sitting still and sees through doorways, and a radar can see a curtain move. Needing two of them to agree before the room turns on, and any one to hold it, plays each one to its strength.
Run the logic on the ESP. The timers live on the box, so a Home Assistant restart or update never loses track of who’s in the room.
Get the board made once the hand-wired one works. The prototype proved the design; the board makes the next one an hour’s job instead of an evening, and every one comes out the same.
Give the 60 GHz radar its own supply, and a way to switch it off. A small regulator gives it the clean 3.3 V it wants, and since it has no reset pin, a power switch is the only way to restart it without unplugging the box.
Pick pins that are safe on every chip you might use. The C3 and C5 have different start-up pins. Checking both datasheets once means one board takes either.
Build the radar windows to the datasheet. Hi-Link publishes the window thickness and gap for each radar. Design the case around those numbers and fit the rest of the parts around them, not the other way round.
One colour rule for every lead. Black ground, red positive, and the same signal colours on every module.
Questions and comments
Loading comments…