Next Article in Journal
Study on a Landslide Segmentation Algorithm Based on Improved High-Resolution Networks
Previous Article in Journal
Highly Efficient Hybrid Reconfigurable Intelligent Surface Approach for Power Loss Reduction and Coverage Area Enhancement in 6G Networks
Previous Article in Special Issue
Multi-Sensor Fusion Approach to Drinking Activity Identification for Improving Fluid Intake Monitoring
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Monitoring the Sleep Respiratory Rate with Low-Cost Microcontroller Wi-Fi in a Controlled Environment

by
Ratthamontree Burimas
,
Teerayut Horanont
*,
Aakash Thapa
and
Badri Raj Lamichhane
School of Information, Computer and Communication Technology, Sirindhorn International Institute of Technology, Thammasat University, Pathum Thani 12000, Thailand
*
Author to whom correspondence should be addressed.
Appl. Sci. 2024, 14(15), 6458; https://doi.org/10.3390/app14156458
Submission received: 1 April 2024 / Revised: 10 July 2024 / Accepted: 22 July 2024 / Published: 24 July 2024
(This article belongs to the Special Issue Intelligent Electronic Monitoring Systems and Their Application)

Abstract

:
Sleep apnea, characterized by breathing interruptions or slow breathing at night, can cause various health issues. Detecting respiratory rate (RR) using Wireless Fidelity (Wi-Fi) can identify sleep disorders without physical contact avoiding sleep disruption. However, traditional methods using Network Interface Cards (NICs) like the Intel Wi-Fi Link 5300 NIC are often costly and limited in channel state information (CSI) resolution. Our study introduces an effective strategy using the affordable ESP32 single-board computer for tracking RR through detailed analysis of Wi-Fi signal CSI. We developed a technique correlating Wi-Fi signal fluctuations with RR, employing signal processing methods—Hampel Filtering, Gaussian Filtering, Linear Interpolation, and Butterworth Low Pass Filtering—to accurately extract relevant signals. Additionally, noise from external movements is mitigated using a Z-Score for anomaly detection approach. We also implemented a local peak function to count peaks within an interval, scaling it to bpm for RR identification. RR measurements were conducted at different rates—Normal (12–16 bpm), Fast (>16 bpm), and Slow (<12 bpm)—to assess the effectiveness in both normal and sleep apnea conditions. Tested on data from 8 participants with distinct body types and genders, our approach demonstrated accuracy by comparing modeled sleep RR against actual RR measurements from the Vernier Respiration Monitor Belt. Optimal parameter settings yielded an overall average mean absolute deviation (MAD) of 2.60 bpm, providing the best result for normal breathing (MAD = 1.38). Different optimal settings were required for fast (MAD = 1.81) and slow breathing (MAD = 2.98). The results indicate that our method effectively detects RR using a low-cost approach under different parameter settings.

1. Introduction

Monitoring human sleep has gained significant attention, one of the reasons being sleep apnea, which is characterized by breathing interruptions or slow breathing at night. The development of devices like smartwatches, mattresses, and rings are able to track sleep patterns. Among the crucial metrics for assessing sleep apnea is the respiratory rate (RR), measured in breaths per minute (bpm). However, these devices often inadvertently disturb sleep due to their requirement for physical contact. Therefore, this study aims to monitor sleep RR using a contactless approach, employing a microcontroller named Espressif32 (ESP32) [1] with Wireless Fidelity (Wi-Fi) capabilities.
Wi-Fi serves as a fundamental channel for internet access through IEEE 802.11 n/g/ac protocols with wireless connectivity. It operates on 2.4/5 GHz frequencies [2] across multiple channels, each offering a bandwidth of 22 MHz. With advancements in Wi-Fi technology, it is possible to glean more information from a connection than just the data being sent. Data transmission in Wi-Fi utilizes a technique called orthogonal frequency division multiplexing (OFDM) [3], allowing parallel data streams. One notable phenomenon in Wi-Fi transmission is the Doppler effect [4,5], highlighting the role of Channel State Information (CSI) as a crucial physical layer metric. CSI helps in analyzing the propagation paths between transmitter and receiver, including any potential obstacles. CSI represents the characteristics of the Wi-Fi signal as it travels from the transmitter to the receiver, interacting with the surrounding environment [6]. This interaction affects the signal, and CSI captures these variations, providing detailed insight into how the signal is modified along its path. CSI is accessible at both the sending and receiving ends, allowing for a comprehensive understanding of the signal’s journey. This is crucial because the receiver can also send data back, creating a two-way flow of information.
The human body acts as a reflector for radio waves, including Wi-Fi signals [7]. Research studies [8,9,10] have shown that the human body significantly influences the CSI by altering the signal’s propagation path. This alteration by the human body is crucial for applications that rely on precise understanding of signal behavior. Numerous studies have explored extracting complex features from Wi-Fi signals for monitoring RR. Network Interface Cards (NICs) are commonly used in research for CSI data collection [11]. Lai et al. [12] proposed a multiple signal classification (MUSIC) based system for monitoring breath rates using CSI data collected with Intel Wi-Fi Link 5300 NIC and Linux. Mosleh et al. [13] details how CSI from NICs can be used to estimate RRs in various environments. Gu et al. [14] monitored respiratory and heart rates utilizing Intel Wi-Fi Link 5300 NIC and two miniPcs having Ubuntu operating software (OS). However, Atif et al. [15] state that Intel Wi-Fi Link 5300 NIC has high deployment costs along with limitations in the resolution of CSI measurements. Furthermore, they highlight that the Atheros-CSI tool, another CSI monitoring solution, also has significant costs and a complex setup process.
The ESP32 microprocessor is known for its low cost compared to traditional NICs used for CSI data collection [16]. Despite its potential, the ESP32 remains largely untapped in Wi-Fi research for identifying sleep apnea measuring RR. Previous studies [17,18] have utilized the ESP32 with physical instruments for monitoring, but these methods can hinder sleep quality due to their intrusive nature. Recent research employing CSI on five patients has been demonstrated, however, the system was not explicitly tested across varying breathing rates (normal, fast, and slow) [19]. Our experiment aims to measure RR at different rates to identify discrepancies with ground truth across various breathing patterns. Additionally, we introduce a new strategy to correlate Wi-Fi signal fluctuations with RR by addressing noise in raw CSI data, employing a series of signal processing methods—Hampel Filtering [20], Gaussian Filtering [21], Linear Interpolation [22], and Butterworth Low Pass Filtering [23]. These four filters implemented in sequence removes noise and outliers from raw CSI data. However, noise caused by external movements and elements that generate distortions in the rooms other than subject maybe still available in the treated CSI data. Therefore, we detect such anomalies and remove it. Furthermore, extraction of RR is applied using local peak function [24] approach.
The major contributions of this study are listed below:
  • The ESP32 microcontroller is utilized to identify sleep apnea by measuring RR, offering a cost-effective, compatible, and low-complexity approach.
  • A series of signal processing methods—Hampel Filtering, Gaussian Filtering, Linear Interpolation, and Butterworth Low Pass Filtering—are introduced to reduce noise contained in raw CSI data. Furthermore, noise generated from external movement other than the subject are also considered for CSI data refinement.
  • Measurement of RR is implemented at different rates—Normal (12–16 bpm), Fast (>16 bpm), and Slow (<12 bpm)—to assess the effectiveness of the proposed approach in both normal and sleep apnea conditions.

