MCPcopy Index your code
hub / github.com/francescopace/espectre

github.com/francescopace/espectre @2.8.0

repository ↗ · DeepWiki ↗ · release 2.8.0 ↗ · Ask this repo → · + Follow
1,209 symbols 4,204 edges 58 files 1,010 documented · 84% updated today2.8.0 · 2026-05-21★ 8,7464 open issues
README

License ESPHome Platform Release CI codecov

🛜 ESPectre 👻

Motion detection system based on Wi-Fi spectre analysis (CSI), with native Home Assistant integration via ESPHome.

[!TIP] New ML Detector: Neural network-based motion detection. No calibration required, runs on-device. This is an experimental feature, and feedback is welcome in the dedicated ML detector discussion. A snapshot build with the latest changes is also available (use -ml assets for the machine learning based detector), or follow Setup guide for custom configuration.


Table of Contents


In 3 Points

  1. What it does: Detects movement using Wi-Fi (no cameras, no microphones)
  2. What you need: A ~€10 ESP32 device (S3 and C6 recommended, other variants supported)
  3. Setup time: 10-15 minutes

What You Need

Hardware

  • 2.4GHz Wi-Fi Router - the one you already have at home works fine
  • ESP32 with CSI support - ESP32-C6, ESP32-S3, ESP32-C3, ESP32 (original) or other variants. See SETUP.md for the complete platform comparison table.

3 x ESP32-S3 DevKit bundle with external antennas ESP32-S3 DevKit with external antennas

Software (All Free)

  • Home Assistant (on Raspberry Pi, PC, NAS, or cloud)
  • ESPHome (integrated in Home Assistant or standalone)

Required Skills

  • Basic YAML knowledge for configuration
  • Home Assistant familiarity (optional but recommended)
  • NO programming required
  • NO router configuration needed

Quick Start

Setup time: ~10-15 minutes
Difficulty: Easy (YAML configuration only)

  1. Setup & Installation: Follow the complete guide in SETUP.md
  2. Tuning: Optimize for your environment with TUNING.md

ESPectre Home Assistant Dashboard Home Assistant dashboard with real-time motion detection, threshold control, and debug sensors


How It Works

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 device "listens" to these changes and understands if there's movement.

Advantages

  • 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)

Want to understand the technical details? See ALGORITHMS.md for CSI explanation and signal processing documentation.


What You Can Do With It

Practical Examples

  • 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

Where to Place the Sensor

Optimal sensor placement is crucial for reliable movement detection.

Recommended Distance from Router

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

Placement Tips

Do: - Position sensor in the area to monitor (not necessarily in direct line with router) - Height: 1-1.5 meters from ground (desk/table height) - External antenna: Use IPEX connector for better reception

Don't: - Avoid metal obstacles between router and sensor (refrigerators, metal cabinets) - Avoid corners or enclosed spaces (reduces multipath diversity)


System Architecture

Processing Pipeline

ESPectre uses a focused processing pipeline for motion detection:

┌─────────────┐
│  CSI Data   │  Raw Wi-Fi Channel State Information
└──────┬──────┘
       │
       ▼
┌─────────────┐
│  Gain Lock  │  AGC/FFT stabilization (~3 seconds)
│             │  Locks hardware gain for stable measurements
└──────┬──────┘
       │
       ▼
┌─────────────┐
│    Auto     │  Automatic subcarrier selection (once at boot)
│ Calibration │  Selects optimal 12 subcarriers (NBVI)
└──────┬──────┘
       │
       ▼
┌─────────────┐
│  Adaptive   │  auto: P95 × 1.1 | min: P100
│  Threshold  │  or fixed manual value
└──────┬──────┘
       │
       ▼
┌─────────────┐
│   Hampel    │  Turbulence outlier removal
│   Filter    │  (enabled by default)
└──────┬──────┘
       │
       ▼
┌─────────────┐
│  Low-pass   │  Noise reduction (smoothing)
│   Filter    │  (optional, disabled by default)
└──────┬──────┘
       │
       ▼
