Esp32 WiFi CSI Human Sensing | Realtime-Time Postion Estimation

Esp32 WiFi CSI Human Sensing | Realtime-Time Postion Estimation

Wi-Fi CSI Human Sensing and Real-Time Position Estimation

Date Published
September 1, 2026
Tech Stack
PythonC++MLArduino

Wi-Fi CSI Human Sensing and Real-Time Position Estimation

Project Overview

Wi-Fi CSI Human Sensing is an experimental AI and Data Science project that uses two ESP32 DevKit V1 boards, Wi-Fi Channel State Information (CSI), signal processing, and machine learning to detect human presence and estimate a person's position in real time.

The system turns changes in Wi-Fi signals into structured sensor data and feeds the extracted features into machine learning models running on a Mac. The final application displays the estimated position of a person as a moving dot between two ESP32 sensors.

The project combines:

  • Artificial Intelligence
  • Machine Learning
  • Data Science
  • Wireless sensing
  • Wi-Fi Channel State Information
  • Signal processing
  • Feature engineering
  • Dataset engineering
  • Neural networks
  • Real-time inference
  • Embedded systems
  • ESP32 development
  • Python
  • Arduino
  • Computer-based visualization

The Idea

Traditional motion and presence detection systems often depend on dedicated sensors such as cameras, PIR sensors, radar, or ultrasonic sensors.

This project explores a different approach:

Can changes in Wi-Fi signals be used to detect and track a person without using a camera?

Two ESP32 boards create a sensing link across a room.

ESP32 #1                         ESP32 #2
Wi-Fi AP                         CSI Receiver
   📡 ───────────────────────────── 📡
             Wi-Fi link
                  │
                  │
                 👤
             Human movement
                  │
                  ↓
           CSI channel changes
                  │
                  ↓
               Python
                  │
                  ↓
        Feature extraction
                  │
                  ↓
          Machine Learning
                  │
                  ↓
       Real-time prediction
                  │
                  ↓
                🔵
          Estimated position

The first version focuses on two tasks:

  1. Human presence detection
  2. One-dimensional position estimation

The position is represented as a normalized value between the two ESP32 devices.

0.0                                           1.0
ESP32 #1 ───────────────────────────────── ESP32 #2
              ↑
              🔵
           Person

Hardware

The prototype uses:

  • 2 × ESP32 DevKit V1
  • Mac computer for data processing and machine learning
  • USB connections between the ESP32 boards and the Mac
  • Existing Wi-Fi environment for experimentation

The two ESP32 boards have different roles.

ESP32 #1, Access Point

The first ESP32 operates as the Wi-Fi access point.

Its responsibilities include:

  • Creating the Wi-Fi network
  • Maintaining the wireless connection
  • Generating wireless traffic
  • Monitoring connected stations
  • Providing the wireless channel used by the sensing system

ESP32 #2, CSI Receiver

The second ESP32 connects to the first ESP32 as a Wi-Fi station.

Its responsibilities include:

  • Receiving Wi-Fi packets
  • Capturing CSI information
  • Extracting CSI metadata
  • Recording RSSI and packet information
  • Sending CSI data to the Mac over USB serial

Technology Stack

Embedded

  • ESP32 DevKit V1
  • Arduino
  • ESP32 Wi-Fi
  • Wi-Fi CSI
  • RSSI
  • Serial communication

Data Science

  • Python
  • NumPy
  • Pandas
  • Scikit-learn
  • Feature engineering
  • Data preprocessing
  • Dataset validation
  • Model evaluation

Machine Learning

The project compares multiple machine learning approaches:

  • K-Nearest Neighbors
  • Random Forest
  • Neural Network

The system automatically compares model performance and selects the strongest model for the current dataset.

Development

  • Git
  • GitHub
  • Python virtual environment
  • Arduino IDE
  • macOS
  • CSV datasets

How Wi-Fi CSI Is Used

Channel State Information (CSI) describes how a wireless signal changes while traveling between a transmitter and receiver.

Objects and people inside the wireless path affect the signal through:

  • Reflection
  • Absorption
  • Diffraction
  • Multipath propagation
  • Body movement
  • Changes in the wireless channel

