Smart Human Presence Detection using WiFi RSSI and Machine Learning on ESP32

Mahendra Mali
MCA, SPCE, Sankalchand Patel University (SPU)
Email: mahendrakumargahelot@gmail.com
Guide: Vishal Sharma

Abstract

This research presents a comprehensive study on a novel, low-cost approach to human presence detection using WiFi Received Signal Strength Indicator (RSSI) and machine learning implemented on the ESP32 microcontroller. Traditional presence detection systems typically rely on cameras, passive infrared (PIR) sensors, or ultrasonic detectors, which often raise privacy concerns, require significant power consumption, or have limited detection capabilities. Our proposed method leverages the inherent variations in WiFi signal strength caused by human presence in indoor environments, offering a privacy-preserving and energy-efficient alternative.

The system architecture employs an ESP32 microcontroller running MicroPython for real-time data collection and processing. RSSI values from nearby WiFi access points are continuously monitored and logged to an SD card. Two distinct datasets are collected: one representing an empty room scenario and another with human presence. These datasets are then analyzed using Python-based machine learning tools in a Jupyter Notebook environment, where statistical features (minimum, maximum, mean, and standard deviation of RSSI values) are extracted and used to train a logistic regression classifier.

Experimental results demonstrate that our approach achieves over 95% accuracy in controlled indoor environments, with detection latency between 1-2 seconds. The system's performance is evaluated under various conditions, including different room sizes, multiple access point configurations, and varying human movement patterns. The final implementation includes real-time classification on the ESP32, visual feedback via an OLED display, and auditory alerts through a buzzer. This research contributes to the growing field of contactless sensing and demonstrates the practical viability of RSSI-based presence detection for smart home applications, security systems, and energy management solutions.

Keywords: ESP32, WiFi RSSI, Human Presence Detection, Machine Learning, MicroPython, IoT, Contactless Sensing, Indoor Localization, Smart Environments

1. Introduction

The detection of human presence has become a fundamental requirement in various applications ranging from home automation and smart surveillance to cybersecurity and energy management systems. Traditional approaches to presence detection typically employ passive infrared (PIR) sensors, ultrasonic detectors, or camera-based systems. While these methods have proven effective in many scenarios, they present several limitations including privacy concerns (in the case of cameras), high power consumption, and limited detection capabilities in certain environmental conditions.

Recent advancements in wireless signal processing and machine learning have opened new possibilities for human presence detection using existing WiFi infrastructure. The human body, composed primarily of water, interacts with electromagnetic waves in the 2.4GHz and 5GHz bands used by WiFi networks. This interaction causes measurable disturbances in signal propagation characteristics, particularly in the Received Signal Strength Indicator (RSSI), which can be leveraged for presence detection.

This paper presents a comprehensive study on the development and implementation of a WiFi RSSI-based human presence detection system using the ESP32 microcontroller. The ESP32 was selected for this research due to its integrated WiFi capabilities, low power consumption, and cost-effectiveness, making it ideal for IoT applications. The system employs machine learning techniques to analyze RSSI variations and distinguish between occupied and unoccupied states of a room or defined space.

The primary contributions of this work include:

The remainder of this paper is organized as follows: Section 2 reviews related work in the field of RSSI-based sensing and presence detection. Section 3 details the system architecture and methodology. Section 4 presents the experimental results and performance evaluation. Section 5 discusses potential applications and practical considerations. Section 6 outlines the advantages of the proposed approach. Section 7 discusses limitations and future work directions. Finally, Section 8 concludes the paper.

2. Literature Review

The use of wireless signals for human presence detection and activity recognition has gained significant attention in recent years. This section provides an overview of existing approaches and their limitations, followed by a discussion of WiFi-based sensing techniques.

2.1 Traditional Presence Detection Methods

Traditional presence detection systems can be broadly categorized into three main types:

Vision-based systems: These systems employ cameras and computer vision algorithms to detect human presence. While effective, they raise significant privacy concerns and require substantial computational resources for image processing. Additionally, their performance degrades in low-light conditions and they often require careful positioning to avoid blind spots.

Infrared-based systems: Passive infrared (PIR) sensors detect changes in infrared radiation caused by human body heat. These sensors are widely used in motion-activated lighting systems but have several limitations. They can only detect moving subjects, have a limited field of view, and are sensitive to environmental temperature changes.

Ultrasonic and microwave sensors: These active sensors emit high-frequency sound waves or microwaves and detect reflections from moving objects. While they can detect stationary subjects better than PIR sensors, they consume more power and may interfere with other electronic devices.

2.2 WiFi-Based Sensing

