burgerlogo

How I Turned My Wi-Fi Into a Motion Sensor

How I Turned My Wi-Fi Into a Motion Sensor

avatar
Francesco Pace

- Last Updated: January 26, 2026

avatar

Francesco Pace

- Last Updated: January 26, 2026

featured imagefeatured imagefeatured image

On September 26, 2025, the IEEE 802.11bf standard was published, enabling Wi-Fi to natively detect motion. But I didn't want to wait.

The first compatible devices will arrive in a few months (maybe), but as a home automation enthusiast, I have a problem with waiting.

So I developed a motion detection system based on Wi-Fi spectrum analysis that:

  • Uses any ESP32 microcontroller (S3, C6, C3...) costing about $10 as a detector

     
  • Integrates natively with Home Assistant via ESPHome

     
  • Detects movement even through walls

     
  • Uses only mathematics and signal processing (no AI)

     
  • Works out-of-the-box with zero configuration

The project (ESPectre) is open source with over 4000 GitHub stars. Perhaps I wasn't the only impatient one!

Who I Am and Why I Did It

My name is Francesco Pace. I have a degree in mathematics and have been working in IT for over 20 years. Home automation is one of my passions, and recently I discovered the world of Wi-Fi sensing.

Although the 802.11bf standard was just released, the underlying technology isn't new. It's called Channel State Information (CSI) and involves processing physical information from the Wi-Fi signal's subcarriers.

The problem? The signal is extremely noisy. Appliances, TVs, cell phones, and people themselves generate continuous interference. For this reason, most existing solutions use Machine Learning techniques to clean the data and recognize specific patterns of human movement.

In a world now dominated by AI and Machine Learning, I wanted to demonstrate that it's possible to achieve excellent results even with inexpensive hardware, using only mathematics and signal processing. No neural networks, no model training, no gigabyte datasets: just mathematical algorithms, digital filters, and classic signal analysis.

Why Wi-Fi Instead of Traditional Sensors?

Before diving into how it works, let's address the obvious question: why use Wi-Fi when PIR and mmWave sensors are everywhere?

PIR sensors are cheap and simple, but they only work with line of sight and can't detect through walls or stationary objects.

 

mmWave radar is very accurate and can detect stationary presence, but each sensor covers a limited area (typically one room). The 24GHz signal is heavily attenuated by walls, so you likely need one sensor per room.

 

Cameras provide rich data and activity recognition, but they're a privacy nightmare and require high processing power.

 

Wi-Fi sensing has a unique advantage: through-wall detection. A single ESP32 in your living room can detect movement in adjacent rooms. The radio waves pass through walls, furniture, and doors. No sensor placement optimization, no dead zones.

How It Works

The Flashlight Analogy

Imagine holding a lit flashlight in a dark room. If you move your hand in front of the light, the shadow changes. If someone walks into the room, the shadows move differently.

Wi-Fi works the same way, but with invisible electromagnetic waves instead of light. When someone moves in a room, they "disturb" the Wi-Fi waves traveling between the router and the sensor. The sensor "listens" to these changes and understands if there is movement.

What CSI Data Is

Technically, what we analyze is called CSI (Channel State Information): information about the state of the radio channel.

In modern Wi-Fi systems (OFDM), the signal is transmitted over dozens of subcarriers, i.e., different frequencies traveling in parallel. For each subcarrier, the receiver calculates:

  • Amplitude: how strong the signal is

     
  • Phase: how much it is "shifted" compared to the original signal

Each subcarrier is represented as a complex number with two components: I (In-phase) and Q (Quadrature). This I/Q representation captures both amplitude and phase in a single value: $Amplitude = \sqrt{I^2 + Q^2}$.

Why is this important? Because when a person moves, both the amplitude (the signal attenuates or strengthens) and the phase (the signal arrives with a different delay due to reflections) change. These changes are mathematically detectable even through walls, without the need for cameras or microphones.

The Core Algorithm

Here's where it gets interesting. How do you go from radio waves to "someone is home?"

Automatic Subcarrier Selection

The ESP32 provides 64 subcarriers, but not all are equally useful. Some are noisier, others are more sensitive to movement. The system uses an automatic calibration algorithm that runs at boot time. During a brief 10-second quiet period, it analyzes each subcarrier's signal quality and automatically selects the best ones for your specific environment.

Moving Variance Segmentation (MVS)

The heart of the system is an algorithm called Moving Variance Segmentation:

  1. Spatial Turbulence: For each CSI packet, the system calculates the standard deviation of amplitudes across selected subcarriers.

     
  2. Moving Variance: A circular buffer stores the most recent measurements and computes the moving variance. Movement creates fluctuations, not just level changes.

     
  3. Adaptive Threshold: During calibration, the system measures baseline noise and calculates an adaptive threshold.

     
  4. State Machine: IDLE (variance below threshold) or MOTION (variance above threshold).

Signal Cleaning

Raw CSI data is noisy. The system applies a filter pipeline to clean the signal:

  • Hampel Filter: Removes outliers using statistical analysis.

     
  • Baseline Normalization: Ensures consistent behavior across different environments.

The Results

After extensive testing with real-world data (over 500 unit tests, 90% code coverage), the results are promising:

  • Recall: 98% (catches almost all movement)

     
  • Precision: 100% (no false positives in testing)

     
  • F1-Score: 99%

     
  • Latency: <10ms per packet

Supported Hardware

This approach runs on most ESP32 variants. The ESP32-S3 is recommended for the best performance. The ESP32-C6 offers great value with Wi-Fi 6 support. The ESP32-C3 is a budget-friendly option. The original ESP32 works but is less optimized.

Real-World Use Cases

  1. Home security: notifications when movement is detected

     
  2. Smart automations: lights that turn on only when needed

     
  3. Energy saving: heating that turns off in empty rooms

     
  4. Elderly monitoring: alerts if there's no movement for too long

     
  5. Office presence: workspace optimization

Home Assistant Integration

For smart home enthusiasts, the system integrates with Home Assistant through ESPHome. A YAML configuration file defines the device settings, and after flashing, the ESP32 appears in Home Assistant as a binary motion sensor.

Calibration Made Fun

Tuning a motion sensor is usually boring, so I built a browser-based game where your body is the controller. You play as a "Spectrum Guardian" protecting WiFi frequencies from enemies. The game is actually a calibration tool in disguise; while you play, the system identifies your baseline noise and adjusts the detection threshold automatically.

Why Mathematics and Not AI?

  • Zero configuration: works out-of-the-box after 10 seconds of calibration

     
  • Lightweight: runs on a $10 microcontroller in real-time

     
  • Deterministic: same input → same output (no "black box")

     
  • No training data: works in any environment without collecting datasets

Limitations

  • Doesn't distinguish between people and pets

     
  • Doesn't count how many people are in the room

     
  • Doesn't recognize specific activities (e.g., walking, running, falling)

 

Privacy Considerations

Although CSI data is technically anonymous, the system can detect the presence of people. Users are responsible for obtaining consent, complying with applicable privacy laws (e.g., GDPR, CCPA), and using the system only in environments they control.

Conclusions

This project demonstrates that it's possible to build advanced sensing systems using inexpensive hardware and classical mathematical approaches. ESPectre is completely open source (GPLv3) and available on GitHub.

Need Help Identifying the Right IoT Solution?

Our team of experts will help you find the perfect solution for your needs!

Get Help