A person moving through the sensing area changes the CSI measurements.

The project captures those changes and converts them into numerical features.

Wireless environment
        ↓
Wi-Fi transmission
        ↓
CSI measurement
        ↓
Raw CSI samples
        ↓
Preprocessing
        ↓
Feature extraction
        ↓
Machine learning
        ↓
Human presence
        ↓
Estimated position

Data Collection Pipeline

One of the biggest parts of the project was building the complete data pipeline.

The ESP32 receiver sends CSI measurements through USB serial to the Mac.

Python records the raw measurements into CSV files.

Example:

data/
├── raw/
│   ├── 20260901_171249_empty_static.csv
│   ├── ...
│
└── processed/
    └── dataset.csv

The raw dataset preserves the original sensor measurements.

The processing pipeline then converts the raw CSI information into machine-learning features.

CSI Parsing and Preprocessing

During development, the first dataset-generation attempt produced raw samples but zero feature rows.

The investigation revealed a CSI format mismatch.

The real ESP32 output contained:

csi_len = 256
first_word_invalid = 1

while the initial Python preprocessing pipeline expected a different CSI representation.

The result was:

Raw samples
    ↓
CSI parser
    ↓
Validation rejected packets
    ↓
0 feature rows

The issue was fixed by aligning the parser and preprocessing pipeline with the actual CSI format emitted by the ESP32 firmware.

After the fix, the same collection pipeline successfully produced feature rows:

raw samples : 1194
malformed    : 0
io errors    : 0
feature rows : 291

The processed dataset then received the generated feature rows.

This debugging process was an important part of the project because it demonstrated the complete sensor-to-dataset workflow rather than relying on synthetic data.

Feature Engineering

The raw CSI measurements are not directly fed into the final model.

The pipeline transforms raw wireless measurements into structured numerical features.

The processed dataset currently contains:

180 feature columns

The feature extraction stage converts the temporal CSI measurements into values suitable for machine learning.

The processing pipeline follows:

Raw CSI
  ↓
Packet validation
  ↓
CSI parsing
  ↓
Signal preprocessing
  ↓
Temporal windowing
  ↓
Feature extraction
  ↓
180-dimensional feature vector

Dataset Design

The dataset contains multiple sensing conditions.

Examples include:

  • Empty room
  • Person standing still
  • Person moving
  • Person at approximately 0.25 normalized position
  • Person at approximately 0.50 normalized position
  • Person at approximately 0.75 normalized position

The project uses separate collection sessions instead of treating the entire recording as one homogeneous dataset.

This helps capture changes between sessions and makes evaluation more realistic.

Machine Learning Pipeline

The machine learning pipeline contains two prediction tasks.

1. Presence Classification

The classifier predicts whether a person is present.

CSI features
     ↓
Neural Network
     ↓
PERSON / EMPTY

The system also produces a probability for the prediction.

Example:

presence: PERSON
P(person): 1.0

2. Position Regression

When a person is detected, the second model estimates their normalized position between the two ESP32 devices.

CSI features
     ↓
Neural Network
     ↓
Position = 0.37

The live system can then visualize the result:

ESP32 #1 ───────────────────────────── ESP32 #2
              🔵
             0.37

Model Comparison

The project does not assume a single machine learning algorithm will perform best.

Multiple models are trained and evaluated.

Presence Classification

Model Validation Accuracy Validation Precision Validation Recall Validation F1
KNN 70.4% 65.0% 90.4% 75.6%
Random Forest 75.6% 68.3% 97.0% 80.2%
Neural Network 84.8% 80.8% 92.1% 86.1%

The Neural Network performed best on the validation comparison and was selected for presence inference.

Presence Test Results

The selected Neural Network achieved:

Metric Test Result
Accuracy 85.3%
Precision 88.7%
Recall 89.3%
F1 Score 89.0%

These results demonstrate that the model learned useful patterns from real Wi-Fi CSI measurements for human presence detection.

Position Regression Results

The project also compares three regression models.