The concept of using WiFi signals for sensing applications has emerged as a promising alternative to traditional methods. The foundation of WiFi-based sensing lies in the fact that wireless signals are affected by the environment through which they propagate, including the presence and movement of people.

Early work in this field focused on Channel State Information (CSI)-based approaches, which provide fine-grained information about the wireless channel. However, CSI extraction requires specialized hardware and drivers, making it impractical for many applications. RSSI-based approaches, while less precise than CSI, offer several practical advantages:

Several studies have demonstrated the feasibility of RSSI-based presence detection. For example, [1] showed that human presence causes measurable fluctuations in RSSI values due to signal absorption and multipath effects. [2] developed a threshold-based approach for occupancy detection using commercial WiFi devices. However, these studies often relied on complex signal processing or required multiple access points.

Our work builds upon these foundations while addressing several key challenges:

3. Methodology

This section details the system architecture, hardware components, data collection methodology, and machine learning pipeline developed for this research.

3.1 System Overview

The proposed system consists of three main components:

  1. Data Collection Module: ESP32-based hardware for RSSI measurement and logging
  2. Model Training Module: Offline machine learning pipeline for classifier development
  3. Deployment Module: Real-time classification and alerting system
System Architecture Diagram

Figure 1: System architecture overview showing data flow from collection to deployment

3.2 Hardware Setup

The hardware platform was carefully selected to balance performance, power efficiency, and cost:

ESP32 Dev Board: The core of the system is an ESP32-WROOM-32D development board, featuring:

Peripheral Components:

Hardware Setup Diagram

Figure 2: Hardware components and connections

3.3 Data Collection Protocol

The data collection process was designed to capture RSSI variations under different occupancy conditions:

Experimental Setup:

Data Collection Scenarios:

  1. Empty Room Baseline: RSSI measurements with no human presence (blankroom.csv)
  2. Occupied Room: RSSI measurements with one person moving naturally (personinroom.csv)
  3. Controlled Movement: Systematic movement patterns at varying distances
  4. Multiple Persons: 2-3 people moving simultaneously

The raw data format includes timestamp, RSSI values for each access point, and ground truth labels:

Timestamp AP1_RSSI AP2_RSSI Occupancy
2023-05-15 14:30:01 -35.2 -42.1 0
2023-05-15 14:30:02 -36.8 -41.5 1

3.4 Signal Processing and Feature Extraction

Raw RSSI values are processed to extract meaningful features for classification:

Preprocessing Steps:

  1. Noise Filtering: Moving average filter with window size 5
  2. Normalization: Min-max scaling to [0,1] range
  3. Outlier Removal: Discarding values beyond ±3σ from mean

Feature Extraction: For each 10-second window, the following features are calculated:

The feature vector F for classification can be represented as:

F = [min(RSSI), max(RSSI), μ(RSSI), σ(RSSI), max(RSSI)-min(RSSI), β1]

where β1 is the slope coefficient from linear regression.

3.5 Machine Learning Model

Several classification algorithms were evaluated before selecting logistic regression:

Algorithm Accuracy Memory Usage Inference Time
Logistic Regression 95.2% 2.1KB 0.8ms
Decision Tree 93.7% 4.5KB 1.2ms
k-NN (k=3) 94.1% 15.2KB 3.5ms
SVM (Linear) 95.0% 3.8KB 1.5ms

Logistic regression was selected for final implementation due to its optimal balance between accuracy and resource requirements. The decision function is:

P(y=1|F) = 1 / (1 + e-(w·F + b))

where w is the weight vector and b is the bias term learned during training.

3.6 System Implementation

The final system was implemented in MicroPython for rapid development and deployment:

Key Software Components:

The main processing loop executes the following steps every second:

  1. Scan for available WiFi networks
  2. Extract RSSI values for target access points
  3. Update rolling window buffer
  4. Calculate features when sufficient samples collected
  5. Run classification
  6. Update display and trigger alerts if needed

4. Results and Performance Evaluation

The system was evaluated under various conditions to assess its detection accuracy, response time, and reliability.

4.1 Detection Accuracy

Using a dataset of 12,000 samples (6,000 per class), the classifier achieved:

Metric Value
Overall Accuracy 95.2%
Precision (Occupied) 94.8%
Recall (Occupied) 95.6%
F1 Score 95.2%
False Positive Rate 4.3%

4.2 RSSI Characteristics

The following table compares RSSI statistics between empty and occupied scenarios:

Scenario Min RSSI Max RSSI Mean RSSI Std Dev Variation
Blank Room -33.4 -30.0 -31.93 0.46 3.4
Person in Room -37.8 -30.8 -33.63 0.97 7.0
RSSI Distribution Comparison

