You are on page 1of 5

Smart Sleep Alarm For Sleep Apnea

Using Oximeter

Abstract— Nowadays, patients with sleep apnea situated in smartphones are also available which can work in a home
areas lacking in technological advancements are given setting.[12] Iot based systems are also proposed which gives
overnight supervision. Sleep apnea is a common condition in overnight diagnostic of the patient by using SpO2 data and
which the patients’ breathing stops and restarts many times cloud to process information.[13]. Other researchers use
when sleeping. This results in oxygen deficiency and may result ballistocardiograph (BCG) [14][15] and others use pressure
in fatality if left unattended over a period. Therefore, to sensors [16]. The sound is also used to determine OSA [17]
provide supervision in absence of medical staff we introduce [18].
“Smart Sleep Alarm for Sleep Apnea Using Oximeter”. The
oximeter measures how Oxygenated a host’s blood is and it The study of sleep Apnea Hypopnea Syndrome
also detects heartbeat (BPM). Furthermore, a haptic feedback helps analyze hemoglobin oxygen saturation levels using
actuator is connected to the patient’s bed. The sensor Artificial Neural Network classifier for sleep Apnea
continuously reads these vitals obtained from the host. When
detection. The proposed system is tested using a data set
oxygen content in blood is low, haptic feedback is enabled. The
immense feedback response is enough to wake up any heavy composed of 8 subjects with one-minute notations. The
sleeper. Using this apparatus, we can avoid deaths caused by optimal system consists of seven features which are utilized
sleep apnea and contribute to modern solutions. from a total of 61 features. The artificial Network system
reached up to 97 percent accuracy using these 7 features.
Keywords—Sleep Apnea, SpO2, pulse oximeter

I. INTRODUCTION Detection of sleep apnea is carried out


through study and Progressive work. By utilizing GA
Sleep apnea and hypopnea syndrome (SAHS) is a sleep (Genetic Algorithm) and ANN (Artificial Neural Network)
disorder which occurs in middle aged population,2%among the system can achieve such high efficiency. Features
females and 4% among males. It is indicated as abnormal selected by the GA algorithm are mostly composed of time-
pause in breathing and troubled sleep. [1]. It is treatable, frequency signal. A total of four out of seven are time-
however 90% of the sufferers go unidentified and therefore
frequency signals, out of which only two time and one
untreated. [2]. The patients suffer from daytime sleepiness
and fatigue and therefore are prone to traffic accidents, and frequency feature is selected. From this selection procedure,
experience memory loss and depression. [3], [4]. A common it is understandable that most of the information about
definition of apnea involves a cessation of airflow for at least Apnea events lies in the time-frequency space. With
10 s while hypopnea is defined as a minimum 10-s airflow evolution and technical advancement accuracy has been
reduction with either a blood oxygen desaturation of 4% or a greatly improved upon. It is to be noted that one drawback
neurological arousal [5]. of using these methods is that the structure of MLP
(Multilayer perception) is calculated using a rule of thumb
.There is a lot of cost involved in detection of sleep apnea and experimental search which can be replaced by a GA
as there are few professionals working in the field[6], [7]. algorithm. These ideas are under consideration for future
This is due to high diagnostic cost and the time patients must
work.
spend in waiting lists [8] In addition patients also must spend
a lot of times with multiple number of sensors attached to
their bodies in hospital beds which is not a natural
environment and cannot give us accurate cure. Research is II. COMPONENTS
being made to make it an easier process by reducing the
number of sensors and implement it in a patient home. It is The following components were utilized to assemble a smart
being carried out in several ways. sleep alarm for sleep apnea.
Sleep apnea detection methods being used include single Micro controller ESP32:
lead ECG which can detect difference in breathing patterns ESP32 is a low-cost, low-power Microcontroller with
and talk about different sleep apnea classification [9]. Hello
integrated Wi-Fi and Bluetooth. The Raspberry Pi Pico and
Sleep apnea can also be detected using deep learning
the ESP32 are two of the most popular microcontrollers on
algorithms applied on ECG and UCD database [10]. A
combination of SpO2 and ECG features is also used to get the market. They are two small, low-power microcontrollers
sleep apnea analysis.[11]. Contactless solutions using
built on 32-bit dual-core CPUs that can be used to control to ensure adequate oxygen supply to the tissues. Sleep apnea
electronics projects. is another case of shortness of breath. Although there are
other ways to identify it, doing so by analyzing shortness of
breath is more conventional.
The pulse meter is configured such that it first gives a
reliable output. There was ambiguity regarding sensitivity
for the sensor and sudden overshoots in output despite
providing correct threshold measures. The issue was
resolved by taking basic measures. Everything is held
together by the code in fact which is explained in next
section. We set our sensor threshold to 130, as on average
we had a reading of 125. Upon holding breath for quite
some time the reading increased to 132. We therefore set our
threshold to 130. Now what will happen when the reading
Fig 1 exceeds 130? It is understandable what the body will do.
The real question is what this module will do. An actuator
is incorporated with ESP32. Wherever a patient’s pulse rate
Pulse sensor: is greater then 130, actuator starts and completes its cycles
Pulse Sensor is a reflection type photoelectric analog until the pulse falls below the prescribed threshold.
sensor used to measure pulse and heart rate. Having been
worn around the finger or earlobe, the sensor can transmit
the collected analog signal to MCU. And then the analog
signal will be converted into digital signal. With simple For our system, we have used ADC 2 of ESP32 GPIO 15 for
calculation finished, the MCU gets heart rate values and pulse oximeter and we have connected our servo with GPIO
uploads them to computer for drawing the pulse waveform. 26.
Following image, display the pin definition in the code.