┌─────────────┐
│ Detection   │  MVS or ML score
│ Evaluation  │  every evaluation_interval packets
└──────┬──────┘
       │
       ▼
┌─────────────┐
│ Hit Filter  │  motion_on_hits / motion_off_hits
│             │  edge-driven IDLE ↔ MOTION
└──────┬──────┘
       │
       ▼
┌─────────────┐
│ Home        │  Edge-driven motion binary +
│ Assistant   │  periodic Movement Score / Threshold
└─────────────┘

Single or Multiple Sensors

┌─────────┐  ┌─────────┐  ┌─────────┐
│ ESP32   │  │ ESP32   │  │ ESP32   │
│ Room 1  │  │ Room 2  │  │ Room 3  │
└────┬────┘  └────┬────┘  └────┬────┘
     │            │            │
     └────────────┴────────────┘
                  │
                  │ ESPHome Native API
                  ▼
         ┌────────────────────┐
         │   Home Assistant   │
         │   (Auto-discovery) │
         └────────────────────┘

Each sensor is automatically discovered by Home Assistant with: - Binary sensor for motion detection, published immediately on state edges - Movement score sensor, published on the periodic cadence - Adjustable threshold (number entity)

Automatic Subcarrier Selection

ESPectre implements NBVI (Normalized Band Variance Index) for automatic subcarrier selection, achieving near-optimal performance (F1>96%) with zero manual configuration. The algorithm selects 12 non-consecutive subcarriers based on stability metrics and spectral diversity.

⚠️ IMPORTANT (MVS mode): Keep the room quiet and still for 10 seconds after device boot. The auto-calibration runs during this time and movement will affect detection accuracy. ML mode skips calibration.

For algorithm details, see ALGORITHMS.md.


FAQ for Beginners

Click to expand FAQ

Q: Do I need programming knowledge to use it?
A: No! ESPectre uses YAML configuration files. Just download the example, flash it, and configure WiFi via the ESPHome app or web interface.

Q: Does it work with my router?
A: Yes, if your router has 2.4GHz Wi-Fi (virtually all modern routers have it).

Q: How much does it cost in total?
A: Hardware: ~€10 for an ESP32 device (S3/C6 recommended, other variants also work). Software: All free and open source. You'll also need Home Assistant running somewhere (Raspberry Pi ~€35-50, or any existing PC/NAS).

Q: Do I need to modify anything on the router?
A: No! The router works normally. The sensor "listens" to Wi-Fi signals without modifying anything.

Q: Does it work through walls?
A: Yes, the 2.4GHz Wi-Fi signal penetrates drywall. Reinforced concrete walls reduce sensitivity but detection remains possible at reduced distances.

Q: How many sensors are needed for a house?
A: It depends on size. One sensor can monitor ~50 m². For larger homes, use multiple sensors (1 sensor every 50-70 m² for optimal coverage).

Q: Can it distinguish between people and pets?
A: The system uses a 2-state segmentation model (IDLE/MOTION) that identifies generic movement without distinguishing between people, pets, or other moving objects. For more sophisticated classification (people vs pets, activity recognition, gesture detection), trained AI/ML models would be required (see Future Evolution section).

Q: Does it work with mesh Wi-Fi networks?
A: Yes, it works normally. Make sure the ESP32 connects to the 2.4 GHz band.

Q: How accurate is the detection?
A: Detection accuracy is highly environment-dependent and requires proper tuning. Factors affecting performance include: room layout, wall materials, furniture placement, distance from router (optimal: 3-8m), and interference levels. In optimal conditions with proper tuning, the system provides reliable movement detection. Adjust the segmentation_threshold parameter to tune sensitivity for your specific environment.

Q: What's the power consumption?
A: ~500mW typical during continuous operation. The firmware includes support for power optimization, and deep sleep modes can be implemented for battery-powered deployments, though this would require custom modifications to the code.

Q: If it doesn't work, can I get help?
A: Yes, open an Issue on GitHub or contact me via email.


