All articles
Technology

How WiFi CSI Sensing Works (with Diagrams)

A comprehensive guide explaining the physics and mathematics behind WiFi Channel State Information (CSI), multipath propagation, phase sanitization, and edge AI inference.

·14 min
How WiFi CSI Sensing Works (with Diagrams)

The Fundamentals of Wi-Fi Radio Waves and OFDM

The Fundamentals of Wi-Fi Radio Waves and OFDM

To understand how WiFi Channel State Information (CSI) can be used to track human beings through walls, we must first dive into how modern WiFi systems transmit data. Modern Wi-Fi standards (specifically 802.11a/g/n/ac/ax) rely on a modulation technique called Orthogonal Frequency Division Multiplexing (OFDM). Instead of transmitting a high-speed data stream over a single wide frequency channel, OFDM splits the channel into multiple narrow-band, closely spaced subcarriers.

For example, a standard 20 MHz wide channel in a 2.4 GHz network is divided into 64 subcarriers, while a 40 MHz channel contains 128 subcarriers. Data bits are modulated onto these subcarriers simultaneously. When a WiFi packet is sent, the transmitter emits a known preamble—a training sequence of radio waves. As these waves travel through space, they encounter physical objects like walls, doors, ceilings, and human bodies.

Each subcarrier has a slightly different frequency, meaning it behaves uniquely when interacting with physical materials. Some subcarriers might pass straight through a wooden door, while others are reflected or absorbed. By the time the packets reach the receiver's antenna, the training sequence is distorted. The receiver measures this distortion by comparing the received signal to the expected preamble, producing a Channel State Information (CSI) matrix.

Amplitude vs. Phase: The Anatomy of a CSI Packet

CSI is represented mathematically as a complex number for each subcarrier. For a given subcarrier $i$, the CSI value $H_i$ is expressed as:

H_i = |H_i| * e^(j * θ_i)

Here, $|H_i|$ represents the **amplitude** attenuation (how much the signal lost strength), and $\theta_i$ represents the **phase** shift (how much the wave's cycle was delayed).

1. **Amplitude**: The amplitude is highly stable and represents the physical blockages in the room. If a human walks between the transmitter and receiver, the amplitude of multiple subcarriers will drop instantly because the human body absorbs RF energy.

2. **Phase**: The phase is extremely sensitive. It measures fractional delays in the arrival time of radio waves. Even a sub-millimeter chest movement during breathing shifts the phase of the reflected wave. Unfortunately, raw phase measurements from commercial Wi-Fi chips (like ESP32) are corrupted by hardware errors.

These hardware errors include Carrier Frequency Offset (CFO)—caused by tiny differences in the clock speeds of the transmitter and receiver—and Sampling Frequency Offset (SFO). These offsets cause the phase to drift rapidly over time. To make phase data useful, RuView implements phase unwrapping and linear phase sanitization algorithms, which remove these linear offsets and extract the true, clean phase shifts caused by environmental movement.

If you're interested in building a node to capture this data yourself, check out our guide on Best ESP32 Boards for CSI.

Understanding Multipath Fading and Human Interaction

Understanding Multipath Fading and Human Interaction

In a typical indoor environment, radio waves reach the receiver via multiple paths. A wave might bounce off the floor, reflect off the ceiling, bounce off a metallic cabinet, and pass through a drywall partition. This is known as **multipath propagation**. When these multiple paths converge at the receiver's antenna, they add constructively or destructively depending on their relative phases. This causes spatial fluctuations in signal strength, known as multipath fading.

In traditional communication systems, multipath fading is a major nuisance that engineers work hard to mitigate. In WiFi sensing, however, multipath fading is a resource. If the environment is completely static, the CSI matrix remains constant. The moment a human body enters the space, it introduces a dynamic path. The length of this dynamic path changes as the person moves.

Because the human body is highly conductive, it reflects a portion of the Wi-Fi signal. As a person walks, their movement creates a Doppler frequency shift in the reflected wave. By taking the short-time Fourier transform (STFT) of the CSI time series, RuView extracts a **Doppler Spectrogram**. This spectrogram displays the velocity of the moving human over time, allowing the system to distinguish between different types of movements (e.g., walking, sitting down, waving hands).

Denoising and Feature Extraction: PCA and Butterworth Filtering

To process CSI at high packet rates (typically 100 to 500 packets per second), we must clean and compress the data. A raw CSI stream from a single ESP32 receiver capturing 64 subcarriers yields 128 variables (amplitude and phase for each subcarrier) per packet. Processing this raw stream directly would overwhelm edge devices like a Raspberry Pi.

RuView's Rust core handles this with a high-performance pipeline:

  • **Bandpass Filtering**: A Butterworth bandpass filter (typically configured between 0.1 Hz and 10 Hz) is applied to target human motion frequencies while discarding high-frequency thermal noise and static DC offsets.
  • **Principal Component Analysis (PCA)**: Because neighboring subcarriers are highly correlated (they experience similar physical blockages), they contain redundant information. PCA reduces the 64 subcarriers down to 3 or 5 principal components that capture over 95% of the variance caused by human motion.
  • **Vitals Extraction**: To extract breathing, a specialized sub-Hz filter (0.15 Hz to 0.4 Hz) is used on the calibrated phase data. By analyzing the periodic phase oscillations, RuView calculates the respiration rate in breaths per minute.

This clean, compressed signal is now ready for deep learning models. For a wider overview of what the platform is capable of with this pipeline, see our Features page.

Neural Network Inference at the Edge

Neural Network Inference at the Edge

Once the signal is filtered and compressed, it is fed into neural networks. RuView supports running these models on a local edge gateway (like a mini PC or Home Assistant yellow) or directly on hardware accelerator modules.

We use two primary neural network architectures:

1. **Convolutional Neural Networks (CNNs)**: CNNs treat a window of CSI amplitude data over time as a 2D image. The network learns spatial-temporal patterns, identifying features like the sudden amplitude drop followed by rapid oscillations characteristic of a human falling down.

2. **Recurrent Neural Networks (LSTMs / GRUs)**: Since CSI is a time-series dataset, LSTMs are excellent at tracking sequential dependencies. They are used to track long-duration events like sleep cycles, walking directions, and continuous presence tracking.

Because these models run locally on the edge gateway, they provide low-latency inference (less than 5ms) and keep all data strictly private. No audio, no video, and no raw RF packets ever leave your local area network (LAN).

To understand the full architecture of this edge pipeline, check out the How It Works Page or join the discussion in the RuView GitHub repository.

FAQ

Can WiFi sensing work through brick walls?

Yes, but range is reduced. 2.4 GHz signals can penetrate drywalls and wooden partitions easily, but concrete or brick walls attenuate the signal more heavily, requiring closer node placement.

How many subcarriers does ESP32 extract?

The ESP32 typically extracts 64 subcarriers on a 20 MHz channel, and up to 128 subcarriers on a 40 MHz channel.

Is the phase data usable without calibration?

No. Raw phase data from cheap oscillators drifts randomly. Linear calibration is required to remove clock offsets.

Explore RuView on GitHub

Browse the Rust engine, ESP32 firmware and examples.

RuView GitHub