Simple Metal Detectors

A Motion Detection System Based on Wi-Fi Spectral Analysis (CSI)

ESPectre is an experimental motion detection system based on Wi-Fi spectrum analysis (CSI — Channel State Information). In simple terms, a small ESP32-S3-based device “listens” to how the Wi-Fi channel changes between the router and the sensor: when someone moves in a room, the radio channel’s parameters change, and the project is able to capture these changes — without cameras, microphones, or wearable sensors. [Project on GitHub]

The core idea of the project is not machine learning, but mathematical signal processing: the project extracts a set of 10 statistical, temporal, and spatial features from CSI data and uses them to determine the presence of motion in real time. This provides two important advantages: the system works “out of the box” without model training, and at the same time these features can serve as a foundation for future ML experiments (people counting, gesture recognition, etc.).

The hardware side is very simple and cheap: you need a 2.4 GHz router and an ESP32-S3 board with external antennas (a kit costs around 300–400 rubles on AliExpress). MQTT (or Home Assistant) is used for integration, and the firmware is built using ESP-IDF.
The project’s README describes quick setup, a calibration guide, and sensor placement tips in detail, so the system works more accurately in a specific room.

Practical Use Cases

Sensor Placement

Distance to RouterSignalMultipathRecommendation
< 2 mToo strongMinimal❌ Too few reflections
3–8 mOptimalGood✅ Best
> 10–15 mWeakVariable❌ Too far

Optimal multipath conditions (3–8 m) provide enough reflections for accurate motion detection.

Placement Recommendations

[ESPectre diagram]

Each sensor is placed under a separate topic:

Motion Detection System Based
home/espectre/kitchen
home/espectre/bedroom
home/espectre/living

Home Assistant can perform the following functions:

Beginner FAQ

Q: Do I need programming knowledge to use this product?
A: Basic command-line skills are needed to build and flash the firmware using ESP-IDF. It’s recommended to follow the step-by-step guide provided in SETUP.md.

Q: Is this product compatible with my router?
A: Yes, as long as your router supports 2.4 GHz Wi-Fi, which is common on most modern routers.

Q: What are the hardware costs?
A: The total hardware cost is approximately 300–400 rubles for an ESP32-S3 board. The software is free and open source. You’ll also need a device to run an MQTT broker, such as Home Assistant or Mosquitto. This can be a Raspberry Pi costing about 35–50 euros, or any existing PC/NAS you already own, at no extra cost.

Q: Does the router need to be modified?
A: No, the router operates normally. The sensor “listens” to Wi-Fi signals without any modifications.

Q: Can the system distinguish between people and pets?
A: The system uses a two-state detection model: IDLE (inactive) and DETECTED (active). This model can identify general motion but doesn’t distinguish between people, pets, or other moving objects. More accurate classification (distinguishing people from pets, recognizing activity and gestures) would require trained AI or machine learning models (see the “Future Development” section).

Q: Does the system require high Wi-Fi bandwidth?
A: No, the system doesn’t require high Wi-Fi bandwidth. MQTT traffic is minimal. If smart publishing is disabled (the default), the system publishes every detection update. If smart publishing is enabled, the system only sends data on significant changes or every 5 seconds as a heartbeat pulse. This results in a data rate of about 0.2–0.5 kbit/s per sensor during idle periods and up to about 1 kbit/s during active movement. The impact on the network is negligible.

Q: Is the system compatible with mesh Wi-Fi networks?
A: Yes, the system works reliably. Just make sure the ESP32 is connected to the 2.4 GHz band.

Q: Is a dedicated server required?
A: No, Home Assistant can run on a Raspberry Pi, a NAS, or in the cloud. Alternatively, an MQTT broker (Mosquitto) can be used on any device.

Q: How accurate is the detection?
A: Detection accuracy depends on the environment and requires proper calibration. Performance is affected by room layout, wall materials, furniture placement, distance from the router (optimal: 3–8 meters), and the level of interference. Under optimal conditions with proper calibration, the system provides reliable motion detection. Use the built-in calibration tools (MQTT commands: analyze, threshold) to tune parameters for your environment.

Q: What’s the power consumption?
A: In normal operating mode, power consumption is approximately 500 mW. The firmware includes power optimization. Battery-powered devices can enter deep sleep mode, but this requires corresponding code modifications.

If you run into any issues, you can open an Issue on GitHub.


Below is a detailed breakdown of how ESPectre works under the hood, based on the project’s documentation. This will help readers better understand exactly what’s happening “under the hood,” and how human motion is captured via the Wi-Fi channel.

1. Capturing Channel State Information (CSI)

The Espressif ESP32-S3-based device uses a native API to capture CSI — i.e., the radio channel parameters between the router and the receiver.

CSI includes more complex data than plain RSSI:

When a person moves, reflections, signal directions, and multipath trajectories change — which shows up as variations in the CSI signal: for example, phase shifts occur, amplitude changes, and temporal fluctuations increase.

2. Signal Processing and Feature Extraction

After CSI is captured, the data goes through several processing stages before a motion decision is made:

Filtering and preprocessing: removing noise and outliers, smoothing. ESPectre uses the following stages:

Feature extraction: ten key features are computed from the cleaned CSI signal, divided into three groups: statistical, spatial (frequency-domain), and temporal.

Statistical (5 features):

  1. Variance — a measure of signal spread, increases during motion
  2. Skewness (distribution asymmetry) — helps detect “unusual” movements
  3. Kurtosis — the “tailedness” of the distribution, reveals abrupt changes
  4. Entropy — a measure of randomness or disorder in the signal; increases when the environment changes
  5. IQR (interquartile range) — a spread measure robust to outliers

Spatial (3 features):

  1. Spatial Variance — the spread of signals across subcarriers (frequency domain)
  2. Spatial Correlation — correlation between neighboring subcarriers: it drops during motion
  3. Spatial Gradient — the rate of signal change between subcarriers, high during changes

Temporal (2 features):

  1. Temporal Delta Mean — the average absolute change compared to the previous CSI packet
  2. Temporal Delta Variance — the variance of changes between consecutive packets

Scoring and decision-making:

From these 10 features, the system automatically selects the 4–6 most discriminative ones (for the current environment) and computes a weighted motion score based on them. The weighting coefficients are optimized using Fisher’s criterion.

A state machine is then used: IDLE (no motion) and DETECTED (motion detected). There’s debounce protection (e.g., requiring N consecutive triggers) and hysteresis, to prevent state “flickering.”

3. Integration and Data Publishing

After the calculations, the device performs the following actions:

Publishing via MQTT: the device sends a JSON message (with the motion state and supporting attributes) to the MQTT broker. By default, messages are sent every second, but “smart” publishing is also possible: only on change, or with a periodic “heartbeat.”

Home Assistant integration: MQTT topics can be automatically imported into Home Assistant as sensors. From there, you can build automations: turning on lights, sending notifications, analyzing behavior by room, and so on.

Scalable architecture: several ESP32-S3 sensors in different rooms can publish to MQTT, with Home Assistant aggregating them and building scenarios for the whole house.

4. Why This Works (and Where the Limitations Are)

Why it works:

Limitations:

The IEEE 802.11bf Wi-Fi Standard

Why a Standard Is Needed

Currently, technologies like ESPectre rely on “hacky” extraction of CSI (Channel State Information) from Wi-Fi chipsets that weren’t originally designed for this. As the project notes, only a limited number of Wi-Fi chipsets support CSI extraction, which restricts hardware choices.

The introduction of the IEEE 802.11bf standard means that CSI extraction and the use of Wi-Fi for “sensing” will become a built-in feature rather than an exception. This opens up a much broader market of devices and simplifies adoption.

What Exactly the Standard Provides

Current State (2025)

The project notes that there are currently no mass-market consumer routers with full 802.11bf support.
On the hardware side, advanced chips, many antennas, Wi-Fi 6/6E/7 support, and possibly additional (AI) computation are required. Expected rollout stages:

What This Means for Projects Like ESPectre

For now, as an implementation: you have to manually use the hardware, extract CSI, and write firmware and algorithms yourself. Once the standard is adopted:

Sources files

🔒

This content is available to logged-in users only.

هذا المحتوى متاح فقط للمستخدمين المسجلين.

Ce contenu est réservé aux membres connectés.

🔑 Login 📝 Register

Log in or create a free account to access downloads and exclusive content.

Exit mobile version