Figure 3: Probability distributions of RSSI values for empty vs. occupied scenarios

4.3 Temporal Performance

The system's response time was measured under different conditions:

Movement Type Detection Latency Success Rate
Walking (1m/s) 1.2s 96%
Sitting Still 2.5s 89%
Multiple Persons 1.0s 98%

4.4 Power Consumption

Power measurements were taken under different operating modes:

Mode Current Draw Estimated Battery Life
Active Sensing 85mA 12 hours
Deep Sleep (wake every 10s) 5mA avg 7 days
Alert Active 120mA 8 hours

5. Applications

The developed system has numerous practical applications across different domains:

5.1 Smart Home Automation

5.2 Security Systems

5.3 Healthcare and Assisted Living

5.4 Commercial Applications

6. Advantages

The proposed system offers several significant advantages over traditional presence detection methods:

6.1 Privacy Preservation

Unlike camera-based systems, the RSSI-based approach doesn't capture any visual or identifiable information about individuals, addressing growing privacy concerns in smart environments.

6.2 Cost Effectiveness

The total hardware cost is under $15, significantly cheaper than most commercial presence detection systems, making it accessible for widespread deployment.

6.3 Energy Efficiency

The ESP32's low-power capabilities enable battery operation for extended periods, with current draw as low as 5µA in deep sleep mode.

6.4 Non-Line-of-Sight Operation

WiFi signals can penetrate walls and furniture, allowing detection even when direct line-of-sight isn't available, unlike PIR or camera systems.

6.5 Easy Integration

The system can be easily integrated with existing smart home platforms and IoT ecosystems through standard communication protocols.

7. Limitations and Future Work

While the proposed system demonstrates promising results, several limitations and opportunities for improvement have been identified:

7.1 Current Limitations

7.2 Future Research Directions

Several avenues for future research and development have been identified:

Advanced Machine Learning Models:

Multi-Modal Sensing:

System Optimization:

8. Conclusion

This research has successfully demonstrated the feasibility of implementing a practical, low-cost human presence detection system using WiFi RSSI and machine learning on the ESP32 platform. The developed system achieves over 95% detection accuracy in controlled environments while addressing critical concerns of privacy preservation and energy efficiency that plague traditional approaches.

The comprehensive evaluation presented in this work provides valuable insights into the characteristics of WiFi signal variations caused by human presence and establishes a framework for implementing machine learning on resource-constrained IoT devices. The system's performance metrics, including detection latency, power consumption, and accuracy, suggest strong potential for real-world deployment in various application domains.

Future work will focus on addressing the identified limitations through advanced machine learning techniques, multi-modal sensor fusion, and system optimization. The promising results obtained in this research pave the way for further exploration of wireless signal-based sensing and its applications in smart environments.

References

  1. Liu, H., et al. "WiFi-Based Human Activity Recognition: A Survey." IEEE Communications Magazine, vol. 57, no. 5, 2019, pp. 138-144.
  2. Wang, Y., et al. "E-eyes: Device-free Location-oriented Activity Identification Using Fine-grained WiFi Signatures." Proceedings of the 20th Annual International Conference on Mobile Computing and Networking, 2014, pp. 617-628.
  3. Espressif Systems. "ESP32 Technical Reference Manual." Version 4.7, 2022.
  4. Pedregosa, F., et al. "Scikit-learn: Machine Learning in Python." Journal of Machine Learning Research, vol. 12, 2011, pp. 2825-2830.
  5. MicroPython Development Team. "MicroPython Documentation." 2023. [Online]. Available: https://docs.micropython.org
  6. Adib, F., et al. "See Through Walls with WiFi!" ACM SIGCOMM Computer Communication Review, vol. 43, no. 4, 2013, pp. 75-86.
  7. Zeng, Y., et al. "WiWho: WiFi-based Person Identification in Smart Spaces." Proceedings of the 15th International Conference on Information Processing in Sensor Networks, 2016, pp. 1-12.
  8. Halperin, D., et al. "Tool Release: Gathering 802.11n Traces with Channel State Information." ACM SIGCOMM Computer Communication Review, vol. 41, no. 1, 2011, pp. 53-53.
  9. Kotaru, M., et al. "SpotFi: Decimeter Level Localization Using WiFi." ACM SIGCOMM Computer Communication Review, vol. 45, no. 4, 2015, pp. 269-282.
  10. Zhang, D., et al. "A Survey on Human Behavior Recognition Using Channel State Information." IEEE Access, vol. 7, 2019, pp. 155986-156010.