2. Materials and Methods

2.1. The ESP32 Microcontroller

The ESP32 microcontroller [25], known for its affordability and versatility in IoT applications [26] is used in our experiment (Figure 1), which can accurately gather quantitative CSI data. It supports 64 subcarriers but is limited to the 2.4 GHz frequency and a single channel connection with a 22 MHz bandwidth per channel. CSI represents the characteristics of the Wi-Fi signal as it travels from the transmitter to the receiver, interacting with the surrounding environment [6]. This interaction affects the signal, and CSI captures these variations, providing detailed insight into how the signal is modified along its path. CSI is accessible at both the sending and receiving ends, allowing for a comprehensive understanding of the signal’s journey. This is crucial because the receiver can also send data back, creating a two-way flow of information. CSI data is collectible from both access points (AP) and stations (STA), typically yielding similar results illustrated in Figure 2. An AP is a device that allows wireless devices to connect to a wired network using Wi-Fi, while an STA is a device that connects to the network, such as a laptop, smartphone, or IoT device. This study focuses primarily on STA-based CSI data for detailed collection and analysis of the signal variations directly from the connected devices.
While comparing with other IoT alternatives, ESP32 microcontroller is a superior choice due to its cost-effectiveness and performance capibility [27]. In terms of compatibility, the ESP32 integrates both Wi-Fi and dual-mode Bluetooth, providing extensive connectivity options in a single chip. This integration simplifies design and reduces the need for additional modules and external components [28]. Despite its advanced features, the ESP32 maintains a low complexity [16], making it accessible for both beginners and experienced developers.

2.2. Monitoring Human Sleep Respiratory Rate Using Vernier Respiration Monitor Belt

Monitoring the RR during sleep is critical for detecting potential health issues. Normal RR varies by body composition [29] and should remain consistent during sleep; deviations may indicate health risks like bradypnea or sleep apnea. RR, measured in bpm, is crucial for health monitoring. This study utilizes the Vernier Respiration Monitor Belt (illustrated in Figure 3), recognized for its accuracy in academic research, to provide a reliable RR measurement at a 4 Hz resolution. In parallel, the ESP32 logs CSI data at a 60 Hz resolution. We establish a mapping between 60 CSI data points and 4 RR data points per second to correlate the two metrics accurately. This exploration into using an accessible device like the ESP32 for sleep RR monitoring is unprecedented in current research.

2.3. Participants and Data Collection Process

For our study, we enlisted the participation of 8 volunteers, each selected to represent a diverse range of body mass index (BMI) and gender. The demographic and physiological characteristics of the volunteers are detailed in Table 1. These volunteers were asked to sleep within an area bounded by two Wi-Fi antennas while equipped with a Vernier belt to monitor their respiratory patterns. Each participant was observed for a duration of five minutes, during which they exhibited unique breathing patterns.

2.4. Conceptual Framework

Previous studies in activity classification [30,31,32], have predominantly utilized omnidirectional antennas, concentrating on the direct line of sight between these antennas for monitoring human activities. We adopted this methodology as depicted in Figure 4. It is crucial to note that CSI is influenced not just by the human body, but by the surrounding environment as a whole. Consequently, identical human poses might yield significantly different CSI readings in dissimilar environments. Therefore, CSI is particularly adept at tracking moving targets by focusing on the changes they induce in the signal. References [33,34] provide the concept of mapping CSI data to activity classifications. In the context of monitoring sleep, the participants are informed to stay in still position to measure RR using ESP32, and Vernier Respiration Monitor Belt is used to measure ground truth. The noise contained in raw CSI data from ESP32 are treated by a series of signal processing methods. However, noise may still be available due to external movements and elements that generate distortions in the rooms. Therefore, we implement noise detection method to remove the anomalies. Furthermore, local peak function is utilized to determine bpm, and compared to the ground truth value. The process of mapping CSI data to RR changes is detailed in Figure 5, and further described in subsequent sections.

2.5. Implementing Digital Signal Processing Techniques for CSI Data Analysis

We adapted the approach described in [32] to capture real-time CSI data using an ESP32 at the receiving end. The original CSI data are complex numbers and can be represented in terms of either phase or amplitude. Given that CSI data take the form h = y / x = v + w i , we process this data to extract amplitude as v 2 + w 2 and phase as arctan2 ( v , 2 ) . In this study, we focus on amplitude analysis. The amplitude of the CSI data is given by Equation (1).
Amplitude = v s c 2 + w s c 2 , s c [ 1 , 52 ]
where s c represents the subcarrier index ranging from 1 to 52. The ESP32 identifies 52 active subcarriers, with most showing some degree of offset. For simplicity, we select the 1st subcarrier for analysis.