Model Validation MAE Validation RMSE Validation R²
KNN 0.350 0.363 -59.127
Random Forest 0.358 0.372 -62.061
Neural Network 0.273 0.287 -36.474

The Neural Network was selected for the position regression task.

The test results were:

Metric Test Result
MAE 0.063
RMSE 0.078
0.000

The position model showed useful behavior during live experiments, including movement of the estimated position along the sensing line.

The current dataset is still too small and concentrated around a limited number of positions to claim highly accurate generalized localization. More independent sessions and position coverage are required for a stronger evaluation.

Real-Time Inference

After training, the model runs locally on the Mac.

The inference pipeline continuously receives CSI measurements and processes them in real time.

ESP32 CSI
    ↓
USB Serial
    ↓
Python serial receiver
    ↓
CSI parser
    ↓
Feature extraction
    ↓
Trained models
    ↓
Presence prediction
    ↓
Position prediction
    ↓
Filtering
    ↓
Real-time visualization

Example inference output:

presence: PERSON
P(person)=1.0

movement: STATIC
P(movement)=0.12

position_filtered: 0.2495
position_raw: 0.2488
confidence: 1.0

latency_ms: 36.0

The system therefore performs the complete process from physical wireless sensing to machine learning inference in real time.

Position Visualization

The current visualization represents the room as a one-dimensional sensing line.

ESP32 #1                                      ESP32 #2
   📡──────────────────🔵──────────────────────📡
                         0.50

When the person moves, the predicted dot moves accordingly.

The current system does not attempt to identify multiple people or provide full 2D coordinates.

The first goal was to prove that a pair of ESP32 devices could produce useful real-time human sensing information.

Environmental Noise and Wi-Fi Interference

The experiment runs inside a normal Wi-Fi environment rather than an isolated laboratory.

Other devices such as:

  • Home Wi-Fi router
  • Mac
  • Phone
  • Other connected devices

can change the wireless environment.

This makes the problem more difficult because CSI measurements depend on the surrounding RF environment.

The project therefore treats environmental variation as an important part of future experimentation.

A useful future experiment is to compare:

Normal Wi-Fi environment
        VS
Controlled Wi-Fi environment

and measure changes in:

  • Presence F1 score
  • Position MAE
  • Position RMSE
  • CSI variance
  • Prediction stability
  • Inference latency

Challenges Solved

CSI Format Compatibility

The first major issue occurred because the Python pipeline expected a different CSI representation from the actual ESP32 output.

The raw data was arriving correctly, but preprocessing rejected the packets.

The parser was updated to understand the actual CSI format.

Serial Data Pipeline

The system required reliable high-speed serial communication between the ESP32 receiver and the Mac.

The final data collection process operates at:

921600 baud

and successfully records thousands of raw CSI samples.

Dataset Generation

The project initially produced:

1194 raw samples
0 feature rows

After debugging:

1194 raw samples
291 feature rows

This confirmed the complete raw-to-feature pipeline was functioning.

Model Selection

Instead of selecting a model based on assumptions, KNN, Random Forest, and Neural Network models were evaluated against the collected data.

The Neural Network performed best for both presence classification and position regression in the current experiment.

Project Architecture

┌──────────────────────┐
│ ESP32 DevKit V1 #1   │
│ Wi-Fi Access Point   │
└──────────┬───────────┘
           │
           │ Wi-Fi
           │
           ▼
┌──────────────────────┐
│ ESP32 DevKit V1 #2   │
│ CSI Receiver         │
└──────────┬───────────┘
           │
           │ USB Serial
           │
           ▼
┌──────────────────────┐
│ Python Data Pipeline │
│                      │
│ Parser               │
│ Preprocessing        │
│ Feature Extraction   │
└──────────┬───────────┘
           │
           ▼
┌──────────────────────┐
│ Processed Dataset    │
│ 180 Features         │
└──────────┬───────────┘
           │
           ▼
┌──────────────────────┐
│ Machine Learning     │
│                      │
│ KNN                  │
│ Random Forest        │
│ Neural Network       │
└──────────┬───────────┘
           │
           ▼