Fig 2

SG 90 servo motor:
SG90 is a popular micro servo motor commonly
used in DIY projects. It is a small, low-cost servo motor that
can rotate 180 degrees with a maximum torque of 1.8 kg-
cm. It operates at 4.8-6V and has a weight of approximately
9 grams, making it ideal for small-scale robotics and model
control applications.

Fig 4

Fig 3
IV. SENSOR CONFIRGURATION
III. WORKING To configure a pulse sensor, you'll typically need to connect
It is common for people experiencing a shortage of it to a microcontroller or development board and write code
breath, such as during intense physical activity, anxiety, or to read and interpret the sensor's output. Here are the general
certain medical conditions, to have an elevated pulse rate. steps to configure a pulse sensor:
Shortness of breath can cause the body to go into a state of
increased physiological stress, leading to an increase in heart Gather the required materials: You'll need a pulse sensor
rate. This response is part of the body's natural mechanism module, a microcontroller or development board such as
Arduino or ESP32, jumper wires, and optionally a 3. The'setup()' function: - Connects the servo to the GPIO
breadboard. pin that has been provided (GPIO 26).
- Sets ADC's resolution to 12 bits.
Connect the hardware: Connect the pulse sensor module to - Sets the attenuation of the ADC channel to 11 dB.
the microcontroller or development board. Typically, the - Establishes the Serial communication at a 9600 baud
pulse sensor will have three pins: VCC, GND, and an analog rate.
output pin. Connect the VCC pin to a 5V power source, the
GND pin to ground, and the analog output pin to an analog
input pin on the microcontroller. Use jumper wires to make 4. The 'loop()' function uses the ADC to read the raw
these connections. analogue data from the pulse sensor.
- Converts the analogue value to a range of heartbeats (60
Write the code: Use the appropriate programming language to 200 per minute).
(e.g., Arduino programming language) to write code that - Sends a printout of the heartbeat value to a serial plotter
reads the analog input pin and processes the sensor data. for monitoring.
You'll need to use the microcontroller's analog input - The servo motor is activated to imitate a heartbeat if the
functions to read the voltage values from the pulse sensor. heartbeat value is greater than the threshold set:
- Waits 15ms between each step as the servo motor
Calibrate and interpret the sensor data: Pulse sensors rotates from 0 to 180 degrees in stages of 1 degree.
usually output analog voltage values that correspond to the
detected pulse rate. You may need to calibrate the sensor 5. "delay(50)": Controls the sample rate by adding a 50
based on its specifications or adjust the code to interpret the millisecond delay at the conclusion of each loop.
data correctly. This can involve mapping the analog values
to actual pulse rates and applying filters or algorithms to
extract meaningful information from the sensor readings.