2.5.1. Hampel Filtering

Raw CSI data from the ESP32 are inherently noisy, containing numerous outliers—data points markedly distant from the rest. Ideally, CSI data should form a continuous sequence, making outliers effectively noise. Hampel Filtering is employed to eliminate these pronounced outliers. An illustrative result of this filtering is displayed in Figure 6, contrasting the original noisy input against the refined output with fewer outliers. We adjust the filtering parameters, window size, and σ , here referred to as α and β , respectively.
For a raw signal { x i } i = 1 n , the Hampel filter is defined as follows:
  • Window and Median: For each i in the range α i n α , define the window { x i α , , x i + α } and compute its median Median i .
    Median i = median ( x i α , , x i + α )
  • Median Absolute Deviation: Calculate the median absolute deviation for the window:
    MAD i = median ( | x j Median i | ) for j { i α , , i + α }
  • Threshold: Define the threshold T:
    T = β · MAD i
  • Filtering: Replace x i with Median i if x i > Median i + T :
    x i = Median i if x i > Median i + σ · MAD i x i otherwise

2.5.2. Gaussian Filtering

Post-Hampel filtering, the CSI data exhibit improved clarity but may still lack smoothness. To further refine the data, Gaussian Filtering is applied, enhancing the smoothness of the CSI sequence. An example of this effect is shown in Figure 7, contrasting a rough input with its smoother, filtered counterpart. The key parameter for this process, σ , is denoted as γ in our study.
The 1-D Gaussian kernel is given by the equation:
g ( x ) = 1 2 π γ 2 exp x 2 2 γ 2
where γ is the standard deviation of the Gaussian distribution.
The kernel is normalized so that its sum is 1:
ϕ ( x ) = g ( x ) i = r r g ( x i )
where r is the radius of the kernel.
The 1-D Gaussian filter is the convolution of the input signal f ( x ) with the Gaussian kernel g ( x ) :
h ( x ) = ( f * g ) ( x ) = t = r r f ( x t ) ϕ ( t )
where r is the radius of the kernel, defined as r = truncate · γ + 0.5 if not specified.
For a multidimensional input f ( x ) , the Gaussian filter is applied independently along each dimension. The Gaussian kernel in n dimensions is:
g ( x ) = i = 1 n 1 2 π γ i 2 exp x i 2 2 γ i 2
The filtered output is given by:
h ( x ) = f ( t ) g ( x t ) d t
The Gaussian filter is adjusted using the following parameters in our study:
(a)
order: the order of the filter is 0.
(b)
γ : the standard deviation of the Gaussian kernel is adjustable to minimize the error.
(c)
truncate: the filter is truncated with the value 4 at many standard deviations.

2.5.3. Linear Interpolation

Given the variable and sometimes unstable sampling rate of CSI data from the ESP32, typically around 70 Hz, we employ Linear Interpolation to standardize the sequence dimensions. This technique allows us to resample CSI data at a consistent rate, set at 60 Hz for this study. An example of this interpolation is presented in Figure 8, demonstrating how data initially logged at an unstable rate of 70–80 Hz is normalized to a stable 60 Hz.
To generate CSI data at a 60 Hz rate, we employ a straightforward mathematical weighting equation to interpolate between two closest timestamped data points from the original dataset. This approach, outlined in Equation (11), allows us to adjust the frequency of the entire CSI dataset to a consistent 60 Hz.
C S I n o w = C S I b e f o r e + t s n o w t s b e f o r e t s a f t e r t s b e f o r e × ( C S I a f t e r C S I b e f o r e ) ,
where t s n o w , t s b e f o r e , t s a f t e r are the interested timestamp, timestamp of the closest CSI occured before the interested timestamp and timestamp of the closest CSI occurred after the interested timestamp respectively. Furthermore, C S I n o w , C S I b e f o r e , C S I a f t e r are CSI logged at t s n o w , CSI logged at t s b e f o r e and CSI logged at t s a f t e r respectively.

2.5.4. Butterworth Low Pass Filtering

After the initial filtering steps, the processed CSI data begin to reveal respiratory wave patterns. However, these signals are often accompanied by higher frequency noise, which is not expected in a static sleeping environment where the only significant movement is the breathing of a person. To isolate the breathing signal, we apply Butterworth low pass filtering, effectively eliminating any components with frequencies exceeding a predefined threshold. By setting this threshold just above the typical range of human RRs, we can isolate the breathing waveform. Figure 9 demonstrates this filtering, comparing the original input, laden with high-frequency noise, to the refined output that prominently features only the breathing wave. The parameters for this filtering process, specifically the order of the Butterworth filter and the cutoff frequency, are denoted as δ and ϵ , respectively, in our study.
The transfer function H ( s ) of an δ -th order Butterworth low-pass filter is given by:
H ( s ) = 1 1 + s ω c 2 δ
where s is the complex frequency variable, and ω c is the normalized cutoff frequency.
In the discrete domain, using the Nyquist frequency f s / 2 where f s is the sampling frequency, the normalized cutoff frequency ω c is given by:
ω c = 2 π ϵ f s

2.6. Noise Detection

After a series of signal processing methods, we obtain refined CSI data. However, the data still may contain noise caused by external movements. Therefore, we introduce a technique to detect the part containing such noise to enhance the result. We deliberately added a noise during the last part of the experiment. In Figure 10 shows intended noise after frame 385 after applying filtering methods. The extensive difference can be observed after applying Butterworth Filtering. Due to this distinctive nature, we added threshold to determine if that window contain a noise.
The RR data after all filtering is seen as a sinusoidal time-series data. Therefore, within a considering window 30 s, we calculated Z-Score for Anomaly Detection [35] for detecting. If there is anomaly within the window, we discard it. Z score at a certain frame is given by Equation (14).
Z i = X i μ w σ w
where X i , μ w and σ w are the data point, the mean of this window and the standard deviation of this window, respectively.
Figure 11 (top) shows poor estimation after frame 355 due to intentional noise. We investigated by plotting Z score as shown in Figure 11 (bottom). Maximum Z shifts explicitly at the frame where prediction went far from minimum Z. Then we set some threshold for the distance between minimum Z score and maximum Z score, denoted as τ in the study. If any window size has the distance between minimum Z score and maximum Z score higher than τ , it is considered as noise caused by external movement, and discarded.

2.7. Extraction of Respiratory Rate

To extract the RR from the filtered CSI graph, we used local peak function [24] to find the number of peak in an interval and scaled it to be a minute resulted as a bpm. There is a single parameter for local peak that is a minimum distance before the next peak. The distance is denoted as ζ in our study. We assume that normal people do not breathe at rate over 30 bpm. Therefore, in 60Hz data with 30 s window, ζ will be 60 × 30 / 15 = 120 . The result in Figure 12 shows that there are 11 peaks in 30 s interval, which corresponds to 22 bpm. This local peak-based method is adapted from [36,37], which is very common approach in heart rate monitoring.

3. Results

Analysis of Experimental Outcomes

The data analysis was conducted using a custom Python 3.8 script, focusing on the mean absolute deviation (MAD) as the primary metric to quantify the discrepancy between the RR measurements obtained from the ESP32 and those recorded by the Vernier belt. The MAD calculation is based on the following formula:
M A D = i = 1 n | N i g t N i p d | n ,
where n is a total number of dataset, N i g t is RR obtained from the belt at index i and N i p d is RR obtained from the ESP32 at index i.
The overall result of bpm for 8 participants with calibrated parameters is shown in Figure 13. This visualization demonstrates that the predicted CSI data, after signal processing and RR extraction, closely matches the ground truth obtained from the Vernier belt. However, significant discrepancy can be observed at certain frames. A detailed statistical analysis is presented in Table 2, Table 3, Table 4 and Table 5.
From 30-s windows, we interpret RR in bpm in the following tables and present the MAD values for three distinct breathing patterns (normal, fast, and slow) under various parameter adjustments. Since, all the 8 participants are adults, we define 12–16 bpm as a normal breathing type during rest as stated by [38]. Therefore, bmp under normal breathing time is slow breathing type, which is useful to understand the RR pattern which may potentially lead to sleep apnea. The bpm higher than 16 is outlined as fast breathing type.
The experiments tested at multiple parameter combinations show that the overall average MAD from 8 participants across all three breathing types is optimal with α = 1 , β = 50 , γ = 15 , δ = 2 , ϵ = 20 , τ = 5 , and ζ = 120 , yielding an MAD value of 2.60. This parameter combination also provides the best result for normal breathing with an MAD of 1.38. However, it fails to optimize results for fast and slow breathing rates. For fast breathing, the best MAD is 1.81 with ϵ = 30 , keeping other parameters the same. For slow breathing, which is suitable for sleep apnea, the optimal MAD is achieved with γ = 35 while keeping the other parameters constant. The observation indicates that low ϵ is beneficial for slow breathing RR estimation because the Butterworth filter effectively eliminates noise. Similarly, ϵ is efficient for fast breathing RR estimation.
Observations indicate that the amplitude is much smoother in the smaller room, allowing for the use of a low γ value for the Gaussian filter. Conversely, a higher γ value is needed for a larger room with less smooth amplitude. The parameter ϵ emerged as a significant factor influencing the accuracy of our results, acting as a filter for the frequencies detected within the signal. A higher ϵ value tends to disregard rapid breathing patterns as noise, preserving only normal and slow breathing rates. Conversely, a lower ϵ setting results in the retention of fast breathing rates but also includes more noise, which adversely affects the clarity of normal and slow breathing rate data. Consequently, for the purpose of sleep apnea detection, a lower ϵ value is recommended to ensure a balanced sensitivity to various breathing rates while minimizing noise interference.

4. Discussion

4.1. Antenna Placement

In our setup, omnidirectional antennas were employed, designed to disseminate signals equally across all directions. This led to the strategic placement of antennas in a parallel arrangement, as illustrated in Figure 4, across all our tests. We validated this setup by analyzing the Received Signal Strength Indicator (RSSI), which measures signal intensity. Our findings confirmed that a parallel alignment of the antennas facilitated the most effective signal concentration.

4.2. Adjusting for Accurate Respiratory Rate Detection

Our results underscore the importance of fine-tuning in the extraction of RRs, especially for slow breathing patterns. The data demonstrates that a lower ζ value minimizes errors in detecting slow respirations, whereas a higher ζ value tends to increase discrepancies. Fast breathing patterns, which are closely associated with noise, present a greater challenge in differentiation. In the context of identifying slow breathing associated with sleep apnea, a ζ slightly lower then normal human RR setting is advantageous, providing a balanced performance across various breathing rates with an emphasis on accuracy for normal and slow respirations.
An important factor is the environment’s density, as illustrated by the Gaussian smoothing factor γ in Figure 7. If γ is set too high, the result can be too flat to be recognized as a pulse. Our investigations, detailed in Table 2, Table 3, Table 4 and Table 5, revealed that data collected in a larger room with many obstacles (Subjects 1–4) benefit from a higher γ . In contrast, data collected in a smaller room with limited obstacles (Subjects 5–8) prefer a lower γ .

4.3. Significance of Our Study

This study offers a highly cost-effective, compatible, and low-complexity strategy for RR monitoring using WiFi CSI. The ESP32, a key component of our system, is known for its affordability, accessibility, and robust community-driven support, making it an ideal choice for this application. By utilizing this inexpensive and widely available hardware, we provide a practical solution that is within reach for a broad audience. Furthermore, we employed advanced filtering techniques to enhance the accuracy of measurements across different breathing patterns, including the slow breathing associated with sleep apnea. The involvement of multiple participants further validates the robustness and generalizability of our approach.

4.4. Limitations and Future Directions

4.4.1. Constrained Sample Size and Data Collection Duration

The study was conducted with a relatively small sample size of 8 participants, which may limit the applicability of the findings. Additionally, the data collection period for each participant was limited to five minutes. Such a brief duration may not capture the full spectrum of RR variability throughout different sleep stages. However, we added variety to the data by instructing participants to breathe in different patterns (e.g., fast, slow, and normal) to make the data varied enough to reflect real-world sleeping conditions.

4.4.2. Controlled Experimental Conditions

Technically, the traversing Wi-Fi signal between the sender and receiver is vague and not applicably filterable within an open environment. Therefore, it was necessary to conduct the study in a controlled environment to ensure the data was precise enough for accurate prediction. This controlled environment included careful placement of Wi-Fi antennas, minimal electronic interference, and avoiding rooms with heavy Wi-Fi traffic. Additionally, participants were instructed to follow specific guidelines, such as lying still and maintaining a consistent posture throughout the experiment. These measures aimed to minimize external variables and ensure the reliability of the collected data. However, we introduced deliberate noise during some parts of the experiment to test the robustness of our method, ensuring that the approach could handle real-world conditions effectively.

4.4.3. Estimation in Multi-Occupant Environments

This experiment demonstrated the potential of ESP32 CSI to accurately track the RR of a single individual. However, tracking the RRs of multiple individuals in a shared space poses significant challenges due to the overlap in CSI signals caused by movement, complicating individual separation. This study specifically targets individuals living alone, such as the elderly, who can greatly benefit from reliable self-monitoring tools.

4.4.4. Future Directions

Future research should focus on expanding the sample size and extending the data collection period to enhance robustness of the findings. Additionally, exploring advanced signal processing techniques and machine learning algorithms could improve the differentiation of respiratory signals in multi-occupant environments. This technology holds promise for future real-world applications, providing a non-intrusive and reliable method for RR monitoring in various settings.

5. Conclusions

This study is driven by the need for a non-invasive method to monitor sleep, focusing on identifying sleep apnea—a condition prevalent among the elderly and individuals who sleep alone. While previous research, such as [33], has explored the use of Wi-Fi Channel State Information (CSI) for detecting physical activity and movement, our study pushes the boundaries by using CSI to measure sleep RRs.
To overcome environmental challenges in typical sleeping environments and enhance Wi-Fi signal stability, we aligned our methodology with RR measurements obtained from the Vernier Belt. Despite initial challenges posed by the intrinsic characteristics of CSI, which allow signal transmission through obstacles, we developed a robust signal processing approach. This involved initial noise reduction using Section 2.5.1, Section 2.5.2 and Section 2.5.3, followed by Section 2.5.4 to isolate frequencies corresponding to human breathing rates. This significantly improved signal accuracy and reliability. Furthermore, we implemented the “Z-Score for Anomaly Detection” method to detect errors in our data analysis. Subsequently, we applied a local peak function to determine the number of pulses, enabling us to calculate a precise bpm value. To validate our methodology, we conducted tests with a diverse group of volunteers. The comparison of our results with those obtained from the Vernier Belt confirmed the efficacy of our approach.
Our findings highlight the feasibility of using widely available Wi-Fi CSI for non-intrusive sleep monitoring, particularly benefiting the elderly and individuals with sleep apnea. The absence of direct contact with the monitoring device offers a seamless sleep experience. Detailed results and parameter adjustments are documented in Section 3, showcasing the adaptability and effectiveness of our method. By demonstrating the capability of common Wi-Fi-enabled devices to capture vital health metrics, this study lays the groundwork for future investigations into the broader applications of Wi-Fi CSI in health monitoring. It opens avenues for further exploration into non-invasive diagnostic tools, promising exciting possibilities for the future of healthcare technology.

Author Contributions

Conceptualization, T.H.; methodology, R.B. and T.H.; software, R.B.; validation, R.B., A.T. and B.R.L.; formal analysis, R.B., A.T. and B.R.L.; investigation, R.B.; resources, T.H., R.B., A.T. and B.R.L.; data curation, R.B.; writing—original draft preparation, R.B.; writing—review and editing, T.H., A.T. and B.R.L.; visualization, R.B.; supervision, T.H.; project administration, T.H.; funding acquisition, T.H. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by Thammasat University Research Fund grant number TUFT 87/2566.

Institutional Review Board Statement

The study was conducted in accordance with the Declaration of Helsinki, the Belmont report, CIOMS guidelines and the International practice (ICH-GCP), and approved by the Institutional Review Board (or Ethics Committee) of The Human Research Ethics Committee of Thammasat University (Science), Thailand, (149/2565 approved on 11 February 2023).

Informed Consent Statement

Informed consent was obtained from all subjects involved in the study.

Data Availability Statement

The data cannot be provided due to privacy.

Acknowledgments

The authors would like to thanks the Advance Geospatial Technology Research Unit, SIIT, and the Center of Excellence in Digital Earth and Emerging Technology (DEET), Thammasat University for providing technical environment and supportive information. We gratefully acknowledge the financial support provided by the Thammasat University Research Fund.

Conflicts of Interest

The authors declare no conflict of interest. The funders had no role in the design of the study; in the collection, analyses, or interpretation of data; in the writing of the manuscript; or in the decision to publish the results.

References

  1. Espressif Systems. ESP32. 2023. Available online: https://www.espressif.com/en/products/socs/esp32 (accessed on 23 May 2023).
  2. Banerji, S.; Chowdhury, R.S. On IEEE 802.11: Wireless LAN technology. arXiv 2013, arXiv:1307.2661. [Google Scholar] [CrossRef]
  3. Li, Y.G.; Stuber, G.L. Orthogonal Frequency Division Multiplexing for Wireless Communications; Springer Science & Business Media: Berlin/Heidelberg, Germany, 2006. [Google Scholar]
  4. Yang, D.; Wang, T.; Sun, Y.; Wu, Y. Doppler shift measurement using complex-valued CSI of WiFi in corridors. In Proceedings of the 2018 3rd International Conference on Computer and Communication Systems (ICCCS), Nagoya, Japan, 27–30 April 2018; pp. 367–371. [Google Scholar]
  5. Shih, Y.Y.; Pang, A.C.; Hsiu, P.C. A Doppler effect based framework for Wi-Fi signal tracking in search and rescue operations. IEEE Trans. Veh. Technol. 2017, 67, 3924–3936. [Google Scholar] [CrossRef]
  6. Ma, Y.; Zhou, G.; Wang, S. WiFi sensing with channel state information: A survey. ACM Comput. Surv. (CSUR) 2019, 52, 1–36. [Google Scholar] [CrossRef]
  7. Hao, Z.; Niu, J.; Dang, X.; Qiao, Z. WiPg: Contactless action recognition using ambient wi-fi signals. Sensors 2022, 22, 402. [Google Scholar] [CrossRef] [PubMed]
  8. Yang, X.; Cheng, J.; Tang, X.; Xie, L. CSI-based human behavior segmentation and recognition using commodity Wi-Fi. EURASIP J. Wirel. Commun. Netw. 2023, 2023, 46. [Google Scholar] [CrossRef]
  9. Huang, D.; Nandakumar, R.; Gollakota, S. Feasibility and limits of wi-fi imaging. In Proceedings of the 12th ACM Conference on Embedded Network Sensor Systems, Memphis, TN, USA, 3–6 November 2014; pp. 266–279. [Google Scholar]
  10. Tang, X.; Yang, X.; Zhou, M.; Xie, L. Realization of CSI-Based Human Behavior Recognition: A Survey. In Advances in Artificial Intelligence and Security, Proceedings of the 7th International Conference, ICAIS 2021, Dublin, Ireland, 19–23 July 2021; Proceedings, Part III 7; Springer: Berlin/Heidelberg, Germany, 2021; pp. 481–491. [Google Scholar]
  11. Shahverdi, H.; Nabati, M.; Fard Moshiri, P.; Asvadi, R.; Ghorashi, S.A. Enhancing CSI-based human activity recognition by edge detection techniques. Information 2023, 14, 404. [Google Scholar] [CrossRef]
  12. Lai, P.J.; Zhan, Y.S.; Yeh, W.L.; Ku, M.L.; Yu, C.M. MUSIC-Based Breathing Rate Monitoring Using Wi-Fi CSI. In Proceedings of the 2022 IEEE 13th Annual Ubiquitous Computing, Electronics & Mobile Communication Conference (UEMCON), New York, NY, USA, 26–29 October 2022; pp. 380–384. [Google Scholar]
  13. Mosleh, S.; Coder, J.B.; Scully, C.G.; Forsyth, K.; Al Kalaa, M.O. Monitoring respiratory motion with wi-fi csi: Characterizing performance and the breathesmart algorithm. IEEE Access 2022, 10, 131932–131951. [Google Scholar] [CrossRef] [PubMed]
  14. Gu, Y.; Zhang, X.; Liu, Z.; Ren, F. Wifi-based real-time breathing and heart rate monitoring during sleep. In Proceedings of the 2019 IEEE Global Communications Conference (GLOBECOM), Waikoloa, HI, USA, 9–13 December 2019; pp. 1–6. [Google Scholar]
  15. Atif, M.; Muralidharan, S.; Ko, H.; Yoo, B. Wi-ESP—A tool for CSI-based device-free Wi-Fi sensing (DFWS). J. Comput. Des. Eng. 2020, 7, 644–656. [Google Scholar] [CrossRef]
  16. Hercog, D.; Lerher, T.; Truntič, M.; Težak, O. Design and implementation of ESP32-based IOT devices. Sensors 2023, 23, 6739. [Google Scholar] [CrossRef]
  17. Rebelo, J.; Gaspar, P.D.; Soares, V.N.; Caldeira, J.M. A Novel mHealth Approach for the Monitoring and Assisted Therapeutics of Obstructive Sleep Apnea. Appl. Sci. 2022, 12, 10257. [Google Scholar] [CrossRef]
  18. Rajguru, K.; Tarpe, P.; Aswar, V.; Bawane, K.; Sorte, S.; Agrawal, R. Design and Implementation of IoT based sleep monitoring system for Insomniac people. In Proceedings of the 2022 Second International Conference on Artificial Intelligence and Smart Energy (ICAIS), Coimbatore, India, 23–25 February 2022; pp. 1215–1221. [Google Scholar]
  19. Ramadhani, U.A.; Wisana, I.D.G.H.; Nugraha, P.C. Smartphone based respiratory signal monitoring and apnea detection via bluetooth comunication. J. Teknokes 2021, 14, 49–55. [Google Scholar] [CrossRef]
  20. Pearson, R.K.; Neuvo, Y.; Astola, J.; Gabbouj, M. Generalized hampel filters. EURASIP J. Adv. Signal Process. 2016, 2016, 1–18. [Google Scholar] [CrossRef]
  21. Marr, D.; Hildreth, E. Theory of edge detection. Proc. R. Soc. Lond. Ser. B. Biol. Sci. 1980, 207, 187–217. [Google Scholar]
  22. Press, W.H.; Teukolsky, S.A.; Vetterling, W.T.; Flannery, B.P. Numerical Recipes: The Art of Scientific Computing; Cambridge University Press: Cambridge, UK, 2007. [Google Scholar]
  23. Roberts, J.; Roberts, T.D. Use of the Butterworth low-pass filter for oceanographic data. J. Geophys. Res. Ocean. 1978, 83, 5510–5514. [Google Scholar] [CrossRef]
  24. Palshikar, G.K. Simple algorithms for peak detection in time-series. In Proceedings of the 1st IIMA International Conference on Advanced Data Analysis, Business Analytics and Intelligence, Ahmedabad, India, 6–7 June 2009; Volume 122. [Google Scholar]
  25. Babiuch, M.; Foltỳnek, P.; Smutnỳ, P. Using the ESP32 microcontroller for data processing. In Proceedings of the 2019 20th International Carpathian Control Conference (ICCC), Krakow-Wieliczka, Poland, 26–29 May 2019; pp. 1–6. [Google Scholar]
  26. Abed, I.A.; Naser, H.Y. ESP32 microcontroller based smart power meter system design and implementation. Al-Rafidain Eng. J. (AREJ) 2020, 25, 136–143. [Google Scholar] [CrossRef]
  27. Maier, A.; Sharp, A.; Vagapov, Y. Comparative analysis and practical implementation of the ESP32 microcontroller module for the internet of things. In Proceedings of the 2017 Internet Technologies and Applications (ITA), Wrexham, UK, 12–15 September 2017; pp. 143–148. [Google Scholar]
  28. Marković, M. Why Is ESP the Most Used IoT Connectivity MCU. 2023. Available online: https://www.byte-lab.com/why-is-esp-the-most-used-iot-connectivity-mcu/ (accessed on 6 June 2024).
  29. Sutherland, T.J.; McLachlan, C.R.; Sears, M.R.; Poulton, R.; Hancox, R.J. The relationship between body fat and respiratory function in young adults. Eur. Respir. J. 2016, 48, 734–747. [Google Scholar] [CrossRef] [PubMed]
  30. Wang, F.; Panev, S.; Dai, Z.; Han, J.; Huang, D. Can WiFi estimate person pose? arXiv 2019, arXiv:1904.00277. [Google Scholar]
  31. Liu, J.; Liu, H.; Chen, Y.; Wang, Y.; Wang, C. Wireless sensing for human activity: A survey. IEEE Commun. Surv. Tutor. 2019, 22, 1629–1645. [Google Scholar] [CrossRef]
  32. Hernandez, S.M.; Bulut, E. Lightweight and standalone IoT based WiFi sensing for active repositioning and mobility. In Proceedings of the 2020 IEEE 21st International Symposium on “A World of Wireless, Mobile and Multimedia Networks” (WoWMoM), Cork, Ireland, 31 August–3 September 2020; pp. 277–286. [Google Scholar]
  33. Chowdhury, T.Z.; Leung, C.; Miao, C.Y. WiHACS: Leveraging WiFi for human activity classification using OFDM subcarriers’ correlation. In Proceedings of the 2017 IEEE Global Conference on Signal and Information Processing (GlobalSIP), Montreal, QC, Canada, 14–16 November 2017; pp. 338–342. [Google Scholar]
  34. Zou, H.; Zhou, Y.; Yang, J.; Jiang, H.; Xie, L.; Spanos, C.J. Deepsense: Device-free human activity recognition via autoencoder long-term recurrent convolutional network. In Proceedings of the 2018 IEEE International Conference on Communications (ICC), Kansas City, MO, USA, 20–24 May 2018; pp. 1–6. [Google Scholar]
  35. Zhou, Z.G.; Tang, P. Continuous anomaly detection in satellite image time series based on z-scores of season-trend model residuals. In Proceedings of the 2016 IEEE International Geoscience and Remote Sensing Symposium (IGARSS), Beijing, China, 10–15 July 2016; pp. 3410–3413. [Google Scholar]
  36. Roach, D.; Sheldon, A.; Wilson, W.; Sheldon, R. Temporally localized contributions to measures of large-scale heart rate variability. Am. J. Physiol.-Heart Circ. Physiol. 1998, 274, H1465–H1471. [Google Scholar] [CrossRef] [PubMed]
  37. Barbieri, R.; Matten, E.C.; Alabi, A.A.; Brown, E.N. A point-process model of human heartbeat intervals: New definitions of heart rate and heart rate variability. Am. J. Physiol.-Heart Circ. Physiol. 2005, 288, H424–H435. [Google Scholar] [CrossRef] [PubMed]
  38. Medicine, J.H. Vital Signs (Body Temperature, Pulse Rate, Respiration Rate, Blood Pressure). Available online: https://www.hopkinsmedicine.org/health/conditions-and-diseases/vital-signs-body-temperature-pulse-rate-respiration-rate-blood-pressure (accessed on 7 June 2024).
Figure 1. Two ESP32s with external antenna. One act as a sender and another act as a receiver.
Figure 1. Two ESP32s with external antenna. One act as a sender and another act as a receiver.
Applsci 14 06458 g001
Figure 2. 2 CSIs from sender-side ESP32 (ESP32 AP) and receiver-side ESP32 (ESP32 STA).
Figure 2. 2 CSIs from sender-side ESP32 (ESP32 AP) and receiver-side ESP32 (ESP32 STA).
Applsci 14 06458 g002
Figure 3. Vernier Respiration Monitor Belt as a ground truth.
Figure 3. Vernier Respiration Monitor Belt as a ground truth.
Applsci 14 06458 g003
Figure 4. Antennae placement in our experiment for RR monitoring.
Figure 4. Antennae placement in our experiment for RR monitoring.
Applsci 14 06458 g004
Figure 5. Steps of the mapping rule.
Figure 5. Steps of the mapping rule.
Applsci 14 06458 g005
Figure 6. Example of applying Hampel filtering, showing the outlier in CSI data significantly reduced when α = 1 and β = 100 .
Figure 6. Example of applying Hampel filtering, showing the outlier in CSI data significantly reduced when α = 1 and β = 100 .
Applsci 14 06458 g006
Figure 7. Example of applying Gaussian filtering when γ = 5 . The Gaussian filtering enhances the smoothness of the CSI data.
Figure 7. Example of applying Gaussian filtering when γ = 5 . The Gaussian filtering enhances the smoothness of the CSI data.
Applsci 14 06458 g007
Figure 8. Example of applying CSI linear interpolation to standardize the sequence dimensions.
Figure 8. Example of applying CSI linear interpolation to standardize the sequence dimensions.
Applsci 14 06458 g008
Figure 9. Example of applying Butterworth low pass filtering when δ = 2 and ϵ = 30 to refine the output CSI data.
Figure 9. Example of applying Butterworth low pass filtering when δ = 2 and ϵ = 30 to refine the output CSI data.
Applsci 14 06458 g009
Figure 10. Example of noise detection when noise is intendedly made after frame 385 in Hampel Filtering (top), Guassian Filtering (middle) and Butterworth Filtering (bottom).
Figure 10. Example of noise detection when noise is intendedly made after frame 385 in Hampel Filtering (top), Guassian Filtering (middle) and Butterworth Filtering (bottom).
Applsci 14 06458 g010
Figure 11. Noise in predicted RR after frame 355 due to deliberate noise (top), and removal of frame rates containing deliberate noise using Z-Score (bottom).
Figure 11. Noise in predicted RR after frame 355 due to deliberate noise (top), and removal of frame rates containing deliberate noise using Z-Score (bottom).
Applsci 14 06458 g011
Figure 12. Example of RR extraction from prediction comparing to the ground truth for normal-rate breathing when ζ = 120 . Crossed symbols represent the local peaks of CSI signal.
Figure 12. Example of RR extraction from prediction comparing to the ground truth for normal-rate breathing when ζ = 120 . Crossed symbols represent the local peaks of CSI signal.
Applsci 14 06458 g012
Figure 13. Overall result of bpm, with the personal calibrated parameter.
Figure 13. Overall result of bpm, with the personal calibrated parameter.
Applsci 14 06458 g013
Table 1. General information of volunteers.
Table 1. General information of volunteers.
AttributeGenderWeight (kg)Height (cm)BMI
Subject
1Male6117519.90
2Female5617019.38
3Male6516922.80
4Female6415626.30
5Male6116821.60
6Male7117323.70
7Male6917323.10
8Male6817422.50
AVG 64.38169.7522.30
Table 2. Evaluation result when α = 1 , β = 50 , γ = 15 , δ = 2 , ϵ = 20 , τ = 5 and ζ = 120 . α and β are key parameters of Hampel filter, γ is a key parameter of Gaussian filter, δ and ϵ are parameters of Butterworth filter, τ is the distance between minimum and maximum Z score, and ζ is the minimum distance between the local peaks.
Table 2. Evaluation result when α = 1 , β = 50 , γ = 15 , δ = 2 , ϵ = 20 , τ = 5 and ζ = 120 . α and β are key parameters of Hampel filter, γ is a key parameter of Gaussian filter, δ and ϵ are parameters of Butterworth filter, τ is the distance between minimum and maximum Z score, and ζ is the minimum distance between the local peaks.
Subject12345678AVG
Breathing Type
Normal (12–16 bpm)1.081.040.891.611.191.431.112.671.38
Fast (>16 bpm)2.162.373.512.985.394.252.893.853.43
Slow (<12 bpm)2.462.433.812.764.832.004.061.522.98
AVG1.901.952.742.453.802.562.692.682.60
Table 3. Evaluation result when α = 1 , β = 50 , γ = 15 , δ = 2 , ϵ = 30 , τ = 5 and ζ = 120 .
Table 3. Evaluation result when α = 1 , β = 50 , γ = 15 , δ = 2 , ϵ = 30 , τ = 5 and ζ = 120 .
Subject12345678AVG
Breathing Type
Normal (12–16 bpm)2.622.463.003.642.262.531.783.562.73
Fast (>16 bpm)1.241.481.682.002.672.031.112.271.81
Slow (<12 bpm)3.675.205.525.387.543.336.163.004.98
AVG2.513.053.403.674.162.633.022.943.17
Table 4. Evaluation result when α = 1 , β = 50 , γ = 35 , δ = 2 , ϵ = 20 , τ = 5 and ζ = 120 .
Table 4. Evaluation result when α = 1 , β = 50 , γ = 35 , δ = 2 , ϵ = 20 , τ = 5 and ζ = 120 .
Subject12345678AVG
Breathing Type
Normal (12–16 bpm)2.671.081.111.364.043.302.893.092.44
Fast (>16 bpm)4.892.674.263.777.826.277.056.405.39
Slow (<12 bpm)1.211.972.102.002.061.782.781.921.98
AVG2.921.912.492.384.643.784.243.803.27
Table 5. Evaluation result when α = 1 , β = 50 , γ = 35 , δ = 2 , ϵ = 30 , τ = 5 and ζ = 120 .
Table 5. Evaluation result when α = 1 , β = 50 , γ = 35 , δ = 2 , ϵ = 30 , τ = 5 and ζ = 120 .
Subject12345678AVG
Breathing Type
Normal (12–16 bpm)1.211.960.892.092.182.52.072.371.91
Fast (>16 bpm)1.812.072.461.885.825.323.053.973.30
Slow (<12 bpm)2.334.543.714.072.491.563.121.242.88
AVG1.782.862.352.683.503.132.752.532.70
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.

Share and Cite

MDPI and ACS Style

Burimas, R.; Horanont, T.; Thapa, A.; Lamichhane, B.R. Monitoring the Sleep Respiratory Rate with Low-Cost Microcontroller Wi-Fi in a Controlled Environment. Appl. Sci. 2024, 14, 6458. https://doi.org/10.3390/app14156458

AMA Style

Burimas R, Horanont T, Thapa A, Lamichhane BR. Monitoring the Sleep Respiratory Rate with Low-Cost Microcontroller Wi-Fi in a Controlled Environment. Applied Sciences. 2024; 14(15):6458. https://doi.org/10.3390/app14156458

Chicago/Turabian Style

Burimas, Ratthamontree, Teerayut Horanont, Aakash Thapa, and Badri Raj Lamichhane. 2024. "Monitoring the Sleep Respiratory Rate with Low-Cost Microcontroller Wi-Fi in a Controlled Environment" Applied Sciences 14, no. 15: 6458. https://doi.org/10.3390/app14156458

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop