AdvancedSmart Environments

Invisible Room — mmWave Smart Space

Detect human presence without a camera and build a smart, responsive space.

Time
3–4 h
Estimated cost
~£40
Hardware
ESP32-DevKitC V4 (38-pin)

Example code — not yet validated

Try it in the browser

What you will build

A room sensor that knows whether someone is there, even sitting still and reading, using 24 GHz radar instead of a camera. A dashboard on your phone shows Present / Empty, Moving / Still, and which distance zone (Near, Middle, Far) the main target is in. A light strip turns on when someone is present and off two minutes after the room empties, with a manual override button.

How it works

The HLK-LD2410C sends out low-power 24 GHz radio waves and measures reflections. Tiny movements such as breathing are enough for it to report a stationary target; bigger movements are reported as a moving target, each with a distance and an energy value. It streams this over UART at 256000 baud. The ESP32 decodes it with the ld2410 library, turns it into simple states, drives the light through the MOSFET module from Project 04, and serves the dashboard.

What it can report: presence, moving vs still, approximate distance of the strongest target. What it cannot: exact position in the room, who someone is, or how many people there are.

Parts

Part Qty Purpose Required
ESP32-DevKitC V4 + breadboard + USB cable 1 Controller + Wi-Fi Yes
HLK-LD2410C mmWave radar module 1 Presence sensing Yes
Logic-level MOSFET module + 5 V LED strip (≤ 50 cm) + 5 V 2 A supply 1 set Room light (reuse Project 04) Yes
Tactile button 1 Manual override Yes
0.96" OLED 1 Local status Optional

Build steps

  1. Read the LD2410C datasheet for your module revision. It needs 5 V power; its UART pins are 3.3 V logic, safe for the ESP32.
  2. Radar: VCC → 5V (VIN), GND → GND, TX → GPIO 16 (ESP32 RX2), RX → GPIO 17 (ESP32 TX2). OUT pin → GPIO 13 (optional).
  3. Light: MOSFET module IN → GPIO 26, strip and supply wired as in Project 04. Button GPIO 27 → GND.
  4. Install the ld2410 library (by ncmreynolds). Add secrets.h with Wi-Fi details.
  5. Upload and open the Serial Monitor at 115200 baud. Checkpoint: walk around → moving; sit still 2 m away → still with a distance near 200 cm.
  6. Mount the radar at chest height facing the room, nothing metal in front of it.
  7. Open http://xbot-room.local. Walk from near to far and confirm the zones match reality. Adjust NEAR_CM and FAR_CM.
  8. Leave the room: the light turns off after EMPTY_HOLD_MS. Press the button: the light toggles and stays in manual mode until pressed again.
  9. For finer tuning (per-gate sensitivity, max range), use HLK's official configuration app over Bluetooth.

Try it in the browser

Demo Mode. A top-down room plan with three distance arcs from the sensor. Buttons simulate "walk in", "sit still" and "leave", and the light and timer react. Labelled Simulated events. Live Hardware appears only when the dashboard is served by the real ESP32. The dashboard never draws a precise person position, only the active zone.

Code

Download invisible-room.ino

// Invisible Room — XBOTNOW
// Board: ESP32-DevKitC V4 · Core: esp32 v3.x · Library: ld2410 (ncmreynolds)
// Radar firmware/version: record on the page; fields differ between versions.
#include <WiFi.h>
#include <WebServer.h>
#include <ESPmDNS.h>
#include <ld2410.h>
#include "secrets.h"

const int RADAR_RX = 16, RADAR_TX = 17, LIGHT_PIN = 26, BUTTON_PIN = 27;
const int NEAR_CM = 100, FAR_CM = 250;
const unsigned long EMPTY_HOLD_MS = 120000;   // 2 min

ld2410 radar;
WebServer server(80);
bool present = false, moving = false, manual = false, lightOn = false;
int distanceCm = 0;
unsigned long lastPresent = 0;

const char* zone() {
  if (!present) return "none";
  return distanceCm < NEAR_CM ? "near" : distanceCm < FAR_CM ? "middle" : "far";
}

void setup() {
  Serial.begin(115200);
  Serial2.begin(256000, SERIAL_8N1, RADAR_RX, RADAR_TX);
  if (!radar.begin(Serial2)) Serial.println("Radar not responding: check wiring and 5 V");
  pinMode(LIGHT_PIN, OUTPUT);
  pinMode(BUTTON_PIN, INPUT_PULLUP);

  WiFi.begin(WIFI_SSID, WIFI_PASS);
  while (WiFi.status() != WL_CONNECTED) delay(300);
  MDNS.begin("xbot-room");
  server.on("/data", [] {
    server.send(200, "application/json",
      String("{\"present\":") + present + ",\"moving\":" + moving +
      ",\"distance\":" + distanceCm + ",\"zone\":\"" + zone() +
      "\",\"light\":" + lightOn + ",\"manual\":" + manual + ",\"source\":\"live\"}");
  });
  server.begin();   // the dashboard page (/) is served from the project's web bundle
}

void loop() {
  server.handleClient();
  radar.read();
  if (radar.isConnected()) {
    present = radar.presenceDetected();
    moving = radar.movingTargetDetected();
    if (moving) distanceCm = radar.movingTargetDistance();
    else if (radar.stationaryTargetDetected()) distanceCm = radar.stationaryTargetDistance();
  }
  if (present) lastPresent = millis();

  if (digitalRead(BUTTON_PIN) == LOW) {            // manual override toggle
    manual = !manual;
    lightOn = manual ? !lightOn : lightOn;
    delay(300);
  }
  if (!manual) lightOn = present || (lastPresent && millis() - lastPresent < EMPTY_HOLD_MS);
  digitalWrite(LIGHT_PIN, lightOn);

  static unsigned long lastLog = 0;
  if (millis() - lastLog > 1000) {
    Serial.printf("%s %s %d cm zone=%s light=%d\n", present ? "present" : "empty",
                  moving ? "moving" : "still", distanceCm, zone(), lightOn);
    lastLog = millis();
  }
}

Troubleshooting

Symptom Likely cause Check
"Radar not responding" TX/RX swapped or 3.3 V supply Swap GPIO 16/17; power from 5 V
Always "present" in an empty room Fan, curtain or pet movement; too sensitive Reduce gate sensitivity in HLK app; aim away from moving objects
Loses a person sitting still Out of range or behind furniture Move closer; raise stationary sensitivity
Distance jumps Several people or reflections Expected: it reports the strongest target only

Safety and limitations

The radar's output power is very low and it is sold for consumer presence sensing. One LD2410C does not provide 3D coordinates, identity recognition or reliable multi-person counting. Not a security, intruder or emergency system, and not suitable for monitoring the wellbeing of vulnerable people. Tell people in the room that a presence sensor is running.

Checklist

Next project

AI Pixel Companion: give your projects a face and a voice.

Next project: AI Pixel Companion