Test and iterate: Upload the code to the microcontroller


and test the setup. Monitor the output, and if necessary, VI. CIRCUIT:
refine your code or adjust the hardware connections to
ensure accurate readings.

V. CODE EXPLAINATION

The purpose of this Arduino sketch is to take data from a


pulse sensor and drive a servo motor based on the heartbeat
signal on an ESP32 board. The servo motor is attached to
GPIO pin 26 (SERVO_PIN) and the pulse sensor is
connected to the ESP32's analogue input.

The sketch is broken into as follows:

First, libraries
- 'ESP32Servo.h': Servo motor control library.
- 'driver/adc.h': A library to access the analog-to-digital
converter (ADC) on the ESP32.

2. Variables and constants: Fig 5


'SERVO_PIN' refers to the GPIO pin (GPIO 26) where the
servo motor is attached.
The ADC channel that is coupled to the pulse sensor (AD1 VII. REVIEW TABLE
channel 0) is designated as "PulseSensorPurplePin."
- 'LED13': The Arduino board's LED (GPIO 2).
- 'Signal': A variable used to store the Pulse Sensor's raw Year Researcher Signal Used
analogue data. 2006 C. Varon ECG
- 'Threshold': The threshold value used to decide when to 2017 S. S. Mostafa ECG,SpO2
"turn on" the Arduino LED and engage the servo motor. 2012 B. Xie and H. SpO2
- 'analogResolution','minAnalogValue', Minn
and'maxAnalogValue': ADC parameters to map the 2015 Nandakumar Audio
analogue value heartbeat range. 2010 Jae Hyuk Shin Pressure Data
-'minHeartbeat' and'maxHeartbeat': The minimum and
maximum heartbeat values mapping.
2019 Haoyu, L Pressue Transdisciplinary Conference on Distributed Diagnosis and Home
Healthcare, 2006. D2H2., 2006, pp. 51–54.
[15] Jae Hyuk Shin, Young Joon Chee, Do-Un Jeong, and Kwang Suk
2006 Park, “Nonconstrained Sleep Monitoring System and Algorithms
D. C. Mack BCG
Using Air-Mattress With Balancing Tube Method,” IEEE Trans. Inf.
Technol. Biomed., vol. 14, no. 1, pp. 147–156, Jan. 2010.
[16] J. A. Kumar P, Nithya V, “Micro System with Mems Sensor for
2008 P. Corbishley Audio
Detecting Sleep Apnea,” ARPN J. Eng. Appl. Sci., vol. 11, no. 3, pp.
2097–2101, 2016.
[17] P. Corbishley and E. Rodríguez-Villegas, “Breathing Detection:
Towards a Miniaturized, Wearable, Battery-Operated Monitoring
System,” IEEE Trans. Biomed. Eng., vol. 55, no. 1, pp. 196–204,
2008.
[18] H. Nakano, M. Hayashi, E. Ohshima, N. Nishikata, and T. Shinohara,
“Validation of a new system of tracheal sound analysis for the
diagnosis of sleep apnea-hypopnea syndrome.,” Sleep, vol.

VI. REFERENCES

[1] T. Young, M. Palta, J. Dempsey, J. Skatrud, S. Weber, and S. Badr,