Security and Privacy

Privacy, Security & Ethical Considerations (click to expand)

Nature of Collected Data

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.

Privacy Advantages

  • No cameras: Respect for visual privacy
  • No microphones: No audio recording
  • No wearables: Doesn't require wearable devices
  • Aggregated data: Only statistical metrics, not raw identifying data

⚠️ Disclaimer and Ethical Considerations

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

Usage Responsibility

The user is solely responsible for using this system and must:

  1. Obtain explicit consent from all monitored persons
  2. Respect local regulations (GDPR in EU, local privacy laws)
  3. Clearly inform about the presence of the sensing system
  4. Limit use to legitimate purposes (home security, personal home automation)
  5. Protect data with encryption and controlled access
  6. DO NOT use for illegal surveillance, stalking, or violation of others' privacy

Technical Deep Dive

For algorithm details (MVS, NBVI calibration, Hampel filter), see ALGORITHMS.md.

For performance metrics (confusion matrix, F1-score, benchmarks), see PERFORMANCE.md.


Two-Platform Strategy

This project follows a dual-platform approach to balance innovation speed with production stability:

ESPectre (This Repository) - Production Platform

Target: End users, smart home enthusiasts, Home Assistant users

  • ESPHome component with native Home Assistant integration
  • YAML configuration - no programming required
  • Auto-discovery - devices appear automatically in Home Assistant
  • Production-ready - stable, tested, easy to deploy
  • Demonstrative - showcases research results in a user-friendly package

Micro-ESPectre - R&D Platform

Target: Researchers, developers, academic/industrial applications

  • Python/MicroPython implementation for rapid prototyping
  • MQTT-based - flexible integration (not limited to Home Assistant)
  • Fast iteration - test new algorithms in seconds, not minutes
  • Analysis tools - comprehensive suite for CSI data analysis
  • Use cases: Academic research, industrial sensing, algorithm development

Micro-ESPectre gives you the fundamentals for: - People counting - Activity recognition (walking, falling, sitting

Core symbols most depended-on inside this repo

add_turbulence
called by 52
micro-espectre/src/segmentation.py
playTone
called by 36
docs/game/game.js
free_buffer
called by 35
micro-espectre/src/nbvi_calibrator.py
calculate_spatial_turbulence
called by 30
micro-espectre/tools/csi_utils.py
update_state
called by 30
micro-espectre/src/segmentation.py
process_packet
called by 29
micro-espectre/tools/csi_utils.py
filter
called by 25
micro-espectre/src/filters.py
send_response
called by 24
micro-espectre/src/mqtt/commands.py

Shape

Method 732
Function 326
Class 149
Route 2

Languages

Python94%
TypeScript6%

Modules by API surface

micro-espectre/tools/10_train_ml_model.py98 symbols
micro-espectre/tests/test_mqtt.py88 symbols
micro-espectre/tests/test_utils.py75 symbols
docs/game/game.js70 symbols
micro-espectre/tests/test_segmentation.py52 symbols
micro-espectre/tests/test_ml_detector.py52 symbols
micro-espectre/tools/csi_utils.py48 symbols
micro-espectre/tests/test_filters.py45 symbols
micro-espectre/tests/conftest.py45 symbols
micro-espectre/tools/5_analyze_filter_turbulence.py44 symbols
micro-espectre/tests/test_nbvi_calibrator.py42 symbols
micro-espectre/tests/test_features.py41 symbols

Dependencies from manifests, versioned

PyWavelets1.9.0 · 1×
PyYAML6.0.3 · 1×
colorama0.4.6 · 1×
esptool5.2.0 · 1×
gcovr8.6 · 1×
matplotlib3.10.9 · 1×
mpremote1.28.0 · 1×
numpy2.4.6 · 1×
paho-mqtt1.6.1 · 1×
prompt_toolkit3.0.52 · 1×
pyserial3.5 · 1×
pytest9.0.3 · 1×

For agents

$ claude mcp add espectre \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact