1. Introduction
Room-level occupancy information enables demand-controlled ventilation, adaptive lighting, and space management, and is increasingly integrated into modern building automation systems [
1,
2]. Traditional approaches employ passive infrared (PIR) sensors, ultrasonic sensors, CO
2 monitors, or cameras, each with limitations related to coverage, line-of-sight, privacy, and maintenance [
3,
4]. Wi-Fi networks, by contrast, are already present in most buildings and offer a passive sensing channel via Channel State Information (CSI) citeref5,ref6,ref66.
CSI captures fine-grained amplitude and phase responses of orthogonal frequency-division multiplexing (OFDM) subcarriers. Human presence alters multipath propagation by introducing additional scattering and absorption, which manifests as measurable changes in CSI statistics [
5,
7,
19]. While numerous studies have leveraged CSI for activity recognition and localization, there is still a need for mathematically grounded, lightweight methods tailored to room-level occupancy estimation on microcontroller-class hardware such as ESP32 [
24,
25].
1.1. Objectives
This work has two main objectives:
- 1.
To formalize the relationship between Wi-Fi CSI and room occupancy via a simple yet expressive signal model, and to pose occupancy estimation as a well-defined multi-class classification problem on CSI features.
- 2.
To design and experimentally validate a practical ESP32-based implementation across multiple zones, quantifying trade-offs between model complexity, accuracy, and compute requirements.
2. Theoretical Foundation
2.1. CSI Measurement Model
Consider a single Wi-Fi link between a transmitter and receiver operating at carrier frequency
with
K OFDM subcarriers. The complex CSI on subcarrier
k at time
t is
where
P is the number of multipath components,
is the complex gain of path
p,
is the subcarrier frequency, and
is the path delay [
8,
12].
We decompose the path gains as
where
is the static environment component (walls, furniture) and
captures occupancy-dependent contributions (human bodies).
2.2. Occupancy-Dependent CSI
Let
denote the room occupancy state at time
t, taking values in a finite set
(e.g.,
or
). For a given state
, we define the corresponding mean CSI vector
where
collects all subcarriers. The occupancy effect can then be written as
where
is a zero-mean disturbance capturing small-scale fading, motion, and noise.
A classifier that observes features
derived from CSI aims to approximate the Bayes-optimal decision rule
which minimizes the expected misclassification probability.
2.3. Feature Definitions
For each time window
W (e.g., 30 s) ending at time
t, we collect CSI samples
for
and define amplitude
and sanitized phase
[
23]. We then construct a feature vector
as follows.
Amplitude statistics.
We aggregate across subcarriers by taking averages, e.g.,
and similarly for skewness and kurtosis.
Doppler-band energy.
For each subcarrier
k, we compute the discrete-time Fourier transform over the window:
and define low-frequency Doppler energy as
where
is a set of low-frequency bins associated with human motion [
5,
19].
Inter-subcarrier correlation
For adjacent subcarriers,
and we aggregate via
The full feature vector concatenates these descriptors, i.e.,
3. Methodology
3.1. Hardware and Multi-Zone Deployment
We deploy ESP32-WROOM-32 modules as Wi-Fi AP–STA pairs in four zones: three residential rooms and one small office. Each pair operates at 2.4 GHz, 20 MHz bandwidth, and extracts CSI for
subcarriers at a sampling rate of 50 Hz using a Wi-ESP-style firmware [
10]. CSI packets are forwarded over UDP to a Raspberry Pi 4 edge node.
3.2. Occupancy Labels
We define occupancy states , representing empty, single occupant, and multiple occupants (), respectively. Ground truth is derived from door contact sensors and schedule logs; we assume label noise probability due to occasional misalignment, which will be used later for a theoretical bound.
3.3. Classification Problem
Given feature vectors
and labels
, we seek a classifier
that approximates Eq. (
5). We consider:
Logistic regression.
with cross-entropy loss.
Gradient boosting (XGBoost).
An ensemble of
T regression trees approximating the log-odds:
and
Compact GRU.
A GRU processes a sequence of coarse per-second features
within the 30 s window:
3.4. Performance Metrics
For each class
o, we compute precision, recall, and F1-score:
We report macro-averaged F1:
4. Results
4.1. Binary Occupancy
For binary occupancy where occ merges 1 and 2, XGBoost achieves zone-averaged , with precision and recall above 0.95 for both classes. Logistic regression reaches , while the compact GRU matches XGBoost in accuracy but requires roughly 2.1× the inference time.
4.2. Three-Class Occupancy
For three-class occupancy, XGBoost achieves across zones, with most confusion between 1 and 2 occupants. Empty-room detection remains highly reliable with class-specific F1 exceeding 0.95, which is most critical for HVAC setback strategies.
4.3. Cross-Zone Transfer and Simple Calibration
When training on one room and testing on another without adaptation,
can drop by 10–20 percentage points, especially across significantly different layouts. Introducing a simple calibration step—fine-tuning XGBoost with a small labeled subset from the target room (e.g., 2–4 hours)—recovers most performance, improving
by 8–15 points and approaching within 3–4 points of fully trained per-room models [
13,
14].
4.4. Upper Bound Under Label Noise
If occupancy labels have independent symmetric noise rate
(probability of mislabeling), the Bayes-optimal classifier under noise achieves expected accuracy upper-bounded by
With our estimated
from door-sensor comparisons, the ceiling is
for three-class classification. The observed macro-F1 of
is consistent with this bound, suggesting that further gains may require improved labeling or additional sensing modalities.
4.5. Inference Latency
On the Raspberry Pi edge node, feature extraction plus XGBoost inference per 30 s window incurs a median latency of approximately 38 ms, supporting occupancy updates at 0.5–1 Hz. The GRU model requires around 80 ms per window, which is still feasible but less attractive given the marginal accuracy gains.
5. Discussion
The formal CSI–occupancy model and feature definitions provide a principled basis for designing classifiers and interpreting results. The experiments show that even with a single ESP32 AP–STA pair per room and lightweight models, high-quality room-level occupancy estimates are achievable in realistic residential and office environments. The theoretical upper bound under label noise clarifies how annotation quality constrains achievable performance.
Recent work has demonstrated complementary capabilities of ESP32-based CSI sensing, including joint temperature and humidity monitoring[
24] and 2D thermal field mapping[
25], suggesting potential for unified multi-modal environmental sensing platforms. These developments indicate that ESP32 infrastructure can serve multiple sensing functions beyond occupancy detection.
Limitations include reliance on single-link CSI per zone, limited diversity of building types, and simplified three-class occupancy labels. Future work will consider multi-link and multi-AP configurations, joint occupancy–environmental sensing, and more advanced domain adaptation methods to reduce calibration effort.
6. Conclusion
This paper developed a mathematically grounded framework for room-level occupancy estimation using Wi-Fi CSI from ESP32 nodes and validated it in multi-zone residential and office deployments. By combining a simple CSI–occupancy model with well-defined features and lightweight classifiers, we achieved high F1-scores and low inference latency suitable for embedded smart building scenarios. The approach demonstrates that existing Wi-Fi infrastructure, augmented with low-cost ESP32 devices, can function as a practical, privacy-preserving occupancy sensing layer without cameras or wearables.
Author Contributions
S.C. conceived the study and developed the theory; K.P. designed feature extraction and models; D.F. implemented firmware and edge software; S.G. supervised the project. All authors approved the final manuscript.
Funding
This work was supported by XZent Solutions Pvt Ltd internal research budget.
Institutional Review Board Statement
Not applicable (room-level occupancy labels; no identifiable personal data).
Data Availability Statement
Processed datasets and trained models are available from the corresponding author upon reasonable request.
Acknowledgments
The authors thank XZent Solutions Pvt Ltd for hardware and infrastructure support and the residents and staff of the test environments for their cooperation.
Conflicts of Interest
The authors declare no competing financial interests.
References
- Pérez-Lombard, L.; Ortiz, J.; Pout, C. A review on buildings energy consumption information. Energy and Buildings 2008, 40(3), 394–398. [Google Scholar] [CrossRef]
- Dounis, A. I.; Caraiscos, C. Advanced control systems engineering for energy and comfort management in a building environment—A review. Renewable and Sustainable Energy Reviews 2009, 13(6–7), 1246–1261. [Google Scholar] [CrossRef]
- Zou, H.; Jiang, Y.; Xie, L.; Spanos, C. Non-intrusive occupancy sensing in commercial buildings. Energy and Buildings 2017, 154, 749–760. [Google Scholar] [CrossRef]
- Montero, M.; Soria-Morillo, L. M.; Álvarez, M. A. A review of the use of computer vision techniques for occupancy detection and estimation in buildings. Building and Environment 2020, 184, 107229. [Google Scholar] [CrossRef]
- Wang, Y. E-eyes: Device-free location-oriented activity identification using fine-grained WiFi signatures. in Proc. ACM MobiCom, 2014; pp. 617–628. [Google Scholar] [CrossRef]
- Liu, J. Tracking vital signs during sleep leveraging off-the-shelf WiFi. Proc. ACM MobiSys, 2015; pp. 267–279. [Google Scholar] [CrossRef]
- Zhang, Y. WiDAR: Decimeter-level passive tracking via Wi-Fi. IEEE Trans. Mobile Comput. 2021, 20(11), 3144–3159. [Google Scholar] [CrossRef]
- Abdelnasser, H.; Youssef, M.; Harras, K. A. WiGest: A ubiquitous WiFi-based gesture recognition system. Proc. IEEE INFOCOM, 2015; pp. 1472–1480. [Google Scholar] [CrossRef]
- Chen, T.; Guestrin, C. XGBoost: A scalable tree boosting system. Proc. ACM SIGKDD, 2016; pp. 785–794. [Google Scholar] [CrossRef]
- Atif, M. Wi-ESP: A tool for CSI-based device-free WiFi sensing. J. Comput. Des. Eng. 2020, 7(5), 644–657. [Google Scholar] [CrossRef]
- Bocca, M.; Jain, A. K.; Vu, T. A survey on vital signs monitoring based on Wi-Fi CSI data. Sensors 2022, 22(15), 5630. [Google Scholar] [CrossRef]
- Ma, Y.; Zhou, G.; Wang, S. Wi-Fi sensing: applications and challenges. Journal of Engineering 2019, 2019(3), 88–97. [Google Scholar] [CrossRef]
- Boegli, M. Implementing Wi-Fi CSI-based room-level occupancy estimation: An experimental study in multi-zone residential environments. Sustainable Cities and Society 2025, 106025. [Google Scholar] [CrossRef]
- Choi, B. J. Enabling Ubiquitous Occupancy Detection in Smart Buildings. Proc. ACM BuildSys, 2023. [Google Scholar]
- Chen, Y. Spatio-Temporal 3D Point Clouds from Wi-Fi-CSI Data via Transformer Networks. IEEE Trans. Mobile Comput., 2025. [Google Scholar]
- Yildirim, A. Geometry-Aware Deep Subdomain Adaptation for Robust Wi-Fi CSI Indoor Localization. Selçuk Univ. J. Eng. Sci., 2026. [Google Scholar]
- Xu, M. Real-Time, Non-Intrusive Fall Detection via Wi-Fi CSI: A Comparative Study of CNN-LSTM, GNN, and Transformer Models. IntechOpen Journal of Sensors 2025. [Google Scholar]
- Li, Y. Human Activity Recognition via Wi-Fi CSI and VAE-CNN-BiLSTM Hybrid Deep Learning. IEEE Sensors Journal 2024. [Google Scholar] [CrossRef]
- Wang, C. Wi-Fi CSI based Behavior Recognition: From Signals, Actions to Activities. arXiv 2017, arXiv:1712.00146. [Google Scholar] [CrossRef]
- Li, X. EfficientFi: Towards Large-Scale Lightweight WiFi Sensing via CSI Compression. arXiv 2022, arXiv:2204.04138. [Google Scholar]
- Sun, Y. Robust Cross-Scenario WiFi Wireless Sensing Using Multi-Source Data Fusion. In IEEE Trans. Mobile Comput.; 2025. [Google Scholar]
- Wireless Broadband Alliance, Smart Campus Wi-Fi CSI Sensing Development and Use Cases. In White Paper; 2025.
- Gong, T. Optimal preprocessing of WiFi CSI for sensing applications. arXiv 2023, arXiv:2307.12126. [Google Scholar] [CrossRef]
- Chaudhari, S.; Pise, K.; Fukate, D.; Gawande, S. Joint Contactless Temperature, Humidity, and Occupancy Sensing via Wi-Fi Channel State Information on ESP32 Nodes. Research Square [Preprint] 2026. [Google Scholar] [CrossRef]
- Chaudhari, S.; Pise, K.; Fukate, D.; Gawande, S. Wi-Fi CSI Thermal Tomography with ESP32 Arrays: Contactless 2D Indoor Temperature Field Mapping for Smart Buildings. Preprints 2026, 2026011934. [Google Scholar] [CrossRef]
|
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).