“The occurrence of sleep-disordered breathing among middle-aged
adults,” New Engl. J. Med., vol. 328, no. 17, pp. 1230–1235, 1993.
[2] T. Young, L. Evans, L. Finn, and M. Palta, “Estimation of the
clinically diagnosed proportion of sleep apnea syndrome in middle-
aged men and women,” Sleep, vol. 20, no. 9, pp. 705–706, 1997.
[3] S. Ancoli-Israel, E. R. DuHamel, C. Stepnowsky, R. Engler, M.
CohenZion, and M. Marler, “The relationship between congestive
heart failure, sleep apnea, and mortality in older men,” Chest, vol.
124, no. 4, pp. 1400–1405.
[4] W. Lee, S. Naqubadi, and M. H. Mokhlesi, “Epidemiology of
obstructive sleep apnea: A population-based perspective,” Expert Rev.
Respir. Med.,vol. 2, no. 3, pp. 349–364, Jun. 2008.
[5] U. Magalang, J. Dmochowski, S. Veeramachaneni, A. Draw, M.
Mador, A. El-Solh, and B. Grant, “Prediction of the apnea-hypopnea
index from overnight pulse oximetry,” Chest, vol. 124, no. 5, pp.
1694–1701, 2003
[6] D. R. Hillman, A. S. Murphy, and L. Pezzullo, “The Economic Cost
of Sleep Disorders.,” Sleep, vo [5] D. R. Hillman, A. S. Murphy, and
L. Pezzullo, “The Economic Cost of Sleep Disorders.,” Sleep, vol. 29,
no. 3, pp. 299–305, 2006.
[7] N. Alghanim, V. R. Comondore, J. Fleetham, C. A. Marra, and N.T.
Ayas, “The Economic Impact of Obstructive Sleep Apnea,”Lung, vol.
186, no. 1, pp. 7–12, 2008.
[8] A. H. Khandoker, J. Gubbi, and M. Palaniswami, “Automated
Scoring of Obstructive Sleep Apnea and Hypopnea Events Using
Short-Term Electrocardiogram Recordings,” IEEE Trans. Inf.
Technol. Biomed., vol. 13, no. 6, pp. 1057–1067, Nov. 2009
[9] C. Varon, A. Caicedo, D. Testelmans, B. Buyse and S. Van Huffel,
"A Novel Algorithm for the Automatic Detection of Sleep Apnea
From Single-Lead ECG," in IEEE Transactions on Biomedical
Engineering, vol. 62, no. 9, pp. 2269-2278, Sept. 2015, doi:
10.1109/TBME.2015.2422378.
[10] S. S. Mostafa, F. Mendonça, F. Morgado-Dias and A. Ravelo-García,
"SpO2 based sleep apnea detection using deep learning," 2017 IEEE
21st International Conference on Intelligent Engineering Systems
(INES), Larnaca, Cyprus, 2017, pp. 000091-000096, doi:
10.1109/INES.2017.8118534.
[11] B. Xie and H. Minn, "Real-Time Sleep Apnea Detection by Classifier
Combination," in IEEE Transactions on Information Technology in
Biomedicine, vol. 16, no. 3, pp. 469-477, May 2012, doi:
10.1109/TITB.2012.2188299.
[12] Nandakumar, R., Gollakota, S., & Watson, N. (2015). Contactless
Sleep Apnea Detection on Smartphones. Proceedings of the 13th
Annual International Conference on Mobile Systems, Applications,
and Services, 45–57. https://doi.org/10.1145/2742647.2742674
[13] Haoyu, L., Jianxing, L., Arunkumar, N., Hussein, A. F., & Jaber, M.
M. (2019). An IoMT cloud-based real time sleep apnea detection
scheme by using the SpO2 estimation supported by heart rate
variability. Future Generation Computer Systems, 98, 69–77.
https://doi.org/https://doi.org/10.1016/j.future.2018.12.001
[14] D. C. Mack, M. Alwan, B. Turner, P. Suratt, and R. A. Felder, “A
Passive and Portable System for Monitoring Heart Rate and Detecting
Sleep Apnea and Arousals: Preliminary Validation,” in 1st

You might also like