Preprint
Article

This version is not peer-reviewed.

Room-Level Occupancy Estimation via Wi-Fi Channel State Information on ESP32 Nodes: A Multi-Zone Experimental Study with Formal CSI–Occupancy Modeling

Submitted:

29 January 2026

Posted:

29 January 2026

You are already at the latest version

Abstract
Room-level occupancy information is essential for demand-driven HVAC control and space utilization analytics, yet conventional solutions rely on PIR or camera systems that require dense instrumentation, line-of-sight, and frequent maintenance. Wi-Fi Channel State Information (CSI) offers a passive alternative: human presence perturbs the multipath structure of wireless channels in ways that can be detected without additional hardware. This paper develops a formal CSI–occupancy modeling framework and validates it experimentally using low-cost ESP32 nodes that expose CSI in the 2.4 GHz band. We model the complex CSI of each link as a superposition of environment-dependent and occupancy-dependent components and cast room-level occupancy estimation as a multi-class classification problem on CSI-derived features. A mathematically defined feature set based on per-subcarrier amplitude statistics, Doppler-band energy, and inter-subcarrier correlation is combined with three lightweight classifiers (logistic regression, gradient boosting, and a compact GRU network). A multi-zone experimental campaign in three residential rooms and one small office zone yields more than 250 hours of labeled data, with room occupancy (0, 1, ≥2 persons) obtained from door sensors and schedule logs. The gradient-boosted model achieves zone-averaged F1-scores of 0.96 for binary occupancy and 0.89 for three-class occupancy, with median inference latency of 38 ms on a Raspberry Pi edge node. Cross-zone transfer experiments and a simple calibration scheme are analyzed, and a theoretical upper bound on achievable accuracy under label noise is derived. The results demonstrate that commodity ESP32-based Wi-Fi infrastructure can support mathematically grounded, room-level occupancy sensing suitable for embedded smart building deployments.
Keywords: 
;  ;  ;  ;  ;  ;  

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, CO2 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 f c with K OFDM subcarriers. The complex CSI on subcarrier k at time t is
H k ( t ) = p = 1 P α p ( t ) e j 2 π f k τ p ( t ) ,
where P is the number of multipath components, α p ( t ) C is the complex gain of path p, f k is the subcarrier frequency, and τ p ( t ) is the path delay [8,12].
We decompose the path gains as
α p ( t ) = α p ( 0 ) + α p ( O ) ( t ) ,
where α p ( 0 ) is the static environment component (walls, furniture) and α p ( O ) ( t ) captures occupancy-dependent contributions (human bodies).

2.2. Occupancy-Dependent CSI

Let O ( t ) denote the room occupancy state at time t, taking values in a finite set O (e.g., { 0 , 1 , 2 } or { 0 , 1 , 2 } ). For a given state o O , we define the corresponding mean CSI vector
μ o = E [ H ( t ) | O ( t ) = o ] C K ,
where H ( t ) = [ H 1 ( t ) , , H K ( t ) ] collects all subcarriers. The occupancy effect can then be written as
H ( t ) = μ O ( t ) + ε ( t ) ,
where ε ( t ) is a zero-mean disturbance capturing small-scale fading, motion, and noise.
A classifier that observes features f ( t ) = g ( H ( t ) ) derived from CSI aims to approximate the Bayes-optimal decision rule
o ^ ( t ) = arg max o O p O ( t ) = o | f ( t ) ,
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 { H k ( n ) } for n = 1 , , N and define amplitude A k ( n ) = | H k ( n ) | and sanitized phase ϕ k ( n ) [23]. We then construct a feature vector f ( t ) R D as follows.
Amplitude statistics.
For each subcarrier k:
μ A , k = 1 N n = 1 N A k ( n ) ,
σ A , k 2 = 1 N n = 1 N ( A k ( n ) μ A , k ) 2 ,
γ A , k = 1 N σ A , k 3 n = 1 N ( A k ( n ) μ A , k ) 3 ,
κ A , k = 1 N σ A , k 4 n = 1 N ( A k ( n ) μ A , k ) 4 3 .
We aggregate across subcarriers by taking averages, e.g.,
μ ¯ A = 1 K k = 1 K μ A , k , σ ¯ A 2 = 1 K k = 1 K σ A , k 2 ,
and similarly for skewness and kurtosis.
Doppler-band energy.
For each subcarrier k, we compute the discrete-time Fourier transform over the window:
S k ( f ) = n = 1 N A k ( n ) e j 2 π f n / N ,
and define low-frequency Doppler energy as
E Doppler = 1 K k = 1 K f F D | S k ( f ) | 2 ,
where F D is a set of low-frequency bins associated with human motion [5,19].
Inter-subcarrier correlation
For adjacent subcarriers,
ρ k , k + 1 = n ( A k ( n ) μ A , k ) ( A k + 1 ( n ) μ A , k + 1 ) n ( A k ( n ) μ A , k ) 2 n ( A k + 1 ( n ) μ A , k + 1 ) 2 ,
and we aggregate via
ρ ¯ = 1 K 1 k = 1 K 1 ρ k , k + 1 .
The full feature vector concatenates these descriptors, i.e.,
f ( t ) = [ μ ¯ A , σ ¯ A 2 , γ ¯ A , κ ¯ A , E Doppler , ρ ¯ , ] R D .

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 K = 30 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 O O = { 0 , 1 , 2 } , representing empty, single occupant, and multiple occupants ( 2 ), respectively. Ground truth is derived from door contact sensors and schedule logs; we assume label noise probability η < 0.1 due to occasional misalignment, which will be used later for a theoretical bound.

3.3. Classification Problem

Given feature vectors f ( t ) and labels O ( t ) , we seek a classifier h : R D O that approximates Eq. (5). We consider:
Logistic regression.
p ( O = o | f ) = exp ( w o f + b o ) o O exp ( w o f + b o ) ,
with cross-entropy loss.
Gradient boosting (XGBoost).
An ensemble of T regression trees approximating the log-odds:
F o ( f ) = t = 1 T f t , o ( f ) ,
and
p ( O = o | f ) = exp ( F o ( f ) ) o exp ( F o ( f ) ) .
Compact GRU.
A GRU processes a sequence of coarse per-second features { z τ } τ = 1 T W within the 30 s window:
h τ = GRU ( z τ , h τ 1 ) , p ( O = o | { z τ } ) = softmax ( W h T W + b ) .

3.4. Performance Metrics

For each class o, we compute precision, recall, and F1-score:
Precision o = TP o TP o + FP o ,
Recall o = TP o TP o + FN o ,
F 1 o = 2 · Precision o · Recall o Precision o + Recall o .
We report macro-averaged F1:
F 1 macro = 1 | O | o O F 1 o .

4. Results

4.1. Binary Occupancy

For binary occupancy O { 0 , occ } where occ merges 1 and 2, XGBoost achieves zone-averaged F 1 macro 0.96 , with precision and recall above 0.95 for both classes. Logistic regression reaches F 1 macro 0.92 , 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 F 1 macro 0.89 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, F 1 macro 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 F 1 macro 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
A max 1 η .
With our estimated η < 0.1 from door-sensor comparisons, the ceiling is A max 0.9 for three-class classification. The observed macro-F1 of 0.89 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

  1. 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]
  2. 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]
  3. 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]
  4. 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]
  5. 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]
  6. Liu, J. Tracking vital signs during sleep leveraging off-the-shelf WiFi. Proc. ACM MobiSys, 2015; pp. 267–279. [Google Scholar] [CrossRef]
  7. Zhang, Y. WiDAR: Decimeter-level passive tracking via Wi-Fi. IEEE Trans. Mobile Comput. 2021, 20(11), 3144–3159. [Google Scholar] [CrossRef]
  8. 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]
  9. Chen, T.; Guestrin, C. XGBoost: A scalable tree boosting system. Proc. ACM SIGKDD, 2016; pp. 785–794. [Google Scholar] [CrossRef]
  10. 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]
  11. 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]
  12. Ma, Y.; Zhou, G.; Wang, S. Wi-Fi sensing: applications and challenges. Journal of Engineering 2019, 2019(3), 88–97. [Google Scholar] [CrossRef]
  13. 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]
  14. Choi, B. J. Enabling Ubiquitous Occupancy Detection in Smart Buildings. Proc. ACM BuildSys, 2023. [Google Scholar]
  15. Chen, Y. Spatio-Temporal 3D Point Clouds from Wi-Fi-CSI Data via Transformer Networks. IEEE Trans. Mobile Comput., 2025. [Google Scholar]
  16. Yildirim, A. Geometry-Aware Deep Subdomain Adaptation for Robust Wi-Fi CSI Indoor Localization. Selçuk Univ. J. Eng. Sci., 2026. [Google Scholar]
  17. 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]
  18. Li, Y. Human Activity Recognition via Wi-Fi CSI and VAE-CNN-BiLSTM Hybrid Deep Learning. IEEE Sensors Journal 2024. [Google Scholar] [CrossRef]
  19. Wang, C. Wi-Fi CSI based Behavior Recognition: From Signals, Actions to Activities. arXiv 2017, arXiv:1712.00146. [Google Scholar] [CrossRef]
  20. Li, X. EfficientFi: Towards Large-Scale Lightweight WiFi Sensing via CSI Compression. arXiv 2022, arXiv:2204.04138. [Google Scholar]
  21. Sun, Y. Robust Cross-Scenario WiFi Wireless Sensing Using Multi-Source Data Fusion. In IEEE Trans. Mobile Comput.; 2025. [Google Scholar]
  22. Wireless Broadband Alliance, Smart Campus Wi-Fi CSI Sensing Development and Use Cases. In White Paper; 2025.
  23. Gong, T. Optimal preprocessing of WiFi CSI for sensing applications. arXiv 2023, arXiv:2307.12126. [Google Scholar] [CrossRef]
  24. 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]
  25. 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.
Copyright: This open access article is published under a Creative Commons CC BY 4.0 license, which permit the free download, distribution, and reuse, provided that the author and preprint are cited in any reuse.
Prerpints.org logo

Preprints.org is a free preprint server supported by MDPI in Basel, Switzerland.

Subscribe

Disclaimer

Terms of Use

Privacy Policy

Privacy Settings

© 2026 MDPI (Basel, Switzerland) unless otherwise stated