Motion detection system based on Wi-Fi spectre analysis (CSI), with Home Assistant integration.
๐ฐ Featured Article: Read the complete story behind ESPectre on Medium ๐ฎ๐น Italian, ๐ฌ๐ง English
- In 3 Points
- Mathematical Approach
- What You Need
- Quick Start
- How It Works
- What You Can Do With It
- Sensor Placement Guide
- System Architecture
- FAQ
- Security and Privacy
- Technical Deep Dive
- Future Evolutions
- References
- Changelog
- License
- Author
- What it does: Detects movement at home using Wi-Fi (no cameras, no microphones)
- What you need: A ~โฌ10 device (ESP32-S3) + Home Assistant or MQTT server + ESP-IDF development tools
- Setup time: 30-45 minutes (first time, including ESP-IDF setup)
This project currently does NOT use Machine Learning models. Instead, it employs a mathematical approach that extracts 10 features from CSI (Channel State Information) data using statistical and signal processing techniques.
- โ No ML training required: Works out-of-the-box with mathematical algorithms
- โ 10 extracted features: Statistical, spatial, and temporal features
- โ Real-time processing: Low latency detection on ESP32-S3 hardware
- โ Foundation for ML: These features can serve as the basis for collecting labeled datasets to train ML models for advanced tasks (people counting, activity recognition, gesture detection)
The mathematical approach provides excellent movement detection without the complexity of ML model training, while the extracted features offer a solid foundation for future ML-based enhancements.
- โ 2.4GHz Wi-Fi Router (the one you already have at home works fine)
- โ ESP32-S3 DevKit bundle with external antennas (~โฌ10) - Available on Amazon, AliExpress, or electronics stores
ESP32-S3 DevKit with external antennas (recommended for better reception)
- โ
MQTT Broker (required for operation):
- Home Assistant with built-in MQTT broker (on Raspberry Pi, PC, NAS, or cloud)
- OR standalone Mosquitto MQTT server (can run on any device, including Raspberry Pi)
- โ ESP-IDF v6.1 (development framework for building firmware)
- โ Basic command line knowledge required for building and flashing firmware
- โ NO router configuration needed
- โ Follow the setup guide in SETUP.md
Setup time: ~30-45 minutes (first time)
- Setup & Installation: Follow the complete guide in SETUP.md
- Calibration & Tuning: Optimize for your environment with CALIBRATION.md
When someone moves in a room, they "disturb" the Wi-Fi waves traveling between the router and the sensor. It's like when you move your hand in front of a flashlight and see the shadow change.
The ESP32-S3 device "listens" to these changes and understands if there's movement.
- โ No cameras (total privacy)
- โ No wearables needed (no bracelets or sensors to wear)
- โ Works through walls (Wi-Fi passes through walls)
- โ Very cheap (~โฌ10 total)
๐ Technical Explanation (click to expand)
Channel State Information (CSI) represents the physical characteristics of the wireless communication channel between transmitter and receiver. Unlike simple RSSI (Received Signal Strength Indicator), CSI provides rich, multi-dimensional data about the radio channel.
Per-subcarrier information:
- Amplitude: Signal strength for each OFDM subcarrier (up to 64)
- Phase: Phase shift of each subcarrier
- Frequency response: How the channel affects different frequencies
Environmental effects:
- Multipath propagation: Reflections from walls, furniture, objects
- Doppler shifts: Changes caused by movement
- Temporal variations: How the channel evolves over time
- Spatial patterns: Signal distribution across antennas/subcarriers
When a person moves in an environment, they:
- Alter multipath reflections (new signal paths)
- Change signal amplitude and phase
- Create temporal variations in CSI patterns
- Modify the electromagnetic field structure
These changes are detectable even through walls, enabling privacy-preserving presence detection without cameras, microphones, or wearable devices.
- ๐ Home security: Get an alert if someone enters while you're away
- ๐ด Elderly care: Monitor activity to detect falls or prolonged inactivity
- ๐ก Smart automation: Turn on lights/heating only when someone is present
- โก Energy saving: Automatically turn off devices in empty rooms
- ๐ถ Child monitoring: Alert if they leave the room during the night
- ๐ก๏ธ Climate control: Heat/cool only occupied zones
Optimal sensor placement is crucial for reliable movement detection.
Optimal range: 3-8 meters
| Distance | Signal | Multipath | Sensitivity | Noise | Recommendation |
|---|---|---|---|---|---|
| < 2m | Too strong | Minimal | Low | Low | โ Too close |
| 3-8m | Strong | Good | High | Low | โ Optimal |
| > 10-15m | Weak | Variable | Low | High | โ Too far |
โ Position sensor in the area to monitor (not necessarily in direct line with router)
ESPectre uses a streamlined processing pipeline:
โโโโโโโโโโโโโโโ
โ CSI Data โ Raw Wi-Fi Channel State Information
โโโโโโโโฌโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโ
โSegmentation โ Moving Variance Segmentation (MVS)
โ (2-state) โ IDLE โ MOTION (operates on RAW CSI)
โโโโโโโโฌโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โผ โผ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โ IDLE โ โ MOTION โ
โ (no feat.) โ โ (optional โ
โ โ โ features) โ
โโโโโโโโโโโโโโโ โโโโโโโโฌโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโ
โ Filters โ Butterworth, Wavelet,
โ โ Hampel, Savitzky-Golay
โ โ (applied to features only)
โโโโโโโโฌโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโ
โ Features โ 10 mathematical features
โ (if enabled)โ (filtered CSI data)
โโโโโโโโฌโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโ
โ โ
โผ โผ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ MQTT โ Publish state + metrics โ MQTT โ
โ (IDLE) โ โ (MOTION) โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
Key Points:
- 2-state system: IDLE or MOTION (no intermediate states)
- Segmentation-based: Uses Moving Variance Segmentation (MVS) on raw CSI data
- Filters applied to features only: Segmentation uses unfiltered data to preserve motion sensitivity
- Optional features: Feature extraction only during MOTION state (configurable)
โโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโ
โESP32-S3 โ โESP32-S3 โ โESP32-S3 โ
โ Room 1 โ โ Room 2 โ โ Room 3 โ
โโโโโโฌโโโโโ โโโโโโฌโโโโโ โโโโโโฌโโโโโ
โ โ โ
โโโโโโโโโโโโโโดโโโโโโโโโโโโโ
โ
โ MQTT
โผ
โโโโโโโโโโโโโโโโโโโโโโ
โ MQTT Broker โ
โ (Home Assistant โ
โ built-in or any โ
โ MQTT Server) โ
โโโโโโโโโโฌโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโ
โ Home Assistant โ
โ MQTT Sensors โ
โ & Automations โ
โโโโโโโโโโโโโโโโโโ
Each sensor publishes to its own topic:
home/espectre/kitchenhome/espectre/bedroomhome/espectre/living
Home Assistant can then:
- Monitor each room independently
- Create group sensors for whole-house occupancy
- Implement zone-based automations
- Track movement patterns across rooms
Click to expand FAQ
Q: Do I need programming knowledge to use it?
Q: Does it work with my router?
Q: How much does it cost in total?
Q: Do I need to modify anything on the router?
Q: Can I try it without Home Assistant?
Q: Does it work through walls?
Q: How many sensors are needed for a house?
Q: Can it distinguish between people and pets?
Q: Does it consume a lot of Wi-Fi bandwidth?
Q: Does it work with mesh Wi-Fi networks?
Q: Is a dedicated server necessary?
Q: How accurate is the detection?
Q: What's the power consumption?
Q: If it doesn't work, can I get help?
๐ Privacy, Security & Ethical Considerations (click to expand)
The system collects anonymous data related to the physical characteristics of the Wi-Fi radio channel:
- Amplitudes and phases of OFDM subcarriers
- Statistical signal variances
- NOT collected: personal identities, communication contents, images, audio
CSI data represents only the properties of the transmission medium and does not contain direct identifying information.
โ No cameras: Respect for visual privacy
WARNING: Despite the intrinsic anonymity of CSI data, this system can be used for:
- Non-consensual monitoring: Detecting presence/movement of people without their explicit consent
- Behavioral profiling: With advanced AI models, inferring daily life patterns
- Domestic privacy violation: Tracking activities inside private homes
The user is solely responsible for using this system and must:
- โ Obtain explicit consent from all monitored persons
- โ Respect local regulations (GDPR in EU, local privacy laws)
- โ Clearly inform about the presence of the sensing system
- โ Limit use to legitimate purposes (home security, personal home automation)
- โ Protect data with encryption and controlled access
- โ DO NOT use for illegal surveillance, stalking, or violation of others' privacy
Moving Variance Segmentation (MVS) analysis: baseline graphs (top) show quiet state, while bottom graphs show motion detection with turbulence signal, adaptive threshold, and state transitions
๐ฌ Signal Processing Pipeline (click to expand)
- Native ESP32 CSI API captures Wi-Fi Channel State Information via callback
- Extracts amplitude and phase data from OFDM subcarriers (up to 64 subcarriers)
- Typical capture rate: ~10-100 packets/second depending on Wi-Fi traffic
- Spatial turbulence calculation: Standard deviation of subcarrier amplitudes (raw CSI data)
- Moving Variance Segmentation (MVS): Real-time motion segment extraction
- Adaptive threshold: Based on moving variance of turbulence signal
- Segment features: Duration, average turbulence, maximum turbulence
- Circular buffer: Maintains up to 10 recent segments for analysis
- Foundation for ML: Segments can be labeled and used for activity classification
Note: Segmentation operates on raw, unfiltered CSI data to preserve motion sensitivity. Filters are not applied to the turbulence signal used for segmentation.
Advanced filters applied to CSI data before feature extraction (configurable via MQTT):
- Butterworth Low-Pass: Removes high-frequency noise >8Hz (environmental interference) - Enabled by default
- Wavelet db4: Removes low-frequency persistent noise using Daubechies wavelet transform
- Hampel Filter: Outlier removal using MAD (Median Absolute Deviation)
- Savitzky-Golay Filter: Polynomial smoothing (enabled by default)
Filter Pipeline: Raw CSI โ Butterworth (high freq) โ Wavelet (low freq) โ Hampel โ Savitzky-Golay โ Features
Note: Filters are applied only to feature extraction, not to segmentation. Segmentation uses raw CSI data to preserve motion sensitivity.
When enabled (default: on), extracts 10 mathematical features from filtered CSI data during MOTION state:
- Statistical (5): Variance, Skewness, Kurtosis, Entropy, IQR
- Spatial (3): Spatial variance, correlation, gradient across subcarriers
- Temporal (2): Delta mean, delta variance (changes between consecutive packets)
Note: Feature extraction can be disabled to reduce CPU usage if only basic motion detection is needed.
- Publishes JSON payload every 1 second (configurable)
- QoS level 0 (fire-and-forget) for low latency
- Retained message option for last known state
- Automatic reconnection on connection loss
- MQTT Sensor subscribes to topic and creates entity
- State: Primary
movementvalue (0.0-1.0) - Attributes: All other metrics available for conditions
- History: Automatic logging to database for graphs
๐ Optional Feature Extraction (click to expand)
ESPectre can optionally extract 10 mathematical features from CSI data during MOTION state:
Statistical properties of the CSI signal distribution:
- Variance - Signal variability, increases significantly with movement
- Skewness - Distribution asymmetry, detects irregular movement patterns
- Kurtosis - Distribution "tailedness", identifies outliers and sudden changes
- Entropy - Signal randomness/disorder, increases when environment changes
- IQR (Interquartile Range) - Robust spread measure (Q3-Q1), resistant to outliers
Characteristics across OFDM subcarriers (frequency domain):
- Spatial Variance - Variability across subcarriers, indicates multipath diversity
- Spatial Correlation - Correlation between adjacent subcarriers, affected by movement
- Spatial Gradient - Rate of change across subcarriers, highly sensitive to movement
Changes between consecutive CSI packets:
- Temporal Delta Mean - Average absolute difference from previous packet
- Temporal Delta Variance - Variance of differences from previous packet
Feature extraction is enabled by default but can be disabled to reduce CPU usage. Note: Features are only extracted during MOTION state, not during IDLE, to optimize performance.
๐ Technical Specifications (click to expand)
- Board: ESP32-S3-DevKitC-1 N16R8
- Flash: 16MB
- PSRAM: 8MB
- Wi-Fi: 802.11 a/g/n (2.4 GHz only)
- Antenna: Built-in PCB antenna + IPEX connector for external
- Power: USB-C 5V or 3.3V via pins
- Framework: ESP-IDF v6.1
- Language: C
- Build System: CMake
- Flash Tool: esptool.py
- CSI Capture Rate: 10-100 packets/second
- Processing Latency: <50ms per packet
- MQTT Publish Rate: Smart publishing (only on significant changes + 5s heartbeat)
- MQTT Bandwidth: ~0.2-1 KB/s depending on activity
- Power Consumption: ~500mW typical
- Detection Range: 3-8 meters optimal
- Detection Accuracy: Environment-dependent, requires tuning
- Works only on 2.4 GHz band (ESP32-S3 hardware limitation)
- Sensitivity dependent on: wall materials, antenna placement, distances, interference
- Not suitable for environments with very high Wi-Fi traffic
- Cannot distinguish between people, pets, or objects (generic motion detection)
- Cannot count people or recognize specific activities (without ML models)
- Reduced performance through metal obstacles or thick concrete walls
๐ Machine Learning and Deep Learning (click to expand)
The current implementation uses an advanced mathematical approach with 10 features and multi-criteria detection to identify movement patterns. While this provides excellent results without requiring ML training, scientific research has shown that Machine Learning and Deep Learning techniques can extract even richer information from CSI data for complex tasks like people counting, activity recognition, and gesture detection.
Classification or regression models can estimate the number of people present in an environment by analyzing complex patterns in CSI.
References:
- Wang et al. (2017) - "Device-Free Crowd Counting Using WiFi Channel State Information" - IEEE INFOCOM
- Xi et al. (2016) - "Electronic Frog Eye: Counting Crowd Using WiFi" - IEEE INFOCOM
Neural networks (CNN, LSTM, Transformer) can classify human activities like walking, falling, sitting, sleeping.
References:
- Wang et al. (2015) - "Understanding and Modeling of WiFi Signal Based Human Activity Recognition" - ACM MobiCom
- Yousefi et al. (2017) - "A Survey on Behavior Recognition Using WiFi Channel State Information" - IEEE Communications Magazine
- Zhang et al. (2019) - "WiFi-Based Indoor Robot Positioning Using Deep Neural Networks" - IEEE Access
Deep learning algorithms can estimate position and trajectory of moving people.
References:
- Wang et al. (2016) - "CSI-Based Fingerprinting for Indoor Localization: A Deep Learning Approach" - IEEE Transactions on Vehicular Technology
- Chen et al. (2018) - "WiFi CSI Based Passive Human Activity Recognition Using Attention Based BLSTM" - IEEE Transactions on Mobile Computing
Models trained on CSI temporal sequences can recognize hand gestures for touchless control.
References:
- Abdelnasser et al. (2015) - "WiGest: A Ubiquitous WiFi-based Gesture Recognition System" - IEEE INFOCOM
- Jiang et al. (2020) - "Towards Environment Independent Device Free Human Activity Recognition" - ACM MobiCom
- UT-HAR: Human Activity Recognition dataset (University of Texas)
- Widar 3.0: Gesture recognition dataset with CSI
- SignFi: Sign language recognition dataset
- FallDeFi: Fall detection dataset
๐ Standardized Wi-Fi Sensing (IEEE 802.11bf) (click to expand)
Currently, only a limited number of Wi-Fi chipsets support CSI extraction, which restricts hardware options for Wi-Fi sensing applications. However, the IEEE 802.11bf (Wi-Fi Sensing) standard should significantly improve this situation by making CSI extraction a standardized feature.
The 802.11bf standard was officially published on September 26, 2025, introducing Wi-Fi Sensing as a native feature of the Wi-Fi protocol. Main characteristics:
๐น Native sensing: Detection of movements, gestures, presence, and vital signs
Market: The Wi-Fi Sensing market is in its early stages and is expected to experience significant growth in the coming years as the 802.11bf standard enables native sensing capabilities in consumer devices.
Hardware availability:
โ ๏ธ Consumer routers: Currently there are no widely available consumer routers with native 802.11bf support- ๐ข Commercial/industrial: Experimental devices and integrated solutions already in use
- ๐ง Hardware requirements: Requires multiple antennas, Wi-Fi 6/6E/7 support, and AI algorithms for signal processing
Expected timeline:
- 2025-2026: First implementations in enterprise and premium smart home devices
- 2027-2028: Diffusion in high-end consumer routers
- 2029+: Mainstream adoption in consumer devices
When 802.11bf is widely adopted, applications like this project will become:
- More accessible: No need for specialized hardware or modified firmware
- More reliable: Standardization ensures predictable behavior
- More efficient: Protocols optimized for continuous sensing
- More secure: Privacy mechanisms integrated at the standard level
- More powerful: Ability to detect even vital signs (breathing, heartbeat)
Perspective: In the next 3-5 years, routers and consumer devices will natively support Wi-Fi Sensing, making projects like this implementable without specialized hardware or firmware modifications. This will open new possibilities for smart home, elderly care, home security, health monitoring, and advanced IoT applications.
For now: Solutions like this project based on ESP32 CSI API remain the most accessible and economical way to experiment with Wi-Fi Sensing.
This project builds upon extensive research in Wi-Fi sensing and CSI-based movement detection. The following academic works and theses provide valuable insights into mathematical signal processing approaches for human activity recognition using Wi-Fi Channel State Information:
-
Wi-Fi Sensing per Human Identification attraverso CSI
-
Channel State Information (CSI) Features Collection in Wi-Fi
-
Indoor Motion Detection Using Wi-Fi Channel State Information (2018)
-
WiFi Motion Detection: A Study into Efficacy and Performance (2019)
-
CSI-HC: A WiFi-Based Indoor Complex Human Motion Recognition Using Channel State Information (2020)
-
Location Intelligence System for People Estimation in Indoor Environment During Emergency Operation (2022)
These references demonstrate that effective Wi-Fi sensing can be achieved through mathematical and statistical approaches, which is the foundation of ESPectre's design philosophy.
For a detailed history of changes, new features, and improvements, see the CHANGELOG.md.
This project is released under the GNU General Public License v3.0 (GPLv3).
GPLv3 ensures that:
- โ The software remains free and open source
- โ Anyone can use, study, modify, and distribute it
- โ Modifications must be shared under the same license
- โ Protects end-user rights and software freedom
See LICENSE for the full license text.
Francesco Pace