┌──────────────────────┐
│ Real-Time Inference  │
│                      │
│ Presence             │
│ Movement             │
│ Position             │
└──────────┬───────────┘
           │
           ▼
        🔵 Live
      Position

Data Science Workflow

The project follows a complete applied Data Science workflow:

Problem definition
       ↓
Hardware design
       ↓
Sensor data acquisition
       ↓
Raw data collection
       ↓
Data validation
       ↓
Data preprocessing
       ↓
Feature engineering
       ↓
Dataset construction
       ↓
Model training
       ↓
Model comparison
       ↓
Validation
       ↓
Testing
       ↓
Real-time inference
       ↓
Live evaluation

This makes the project a practical example of combining Data Science, Machine Learning, embedded systems, wireless sensing, and real-time AI inference.

Current Results

The current prototype demonstrates:

  • Real Wi-Fi CSI acquisition
  • Real-time CSI streaming
  • Raw CSI recording
  • Automated dataset generation
  • 180-dimensional feature extraction
  • Human presence classification
  • Movement classification
  • Position regression
  • Neural Network model training
  • Real-time inference
  • Live position visualization
  • Approximately 36 ms inference latency in a test run

The presence model currently achieves:

85.3% test accuracy and 89.0% F1 score.

The position model produces useful live movement estimates, although additional data is required for robust generalized localization.

Future Improvements

The project is designed to grow beyond the initial two-sensor prototype.

Larger Dataset

Collect more independent sessions across:

  • More positions
  • Different people
  • Different movement speeds
  • Different body orientations
  • Different room conditions
  • Different distances between ESP32 devices

Better Position Estimation

Increase position coverage:

0.00
0.10
0.20
0.30
0.40
0.50
0.60
0.70
0.80
0.90
1.00

This should give the regression model a much richer representation of the wireless channel.

Temporal Machine Learning

Future versions can incorporate temporal models such as:

  • 1D CNN
  • LSTM
  • GRU
  • Temporal Neural Networks

Instead of using only individual feature windows, these models could learn patterns across time.

2D Localization

The current prototype estimates position along one dimension.

A future version could use additional ESP32 sensing links to estimate two-dimensional coordinates.

        ESP32
          📡
           \
            \
             🔵
            /  \
           /    \
         📡      📡
      ESP32      ESP32

Multi-Person Detection

A future version could investigate whether multiple people can be detected and separated using multiple CSI links and richer temporal features.

Robust Environmental Adaptation

Future experiments will investigate:

  • Wi-Fi interference
  • Room geometry
  • Furniture changes
  • Different routers
  • Different wireless channels
  • Sensor placement
  • Human body orientation
  • Environmental calibration

What I Learned

This project provided hands-on experience with the full lifecycle of a real-world machine learning system.

Key areas include:

  • Wireless sensor data acquisition
  • ESP32 embedded development
  • Wi-Fi CSI
  • Serial communication
  • Data cleaning
  • Signal preprocessing
  • Feature engineering
  • Dataset design
  • Machine learning
  • Neural networks
  • Classification
  • Regression
  • Model comparison
  • Evaluation metrics
  • Real-time inference
  • Debugging hardware-to-software pipelines

One of the most important lessons was that machine learning performance depends heavily on the quality and diversity of the data collection process.

A model cannot learn reliable physical localization from a dataset with insufficient position coverage.

Project Status

Status: Working Prototype

The current system successfully performs real-time Wi-Fi CSI sensing using two ESP32 DevKit V1 boards.

The first milestone focuses on proving the complete sensing and AI pipeline.

Future versions will focus on improving localization accuracy, expanding the dataset, handling environmental variation, and eventually moving toward two-dimensional and multi-person sensing.

Keywords

Wi-Fi CSI · Channel State Information · Wi-Fi Sensing · Human Sensing · Human Presence Detection · Human Localization · Indoor Positioning · ESP32 · ESP32 DevKit V1 · Machine Learning · Artificial Intelligence · Data Science · Neural Networks · Signal Processing · Feature Engineering · Real-Time AI · Python · Arduino · Embedded Systems · Wireless Sensing · CSI-based Localization · Indoor Human Tracking