Wearable sensor for continuous monitoring of physiological ......Wearable sensor for continuous...
Transcript of Wearable sensor for continuous monitoring of physiological ......Wearable sensor for continuous...
-
FACULDADE DE ENGENHARIA DA UNIVERSIDADE DO PORTO
Wearable sensor for continuousmonitoring of physiological parameters
Miguel Maria Macedo Sampaio Álvares Ribeiro
Mestrado Integrado em Engenharia Eletrotécnica e de Computadores
Supervisor: Luis Miguel Pinho de Almeida
February 8, 2020
-
c© Miguel Maria Macedo Sampaio Álvares Ribeiro, 2020
-
Abstract
Providing high quality health care to a mass population is becoming one of the great endeavorsof modern society. In order to do so, there is a urge to embrace the use of new technologies thatcan provide comfort while ensuring the safety and reliability of traditional methods.
The system hereby proposed ought to be capable of monitoring a person’s vital signs thereforebeing very flexible regarding its application scenarios. It can be used not only in emergencywards and screening diseases but also in a home environment to monitor elderly people or youngchildren. Furthermore, it is not exclusive to monitoring and preventing diseases, it can also be aninstrument that aids sports training at high intensity levels.
This product can measure a patient’s heart rate and oxygen saturation levels ensuring comfortand easy usage. Another advantage when compared to traditional machines used to fit the samepurpose is the fact that it is much cheaper, takes up less space and it encompasses two functional-ities that are otherwise measured with different machines.
This system has two major components, an ESP32 microprocessor and a MAX30100 Pho-toPletysmoGraphy (PPG) sensor. The ESP32 module was chosen due to its computing capacity(dual-core 32-bit processor), having a WiFi module built in with full TCP/IP stack and having3 pre-defined sleep modes to reduce power consumption. The MAX30100 sensor was pickedbecause it is a compact and small module with simple usage.
Furthermore, the goal of this dissertation is to build this system to be robust and reliable, whileenergy efficient, maximizing its battery life while not compromising its logical correctness.
The configuration chosen that produced steady results whilst consuming lowest energy possi-ble was: 37 mA of current for the IR LED, sampling frequency of 50 Hz and pulse width of 200µs. When using the power saving modes the battery life extended up to 277% the value measuredin normal operating mode.
i
-
ii
-
Acknowns
To the greatest extent possible, i would like to thank my parents for the help and support theynever ceased to give me, no matter what. To all my family, especially my grandparents and mygodparents for their love, kindness and wisdom.
I would also like to thank Professor Luís Almeida who proved to be the best supervisor onecould ever imagine.
Um obrigado muito especial à minha Tininha pela paciência que tem e a ajuda que me dá, é omeu orgulho!
To my girlfriend. Thank you Mariana for all your love and support, and for making me a betterperson.
To all my graduation friends , particularly CeVas, Pissadas, Priskas, Radares and Zed for theirhelp (Cenisgas) and the good moments when we were together.
And last, but definitely not least, i would like to thank Carido and Rafa for being constantmorons and always cheering me up.
Miguel Maria Macedo Sampaio Álvares Ribeiro
iii
-
iv
-
“I act like everything is fine, but deep down in my shoe, the sock is sliping”
v
-
vi
-
Contents
1 Introduction 11.1 Context and Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3 Structure of the document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 Bibliographic research 32.1 Monitoring physiological signals . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1.1 Heart rate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.1.2 Oxygen saturation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Photoplethysmography sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.3 Wearable monitoring systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.3.1 Home monitoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82.3.2 Sports training . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.3.3 Emergency wards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3 Photoplethysmography sensor based on ESP32 133.1 ESP32 platform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.2 MAX30100 sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2.1 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153.3 Connecting ESP32 and MAX30100 . . . . . . . . . . . . . . . . . . . . . . . . 173.4 Programming the system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.4.1 Reading samples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183.4.2 Heart rate monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193.4.3 Pulse oximeter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233.4.4 Code organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.5 WiFi transmission . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273.6 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4 Experimental characterization 294.1 MAX30100 parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294.2 Quality of Service experiments . . . . . . . . . . . . . . . . . . . . . . . . . . . 304.3 Energy consumption experiments . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.3.1 Sleep modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374.4 Designing a production-ready device . . . . . . . . . . . . . . . . . . . . . . . . 454.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
vii
-
viii CONTENTS
5 Conclusion 475.1 Critical Observations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485.2 Future work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
References 49
-
List of Figures
2.1 QRS complex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42.2 PPG sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1 Graphical Representation of the FIFO Data Register . . . . . . . . . . . . . . . . 163.2 Schematic of the system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183.3 Plot of values unfiltered . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203.4 Plot of values after offset removal . . . . . . . . . . . . . . . . . . . . . . . . . 213.5 Plot of values after offset removal and median filtering . . . . . . . . . . . . . . 223.6 Plot of values after offset removal, median and butterworth filtering (final signal) 233.7 State Machine for beat detection . . . . . . . . . . . . . . . . . . . . . . . . . . 243.8 Empirical and Theoretical R to SaO2 . . . . . . . . . . . . . . . . . . . . . . . . 253.9 Execution of tasks with CH1="task-BMP"" and CH2="task-sleep" . . . . . . . . 263.10 Frequency of task-BPM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273.11 Execution time of task-BPM . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.1 HR only mode (allowed settings) . . . . . . . . . . . . . . . . . . . . . . . . . . 304.2 HR and SpO2 mode (allowed settings) . . . . . . . . . . . . . . . . . . . . . . . 304.3 Box plot of Currents Consumed while varying Frequency for 200µs Pulse Width 344.4 Box plot of Currents Consumed while varying Frequency for 400µs Pulse Width 354.5 Box plot of Currents Consumed while varying Frequency for 800µs Pulse Width 354.6 Box plot of Currents Consumed while varying Frequency for 1600µs Pulse Width 364.7 Plot of average Current Consumed while varying Frequency for each Pulse Width 364.8 Plot of average Current Consumed while varying IR LED current with 200 µs
Pulse Width and 50Hz of sampling Frequency . . . . . . . . . . . . . . . . . . . 374.9 Plot of average Current Consumed while varying Pulse Width for each Frequency 374.10 Surface created with average current consumed for each configuration with LED
current = 43.6 mA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384.11 Current consumed in normal mode with task-sleep deactivated . . . . . . . . . . 404.12 Current consumed in modem-sleep mode with task-sleep deactivated . . . . . . . 404.13 Current consumed in normal mode with task-sleep active for 10 seconds . . . . . 414.14 Current consumed in modem-sleep mode with task-sleep active for 10 seconds . 414.15 Current consumed in light-sleep mode with task-sleep active for 10 seconds . . . 424.16 Current consumed in deep-sleep mode with task-sleep active for 10 seconds . . . 424.17 Current consumed in modem-sleep combined with light-sleep with task-sleep ac-
tive for 20 seconds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434.18 Current consumed in modem-sleep combined with deep-sleep with task-sleep ac-
tive for 40 seconds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
ix
-
x LIST OF FIGURES
-
List of Tables
3.1 ESP32 specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.2 Possible MAX30100 Sampling Frequency values . . . . . . . . . . . . . . . . . 163.3 Possible LED Pulse Width values . . . . . . . . . . . . . . . . . . . . . . . . . . 173.4 Possible LED current values . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.1 Results for IR LED current = 50 mA) . . . . . . . . . . . . . . . . . . . . . . . 314.2 Results for IR LED current = 43.6 mA . . . . . . . . . . . . . . . . . . . . . . . 314.3 Results for IR LED current = 37 mA . . . . . . . . . . . . . . . . . . . . . . . . 324.4 Results for IR LED current = 30.6 mA . . . . . . . . . . . . . . . . . . . . . . . 324.5 Results for IR LED current = 24 mA . . . . . . . . . . . . . . . . . . . . . . . . 324.6 Results for IR LED current = 17.4 mA . . . . . . . . . . . . . . . . . . . . . . . 334.7 Results for IR LED current = 11 mA . . . . . . . . . . . . . . . . . . . . . . . . 334.8 Results for IR LED current = 4 mA . . . . . . . . . . . . . . . . . . . . . . . . 334.9 Current Consumption Average and Standard Deviation, and Battery life for Nor-
mal operating mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444.10 Current Consumption Average and Standard Deviation, and Battery life for Modem-
sleep operating mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444.11 Current Consumption Average and Standard Deviation, and Battery life for Light-
sleep mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444.12 Current Consumption Average and Standard Deviation, and Battery life for Deep-
sleep mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444.13 Current Consumption Average and Standard Deviation, and Battery life for Mo-
dem sleep combined with Light-sleep or Deep-sleep mode . . . . . . . . . . . . 44
xi
-
xii LIST OF TABLES
-
Abbreviations and Symbols
AC Alternate CurrentADN Application Dedicated NodeADC Analog to Digital ConverterAE Application EntityBCG BallistocardiogramBPM Beats Per MinuteCSE Common Service EntityDC Direct CurrentDMA Direct Memory AccessECG ElectrocardiogramFIFO First In First OutHgbO2 OxyhemoglobinHgb DeoxyhemoglobinIN Infrastructure NodeIR Infra-RedIoT Internet of ThingsLED Light Emitting DiodePPG PhotoplethysmogramRMS Root Mean SquareSaO2 Arterial Oxygen SaturationSCL Serial ClockSDA Serial DataSO2 Oxygen SaturationSpO2 Peripheral Oxygen Saturation
xiii
-
Chapter 1
Introduction
1.1 Context and Motivation
Nowadays, the average life expectancy is steadily increasing every year due to many reasons.
Much of that increase is due to healthcare and to falling death rates amongst women and young
children, especially from infectious diseases. Cardiovascular diseases are amongst major death
causes worldwide [1]. Therefore, unobtrusive long-term monitoring of patient’s vital signs can
lead to early detection of some anomalies and also to prevent, cure or manage some diseases
like Atrial Fibrillation, hypoxemia, tachycardia or even ventricular fibrillation (that may lead to
sudden cardiac arrest). Moreover, home monitoring can help reducing the amount of time spent
in hospitals and the overall costs of treatments [2]. At the moment, machines used to monitor
patients’ vital signs are expensive and take up a lot of space. Most of them are uncomfortable and
not easy to use. In addition, when in an hospital emergency room environment, it is mandatory
that you go through a triage process (if not in a critical state), which can typically take a long time,
before your vital signs can be monitored.
In this dissertation a solution is proposed: a non-invasive, cheap and easy to use device capable
of making measurements at the skin surface and send the data collected using wireless communi-
cation to a computing node. This would be a major improvement, not only concerning the general
health but also comfort-wise. This node must be capable of receiving data from a sensor that ac-
quires vital signs, process this data in real-time and send to a monitoring station that displays the
patient’s health state. The utilization of WiFi in contrast to other types of wireless communication,
such as Bluetooth, increases the range of the module and facilitates its connection to existing WiFi
infrastructures, therefore making it more versatile. Other possible scenarios of usage, include care
homes for elderly people, babies, major sports events or even remote systems that allow patients
to be monitored at home.
1
-
2 Introduction
1.2 Objectives
The purpose of this work was to engineer a system capable of measuring an individual’s heart rate
and oxygen saturation levels. This module is formed by two major components: an ESP32 micro-
processor and one MAX30100, a photoplethysmography sensor. This system must be robust and
be able to produce results within certain standards, to ensure this, quality of service test ought to
be conducted. Furthermore, evaluate the system’s energy consumption when using different con-
figurations for the MAX30100 sampling method, in order to assess the device’s lifetime between
charges using a small form-factor rechargeable battery.
1.3 Structure of the document
This Document is arranged in 5 chapters, each one containing a brief conclusion:
1) Introduction - This section, summarizes the work ahead, describing it broadly.
2) Bibliographic Research - This section presents an in depth research on similar systems to
analyse their pros and cons in order to design an innovative system with unique capabilities.
3) Photoplethysmography Sensor based on ESP32 - This is a thorough description of the
system is made including the characterization of each element (ESP32 and MAX30100) as well
as detailed information about their connection and programming. Additionally, the WiFi commu-
nication is approached and explained.
4) Experimental Characterization - This section focuses on the experimental results obtained
from different possible configurations of the system. These configurations vary in: Sampling
Frequency, Pulse Width and LED current. This assessment aims to analyze the quality of service
and proper lifetime of the device.
5) Conclusion - This section summarizes and reflects on the work that was done, assessing
whether the goals were achieved or not. A last paragraph mentions work to further improve the
module built in this project.
-
Chapter 2
Bibliographic research
This Chapter seeks to identify and study the most common and effective ways of monitoring
physiological signals focusing specifically on heart rate and oxygen saturation levels since they
stand amongst the most valuable and useful parameters to monitor.
2.1 Monitoring physiological signals
Over the last decades, monitoring physiological signals has become increasingly popular, not
only as a training aid for sports but also to improve the patient’s safety in the ordinary living
environment. In fact, the analysis of these parameters can be used to diagnose certain illnesses
like tachycardia (high heart rate at rest, typically above 100 beats per minute), bradycardia (slow
heart rate, below 60 beats per minute), chronic arterial insufficiency (CAI) of lower extremities
(SpO2 values can reach below 50 % in critical stages), etc.
2.1.1 Heart rate
Heart rate corresponds to the number of contractions of the heart per minute, also known as
beats per minute (BPM). This value can vary depending on the individual’s body need to absorb
oxygen and/or secrete carbon dioxide.
The normal value for an adult’s heart rate is within the range 60–100 BPM[3]. Many activities
influence heart rate values such as physical exercise, sleep, illness, and anxiety.
Although experiences to measure heart rate had been made before (starting as early as 1872
[4]), it was not until 1901 that Willem Einthoven built the first practical electrocardiogram (ECG)
[5]). Einthoven’s work concerning ECG later awarded him with a Nobel prize (1924) [6].
In order to measure a patient’s heart rate there are two main types of technologies: Electrical
and Optical.
Electrical technologies can detect small electrical changes that come as a consequence of car-
diac muscle depolarization and repolarization. They consist of two main elements: a transmitter
and a receiver. The transmitter is commonly worn on a chest strap whereas the receiver’s main
function is to display to reproduce the results obtained so that the user has access to them.
3
-
4 Bibliographic research
Figure 2.1: QRS complex
In contrast, optical monitors use light-based sensors to detect changes in the patients blood
volume in the microvascular tissue. This is accomplished by illuminating the skin and quantifying
changes in the light absorption [7].
Both methods rely on algorithms that process the obtained data (filtering, offset removal and
noise removal) like Pan-Tompkins [8].These automated methods aim to detect the QRS complex
found in ECGs. This signal corresponds to the main spike in the electrocardiogram. The QRS
complex (Figure 2.1) comprehends three distinct waves seen on a typical ECG: Q, R and S waves.
Is usually lasts from 0.08 to 0.10 seconds and corresponds to the electrical stimulus spread through
ventricles [9].
2.1.1.1 Ballistocardiogram
A ballistocardiogram (BCG) represents the recording of the mechanical activity of the heart
through the movements of the body imparted by the ballistic forces (recoil and impact)[10]. The
graphic obtained resembles a ballistic trajectory where the upward motion is due to cardiac con-
traction and ejection of blood whereas the downward motion comes from the deceleration of blood
flow through larger blood vessels [11].
This method was discovered in late 19th century [12], although its major research was made
in the 1940’s. It has started to decrease in popularity around 1980 [13] due to some reasons: an
absence of a standard regarding the measurement techniques (different methods lead to different
signals [14]), a lack of understanding precisely the BCG waveform and its physiological meaning,
adding to this there are no ground rules regarding the interpretation [15].
-
2.1 Monitoring physiological signals 5
2.1.1.2 Electrocardiogram
An electrocardiogram (ECG) is a test that produces a graph of voltage versus time which
can be used to study the patient’s heart activity[16]).It is a safe, non-invasive and painless test
with no major risks. It assesses heart rhythm, chamber size, and muscle thickness. For many
years, electrocardiogram (ECG) has been used as the most dominant cardiac monitoring technique
to identify cardiovascular abnormalities and detect irregularities in heart rhythms [17][18]. In
addition it has broad applications concerning clinical diagnosis and prognosis of cardiovascular
diseases like arrythmias, congenital heart disease, coronary artery disease, heart attacks, hearts
failure, cardiomyopathy, valvular heart disease, among others [19][20].
The signal is measured by placing electrodes on the skin level throughout the patient’s body.
As mentioned before, this procedure works due to the electrodes’ capability of detecting small
electrical variations. These come as a consequence of the heart’s activity (polarization and depo-
larization for each cardiac cycle).
ECGs can be used not only to check on cardiac diseases, but also pulmonary like a cardiopul-
monary exercise test (CPET).
The four different types of electrocardiograms are: Exercise ECG (stress test), Holter monitor,
Resting 12-lead ECG and Signal-averaged electrocardiogram. The most commonly used method
is the 12 lead ECG and it can be part of a routine checkup to screen for heart conditions before
any symptoms develop.
Here, ten electrodes are placed on the patient’s limbs and on the chest [21]. This allows the
heart’s electrical potential to be monitored from 12 different angles ("leads"). Usually the exam
lasts for 10 seconds which is enough to capture the overall magnitude and direction of multiple
cardiac cycles [22].
2.1.1.3 Photoplethysmogram
Photoplethysmography (PPG) is a method to optically record an individual’s heart activity.
The most commonly used device to obtain a PPG is a pulse oximeter. A light source is used
(usually one or more LEDs) and a photo-detector at the skin level in order to measure volumetric
variations of blood circulation [23][24].
With each cardiac cycle, blood is pumped out of the heart into the peripheries, causing a major
increase in pressure levels throughout all vessels. Although the pressure dumps throughout the
blood’s route, at a peripheral level it is still enough to capture the heart’s motion. This sudden rise
of pressure is represented by the main peak in the PPG. The waveform represented varies in each
patient and can be used for early detection and diagnosis of various cardiovascular illnesses that
may even appear later in life [25].
2.1.2 Oxygen saturation
Oxygen saturation is measured calculating the fraction of oxygen-saturated hemoglobin rela-
tive to the total hemoglobin in an individual’s blood. In other words, it is a measure of how much
-
6 Bibliographic research
hemoglobin is currently bound to oxygen compared to how much hemoglobin remains unbound
to it. Normal values for an adult human are above 90 %. Levels below 90 % are called hypoxemia
[26] and below 80 % start to compromise some organs functionality (mostly brain and heart, but
also kidneys).
The most common and effective device used to measure a patient’s oxygen saturation level is a
pulse oximeter. The use of pulse oximetry has become a standard in modern medicine. It is often
regarded as a fifth vital sign [27].
2.2 Photoplethysmography sensors
Pulse oximetry, as it was already mentioned, is an unobtrusive, low cost and non-invasive
method for monitoring a patient’s arterial oxygen saturation level (SaO2). SaO2 is calculated esti-
mating the oxygenated hemoglobin (oxyhemoglobin - HgbO2) and the non-oxygenated hemoglobin
(deoxyhemoglobin - Hgb) levels [28].It can serve as an early warning signal of impaired oxygena-
tion in a given patient, while avoiding the pain and risks of arterial puncture. The clinician should
be aware of the pathophysiology/background of pulse oximetry to use this technology appropri-
ately.
A pulse oximeter is an optical sensor with three main components: one or more light emitting
module/s, one or more photo-detectors and a microprocessor to process the obtained data.
This method is based upon spectrophotometric principles and on the Beer-Lambert law [29].
This law states that all substances have a unique absorbance spectrum, meaning that oxyhe-
moglobin and deoxyhemoglobin absorb light differently. HgbO2 compared to Hgb absorbs more
infrared light (wavelength around 940 nm) and less red light (wavelength around 660 nm) [30].
The light intensity that passes through the blood (Lo) is proportional to the intensity of incident
light (Li) minus the light absorbed (Figure 2.2). The amount of light absorbed depends upon the
concentration of solute (C), the path length light has to travel through the solution (D), and the
molar extinction coefficient of the solute (ε). ε is a constant for Hgb at a given wavelengthabsorbance (Equation 2.1), blood is the solvent and oxyhemoglobin is the solute.
Absorbance = ε.C.D = logLiLo
(2.1)
In conclusion, when there is a pulse, the blood gets renewed with HgbO2, leading to an in-
crease in infrared and red light absorptions. These values enable the calculation of the ratio of
HgbO2 to the reduced Hgb levels, and then to plot this ratio against a standardized calibration
curve in order to derive the SaO2 measurement. This curve varies within each individual and there
is a standard derived from healthy adult volunteers [31].
The sensor must be located on a vascular bed [32] (for example finger, toe, earlobe, forehead).
The sensor also works with light reflectance instead of transmittance (when used in forehead it is
mandatory). There are no differences in ability of the different type of sensors to obtain readings
-
2.3 Wearable monitoring systems 7
Figure 2.2: PPG sensor
and no distinction in the accuracy of these readings [33]. In some cases, reflection sensors give
readings earlier and at a lower pulse pressure [33]. Furthermore, using light reflectance does imply
an increase in the user’s comfort and easier usage.
Pulse oximetry is considered safe (although some reports of incidents like burns and pressure
necrosis have appeared [34]) and has a low failure rate of less than 5 %. In addition, these failures
tend to occur in elderly and sicker patients during long surgical procedures [35].
As everything, pulse oximetry as its problems:
1) It is difficult to properly place the probe, since the distance between the sensor and the
user has to be constant.
2) Insufficient signal which can occur from hypoperfusion (insufficient blood flow) or ex-
cessive signal as a result of excessive motion or ambient light.
3) Does not measure ventilation.
4) Reference data may not correspond the patient’s own curve.
5) Deeply pigmented skin may decrease pulse oximetry’s accuracy, although this is not as
relevant as the other cons.
6) The readings are more accurate at higher levels of SaO2.
2.3 Wearable monitoring systems
A wearable system is a smart electronic device that can be worn or incorporated in a piece
of clothing. They are capable of transferring data over a network without the need for human
interaction, thus being a good example of an Internet of Things (IoT) device [36][37].
This section focuses on existing wearable monitoring systems. The main goal is to find ex-
amples for each use-scenario in order to retrieve ideas to conceive a robust and efficient system,
-
8 Bibliographic research
specifying the software architecture and the hardware used. Furthermore, a description of one
system for each of the following main use-scenarios are: home monitoring, sport training and
emergency wards.
2.3.1 Home monitoring
This type of system allows the patient to be monitored at home, ensuring safety and comfort.
Thus, it can be used for multiple purposes: elderly people, babies, some diseases that on the one
hand require monitoring, but, on the other hand, the patient is not in a critical state. When the
sensor communicates wirelessly with another component worn or carried by the user, it forms a
wireless body-area network (WBAN), which can also include other devices. The work in [38]
shows an example of a WBAN-based system for health monitoring at home proposed for a contin-
uous tracking of the patients’ heart rate. The proposed architecture is multi-layered with the first
tier consisting of multiple nodes which have the following functions:
1) Tracking one or more physiological signals.
2) Processing the signal/s (filtering, feature extraction and feature recognition).
3) Storing the already processed data.
4) Sending the data to another node/s and/or a WBAN server.
These sensors communicate directly to a WBAN gateway that is either plugged into a home
server or a wired/wireless network appliance (recently, the gateway is frequently instantiated on
a smartphone which connects the WBAN to the Internet). The WBAN gateway on one hand for-
wards the messages to a medical server, on the other hand, by sending beacon messages, provides
time synchronization. If by any reason the user steps out of the gateway’s range, the sensors
automatically start buffering data locally. Upon getting within range and the WBAN link being
reestablished, the sensors automatically upload stored sensor and event data.
2.3.1.1 Software
Embedded sensor software runs on the micro-controller on a T-mote sky platform (wireless
sensor module) and it is responsible for the sampling and acquisition, real-time processing, event
queuing, and WBAN communication.
The home health server in [38] communicates with the sensors in the WBAN, merging event
messages as they arrive from the sensors, creating health monitoring session files for each user,
and providing them feedback. This software runs on a home PC and was developed using C Sharp
and Microsoft .NET 2.0 framework. This server is capable of WBAN communications using one
of two options: a directly connected network coordinator via USB or a remote network coordinator
connected via a T-mote connect, where messages between the server and the network coordinator
are sent over a local network using reliable TCP/IP sockets.
-
2.3 Wearable monitoring systems 9
2.3.1.2 Hardware
In [38] two options were considered for heart rate sensors: a single-channel bio amplifier for
three-lead ECG and standard Polar belt. The first one can either send a raw ECG signal (already
filtered) or R-peak events recognized by the software. With respect to the second version, it can
record each heartbeat without the need of ECG electrodes, leading to an increase of the patient’s
comfort and also easier usage. The WBAN gateway is implemented using a standard wireless
platform. The home health server application runs on a personal computer.
2.3.2 Sports training
Monitoring an athlete’s physiological signals can be of major importance in order to make sure
that they are staying within the prescribed zones of intensity during periods of work and rest as
well as ensuring that they get a maximum benefit before training. The most common systems use
a heartrate monitor since it is the most significant signal when it comes to exercise intensity.
A system was studied [39] that has a mesh network: the transmission of data is made from
each node to its nearest neighbors. This architecture has several advantages such as being self-
configuring, self-healing and easy to maintain. This system allows many athletes to be monitored
at the same time, each wearing a sensor capable of transmitting data to a monitoring center via
radio communications.
2.3.2.1 Software
The software for the system in [39] was developed with an IDE to program nRF24AP1 as a
receiver. Software serial library enabled connecting the nRF24AP1 to the ATMega168 and lastly,
LabVIEW was used to display the data received in the computer.
2.3.2.2 Hardware
The system uses a Garmin Heart-rate strap to measure the user’s heartbeat which is connected
to the nRF24AP1 processor via ANT+ wireless protocol for peer to peer comunication. ANT+ is a
variation of the previous ANT (Adaptive Network Topology) protocol. This technology defines a
wireless communication protocol stack that enables hardware to operate in the 2.4 GHz ISM band
to communicate by establishing standard rules for co-existence, data representation, signaling,
authentication, and error detection. Each receiver consists of a microcontroller (ATMega168),
a nRF24AP1 (ultra-low power single-chip radio transceiver with embedded ANT protocol for
personal area networks) and an XBee transmitter (radio communication based in the 802.15.4-
2003 standard, designed for point-to-point and star communications at over-the-air with a bau rate
of 250 kbit/s). The receiver stores the data and assigns it an ID before transmitting it to the server.
The sensors transmit data via radio communication to a monitoring station that comprise a XBee
receiver connected to the server computer.
-
10 Bibliographic research
2.3.3 Emergency wards
This is a critical scenario since it is related to ensuring health care, trying to avoid deaths and
prevent potentially adverse events. This scenario imposes constrains on autonomy, connectivity,
interoperability and delay, and the consequences of not respecting these constraints may be ex-
ceptionally severe if not handled properly. A solution is proposed [40] using a full internet-based
architecture and open protocols from wristband wearable sensors up to a monitoring system. The
system follows the oneM2M publisher-subscriber protocol, particularly the OM2M open-source
implementation and is composed of:
1) Application Dedicated Node (ADN) which contains an Application Entity (AE) that im-
plements the service logic.
2) Infrastructure Node (IN) holding a Common Service Entity (CSE).
3) IN-AE is an AE that is registered with the CSE in the IN.
The ADN-AE oversees the sensor and can decide when it should transmit its data (periodically
or not) to control the battery lifetime of the wristband.
The IN-CSE is the infrastructure core, consisting of an M2M broker that receives and dis-
tributes messages. The IN-AE is the monitoring application in the infrastructure side that is con-
nected to the broker. The IN-AE is an openEHR service (an open source Electronic Record Sys-
tem) provided with M2M capabilities. Every time a patient’s wristband is assigned to the patient’s
EHR, the IN-AE subscribes to the respective resource in the IN-CSE. Then, the IN-AE starts
receiving notifications of the data published by the device.
This paper also addresses the tradeoff between time to wake-up (end-to-end latency) and en-
ergy consumption (battery lifetime), by exploring different sleep functions that enable the micro-
processor to enter low-power consumption modes. These modes differ by shutting down the WiFi
circuit, for a certain time, only, without losing the connection to the Access Point (modem-sleep),
or in addition the crystal oscillator-based system clock thus suspending the CPU temporarily,
while keeping a less precise RTC clock (light sleep) or even shutting down the whole module
(deep-sleep) which breaks WiFi connectivity to the AP.
2.3.3.1 Software
The embedded software (for the wristband sensors) runs on the ESP8266 framework provided
by Espressif Systems, v1.2, running on FreeRTOS. OpenEHR is a non-proprietary standard for
e-health, consisting of open specifications, clinical models and software that can be used to build
information and interoperability solutions for healthcare. Its standardized EHR architecture based
on a multi-layered approach separates information from knowledge.
The OM2M broker was used as reference implementation for the oneM2M standard. The Con-
strained Application Protocol (CoAP) was implemented over UDP with non-confirmable messages
between the publisher and the broker to reduce overhead.HTTP protocol was used over TCP for
-
2.4 Conclusion 11
high reliability between the broker and the subscriber. The ESP8266 publisher client was imple-
mented using C and the OpenEHR subscriber client using Java.
2.3.3.2 Hardware
The sensor used is optical and tracks HR and pulse oximetry (oxygen saturation).
The ADN-AE runs on an ESP8266 module and supports the use of buffers, which are also
used to holda data during temporary connectivity losses. The data is sent via a WiFi network
to the IN-CSE that acts as a broker in the communication model. These modules offer multiple
sleep modes that grant them the ultra-low-power feature, imposing different trade-offs between
end-to-end latency and energy consumption.
The IN-CSE runs on a dedicated server, in a computerwhile the IN-AE (subscriber client) was
running on another computer. They were connected through a Fast Ethernet network (100Mb/s).
The ESP8266 publisher client (ADN-AE) connected to the broker via WiFi using the default
802.11 protocol.
2.4 Conclusion
In this chapter we made a description of the most common techniques to measure heart rate
and oxygen saturation. Focusing particularly on the techniques that are the least invasive and
inexpensive. Then a description of three example systems was made, found in the literature. These
examples are within this dissertation’s interest since they aim three typical use cases, namely,
home monitoring, sports events and emergency wards. These systems allow understanding the
limitations of current technologies so that they can be mitigated.
This work will focus on the low-level implementation of the sensor, with a similar high-level
architecture as presented in the Emergency ward example in (2.3.3).
-
12 Bibliographic research
-
Chapter 3
Photoplethysmography sensor based onESP32
The Internet of Things (IoT) market has expanded at a very fast pace over the last few years,
trying to keep up the demand regarding communication and control for a wide range of devices
and gadgets.
This chapter describes the system proposed, which follows the IoT paradigm, its components
and the system as a whole. A decision was made to use the ESP32 processor as the sensor’s
platform, using its computing power (32-bit dual-core processor) for the necessary processing of
signal, and the WiFi interface to connect to the system infrastructure. Then,a PPG sensor is used,
namely the MAX 30100, for which there is plenty information available online.
3.1 ESP32 platform
The ESP32 is a family of processors created by Espressif Systems released in September 2016
as successors for the ESP8266 modules. This system is powered by a dual-core 32-bit Xtensa LX6
microprocessor, which has a Harvard architecture. All memory slots and peripherals are located
on the data bus and/or the instruction bus of these CPUs. The address mapping of two CPUs
is symmetric, meaning that they use the same addresses to access the same memory. Multiple
peripherals in the system can access embedded memory via DMA. The two CPUs are named
“PRO-CPU”, which is used to run the WiFi software and TCP/IP protocol stack, and “APP-CPU”,
used to run the application’s software. However, for most purposes the two CPUs are identical and
share the same memory making them interchangeable.
They are the a very good solution for a wearable system like this since they are very small,
have a WiFi module built in and come with pre-defined sleep modes that aim power saving.
Concerning its battery life, that is not a simple matter since the ESP32 can consume up to 260
mA. Thankfully, there are a lot of ways this value can be decreased. For example, it already comes
with 3 pre-defined power saving modes: modem-sleep, light-sleep and deep-sleep (currents can
get as low as 20 µA). Each one of them turns off parts of the system in order to save energy.
13
-
14 Photoplethysmography sensor based on ESP32
There are 5 variations of the ESP32 chip:
1) ESP32-DOWDQ6.
2) ESP32-D0WD.
3) ESP32-D2WD.
4) ESP32-S0WD.
5) ESP32-PICO-D4.
Primarily these relate to how many CPU cores (1 or 2) and whether there is embedded flash
memory or not.
For this project ESP32-D2WD was chosen, which combines 16 MB of flash memory and a
dual core processor.
Table 3.1: ESP32 specifications
Voltage 3.3 VCurrent consumption (I) 20 µA < I < 260mA
Processor Speed Dual 240 MHzInternal ROM memory 448 KBytes
RAM memory 520 KBytesRTC FAST Memory 8 KBytesRTC SLOW Memory 8 KBytes
GPIOs 34Analog to Digital pins 7
Maximum concurrent TCP connections 16DMA 16 capable modules
802.11 support 11b/g/n/e/iBluetooth BLE
SDIO Slave 1EMAC 1
SDMMC 1SPI 3I2S 2I2C 2
UART 3
3.2 MAX30100 sensor
The MAX30100 is a highly integrated solution as pulse oximeter or a heart rate monitor de-
signed for the requirements of wearable devices. It comprehends two LEDs: red (λR = 660nm)
-
3.2 MAX30100 sensor 15
and infra-red (λIR = 880nm), a photodetector, optimized optics, and low-noise analog signal pro-cessing to aid in detecting pulse oximetry and heart-rate signals. The power supply can be any
value between 1.8V and 3.3V and it has an insignificant standby current consumption.
At the hardware level, only 4 pins are going to be used from the MAX30100: Vcc, Gnd,
SDA and SCL. This sensor provides a 16-bit FIFO buffer to store each sample (HR and SpO2),
enabling it to be connected to a shared bus. The MAX30100 includes a discrete time filter to reject
50Hz/60Hz noise.
3.2.1 Registers
This sensor can be fully customized through its registers: LED current, Pulse width and
Sampling Frequency. A full description of all registers (each register is 8bits long) is listed below
(Chapter 4.1, page 29 for a list with all possible configurations).
3.2.1.1 FIFO
The MAX30100 sensor is equipped with a FIFO buffer which is accessed via Inter-Integrated
Circuit protocol (I2C).
All registers concerning the FIFO (0x02-0x05) are 4 bits long with the exception of "FIFO
Data". All of them are listed bellow:
1) FIFO write pointer (0x02): points to the location where the sensor shall write the next
sample. It automatically advances with each sample pushed into the FIFO.
2) FIFO Overflow Counter (0x03) : When the FIFO is completely full, samples are not
pushed on to the FIFO, they are lost instead. OVF-COUNTER counts the number of samples that
have been lost.
3) FIFO Read Pointer (0x04): points to the location where the ESP32 can get the next
sample from the FIFO via I2C. Similarly to FIFO write pointer, it automatically advances each
time a sample is withdrawn from FIFO.
4) FIFO Data (0x05): The FIFO Circular Buffer has a capacity of 64 bytes: 16 samples of
4 bytes (2 bytes for each LED sample). This register points to the next sample to be read from the
FIFO. Unlike previous ones, FIFO DATA register does not automatically increment the register
address. Since each sample has 4 bytes of data and FIFO Data register has only 1 Byte, it has to
be read 4 times to get one sample (and incremented in order not to read the same sample again).
When using lower ADC resolution the data is left-justified as observed in Figure 3.1, meaning
that the most significant bit is always in the left-most position, the most significant bit, regardless
of ADC resolution (sample size).
3.2.1.2 Mode configuration
This register allows the user to choose between two operating modes:
-
16 Photoplethysmography sensor based on ESP32
Figure 3.1: Graphical Representation of the FIFO Data Register
1) Heart Rate only: MODE[2:0] = 010.
2) Heart Rate and SpO2: MODE[2:0] = 011.
3.2.1.3 SpO2 configuration
This register (0x07) has the following control bits:
1) SpO2 High Resolution Enable [6]: When this bit is set to high SpO2 ADC resolution is
16-bit with 1600µs pulse width. Otherwise the ADC resolution and pulse width can be configuredto any chosen value.
2) SpO2 Sample Rate Control [4:2]: sets the effective sampling rate for both IR and red
LED samples.
3) LED Pulse Width Control [1:0]: these two bits are used to choose the pulse width which
is directly related to the ADC sample size.
Table 3.2: Possible MAX30100 Sampling Frequency values
SPO2-SR[2:0] Samples per Second000 50001 100010 167011 200100 400101 600110 800111 1000
-
3.3 Connecting ESP32 and MAX30100 17
Table 3.3: Possible LED Pulse Width values
LED-PW [1:0] Pulse Width (µs) ADC Resolution (bits)00 200 1301 400 1410 800 1511 1600 16
3.2.1.4 LED configuration
This register (0x09) controls both LEDs current. Bits [7:4] for red LED and [3:0] for IR LED.
Table 3.4: Possible LED current values
Red-PA[3:0] or IR-PA[3:0] Led Current (mA)0000 0.00001 4.40010 7.60011 11.00100 14.20101 17.40110 20.80111 24.01000 27.11001 30.61010 33.81011 37.01100 40.21101 43.61110 46.81111 50.0
3.3 Connecting ESP32 and MAX30100
The data collected from the sensor is sent to the microprocessor using I2C. This protocol is
a synchronous, multi-master, multi-slave, half-duplex serial computer bus invented by Philips in
1982. It covers transmission speeds from 0.1 to 5 Megabits per second. In order to implement such
communication it is needed to connect two signals: Serial Data (SDA) and Serial Clock (SCL).
The data is sent in 9-bit packages which contain 8 data bits and one bit for acknowledge purposes.
The schematic of the connection between the MAX30100 and the ESP32 can be seen in Figure
3.2.
-
18 Photoplethysmography sensor based on ESP32
Figure 3.2: Schematic of the system
3.4 Programming the system
The ESP32 module was programmed in C with compliance to MISRA C standards.
Expressif systems offers a robust software application development environment to help de-
velopers in order to easily take advantage of their computing modules named Espressif IoT Devel-
opment Framework (ESP-IDF). This platform allows configuring the microprocessor parameters,
building the project and flashing it onto the device. In addition, this framework has a monitor
command that allows the terminal to display the messages printed onto the port where the ESP32
is connected.
The FreeRTOS (Real Time Operating System) operating system was used. It is a real-time
operating system for embedded systems distributed under MIT Licence. FreeRTOS provides mul-
tiple methods for threads or tasks, mutexes, semaphores and software timers. FreeRTOS is de-
signed to run on a single core. However, since the ESP32 dual core CPUs are identical and share
the same memory, this allows tasks to run on both cores interchangeably. This operating system
helps developing real-time applications.
3.4.1 Reading samples
In order to read samples from the MAX30100 sensor, I2C communication must be config-
ured. This is set in funcion "max30100-master-init()". This function receives the SDA and SCL
pins which the sensor is connected to. It also has as an argument the i2c-port (I2C-NUM-0 is
-
3.4 Programming the system 19
used), pullup-en(whether internal pull-up resistors are needed or not for SDA and SCL) and i2c-
freq (I2C frequency is set to 100000 bits per second). This is everything needed to start the I2C
communication.
Furthermore, the sensor’s registers must be configured in order to choose operating mode.
"max30100-init()" is responsible for such configuration and also resetting all values, having the
following variables as parameters:
1) i2c-port: port to which the sensor is connected, there are two options: I2C-NUM-0 and
I2C-NUM-1.
2) Operating-mode: either HR-only or SpO2 and HR.
3) Sampling-rate: values can be seen in 3.7.
4) Red-led-pulse-width: values can be seen in 3.7.
5) Ir-led-pulse-width: values can be seen in 3.6.
6) Starting-red-led-current. values can be seen in 3.6.
7) Mean-filter-size: the size of the filter (3.4.2.2).
8) High-res-mode: when set to TRUE, ADC resolution is 16-bit with 1600µs pulse width.
9) Debug.
The last parameter (debug) when set to "TRUE" enables the printing of state messages that
allow the user to understand what is happening in order to perform debugging. All configurations
for each parameter can be seen further on (page 29). A function was created for each parameter in
order to write its respective configuration onto the sensor’s register. An example for the Operating
mode is "set-mode()"
After all configurations are made, "read-FIFO()" must be called in order to read and store the
FIFO data. This function needs an address and an array in order to start reading in the specified
address and store the data in the array.
3.4.2 Heart rate monitor
This section explains how to set the system to acquire the user’s heart rate values only. For
this, it is needed to filter the signal in order to remove unwanted noise and offsets to properly be
able to interpret the obtained values.
Firstly, the operation mode must be set to HR-only (sending 0x02 to "MODE config"). This is
accomplished with the function "setMode()". Since the IR LED is the one responsible for measur-
ing the BPM values, its current must be set. The function responsible is "setLEDCurrents()".
The second stage is to filter the signal, although samples can already be read from the buffer
using "readFIFO()". The plot in Figure 3.3 shows two unwanted signals that must be mitigated:
the DC offset of 50 000 units, and the fast oscillation.
-
20 Photoplethysmography sensor based on ESP32
Figure 3.3: Plot of values unfiltered
3.4.2.1 DC removal
This filter leaves the AC part of the signal by removing its offset. The function responsible for
this ("dc-removal()") computes Equations 3.1 and 3.2 (as presented in [41]), in which:
y(t): Filter’s output.
x(t): Input of the filter.
ω(t): Intermediate value.α: The constant responsible for the filtering in defined by the user between [0,1]. If this
number is zero, all the signal is filtered. In a DC filter it is desired for α to be a value close to one(0.95 was chosen).
ω(t) = x(t) + α.ω(t −1) (3.1)
y(t) = ω(t) − ω(t −1) (3.2)
The output graph oscillates around the zero reference level, as it can be observed in figure 3.4,
page 21.
3.4.2.2 Mean median filter
This filter, as the name suggests, is a mean filter used to clean the signal in order to better
detect pulses. It runs the signal, entry by entry, replacing each value with the difference between
the average of the entries and the previous value ("mean-diff()" function). The number of values
used can vary and is up to the user to set this number in MEAN-FILTER-SIZE variable (MEAN-
FILTER-SIZE is set to 15 samples in the final version of the filter).
-
3.4 Programming the system 21
Figure 3.4: Plot of values after offset removal
The pulses take place where the derivative of the signal has maximum values. The signal starts
to take form and resembling an Electrocardiogram (Figure 3.5).
3.4.2.3 Butterworth filter
Despite the improvement achieved with the previous filter, some smoothing would improve
its analysis. This can be accomplished by removing the higher level harmonics with a low-pass
Butterworth filter. This filter is designed to have a flat response in the pass-band frequency and to
cut off the signal in the undesired frequencies [42]. In order to implement this filter, two variables
must be calculated:
1) Fs: Sampling Rate.
2) Fc: Cut-off frequency.
The sampling frequency is a MAX30100 configurable parameter (all sampling rates are listed
in chapter 4.1, page 29). To explain the implementation of the butterworth filter 100 Hz frequency
rate will be considered.
The cut-off frequency must be determined based on the desired range of HR operation (max-
imum and minimum BPM expected values). The minimum and maximum BPM values chosen
were 50 and 220, respectively.
In order to calculate the frequencies, a division of the BPM value by 60 (seconds in a minute)
must take place (Equations 3.3 and 3.4).
fmin =5060
= 0.8(3)Hz (3.3)
fmax =22060
= 3.(6)Hz (3.4)
-
22 Photoplethysmography sensor based on ESP32
Figure 3.5: Plot of values after offset removal and median filtering
The filter works not with these two values, but with Rn, the relationship between both (Equation
3.5)
Rn =FcFs
(3.5)
However, the amount of time that was measured that was needed to perform a loop (reading
and filtering sensor data) corresponded to 75 Hz frequency. This would lead to cutting off wanted
frequencies. To solve this, the cut-off frequency was decreased to 15 Hz. This is not a major
problem since the cut-off of frequency is around 180 BPM instead of 220, but nonetheless, if
usage in intense sport training is intended, this issue may need further study. The function that
implements this filter is called "lpb-filter()" (calculating of the parameters α and β with the chosenfrequencies[43]) through computing Equations 3.6, 3.7 and 3.8.
ir.value[0] = ir.value[1] (3.6)
ir.value[1] = (α . x) + (β . ir.value[0]) (3.7)
ir.result = ir.value[0] + ir.value[1] (3.8)
with:
ir.value : infra-red LED measured value.
ir.result : infra-red LED filtered value.
α = 0.245237
β = 0.509525
-
3.4 Programming the system 23
Figure 3.6: Plot of values after offset removal, median and butterworth filtering (final signal)
3.4.2.4 Heart beat detection
Once the signal is cleaned up and filtered, BPM values can be easily calculated. In order to
calculate these values, a state machine was implemented (Figure 3.7). The idea is quite simple:
1) Starting in Idle state, all values are reset to zero and the state machine is waiting for the
sensor’s IR value to reach a minimum threshold. When it does, the "Upwards Tracing" state is
activated.
2) When in "Upwards Tracing" state, a timestamp is taken to enable heart rate calculation.
When the sensor value reaches a value smaller or equal to its previous one (local maximum de-
tected) it switches to "Peak Reached" state.
3) In "Peak Reached 1" the state machine starts calculating BPM value and automatically
switches to "Peak Reached 2" so that the function "detect-pulse()" only returns True for the mini-
mum amount of time possible.
4) When in "Peak Reached 2", the state machine keeps calculating BMP value, since it did
not have enough time to complete it. Furthermore it waits until the sensor reading is bellow the
maximum accepted value to shift to "Idle" and therefore, complete a loop.
Finally, every time a pulse is detected, depending on the operating mode, results are printed.
3.4.3 Pulse oximeter
As it was previously mentioned in 2.2, oxygen saturation levels can be measured by calculating
the ratio between the light absorbed from IR LED and red LED. This procedure is going to be
explained and detailed. The perfect calibration of the sensor varies within each patient, in other
words, empirical data is needed in order to create a proper lookup table to convert values.
The use of two different wavelengths of light is needed in order to reduce the mathematical
complexity of the process. Each LED is turned on and off alternately and measures are kept in the
MAX30100 storage buffer.
-
24 Photoplethysmography sensor based on ESP32
Figure 3.7: State Machine for beat detection
In theory, the oxygen saturation is proportional to R (Equation 3.9). In practice, this rela-
tionship is not so linear (Figure 3.8). For this reason a look up table is used to provide correct
values.
R =log(Iac)λ1log(Iac)λ2
(3.9)
Iac is the light intensity for which only the AC signal is present, λ1 is 650 nanometers wave-length and λ2 stands for 950 nanometers wavelength in light spectrum.
Furthermore, there are a DC and an AC components in the measurements. The AC component
is due to the blood vessels absorption of light. The DC component exists because of the skin and
other tissue’s absorption.
Analog signal processing is of no use here since the LEDs work in a pulsating mode, therefore
digitally processing the signal is a must. Firstly, in order to have the program measuring Oxygen
levels it is mandatory to set the mode to "SaO2 + HR". This is accomplished writing 0x03 onto the
"MODE config" register. This turns on current supply for both LEDs and ensures that the sensors
starts filling FIFO buffer with samples from both light spectrums.
The current of each LED is controlled so that the DC values match one another with a small
tolerance [44]. The function implemented is quite simple: first it checks if the difference between
values from both LEDs is within the threshold and if so, no further calculation is needed. If not,
one of two things will take place:
1) If (IR LED value - red LED value > acceptable difference) and (actual red LED current
< maximum LED current) then the red LED current shall be increased.
-
3.4 Programming the system 25
2) If (red LED value - IR LED value > acceptable difference) and (actual red LED current
> minimum LED current) then the red LED current ought to be decreased.
Figure 3.8: Empirical and Theoretical R to SaO2
This intensities adjustment can only be made with a maximum period that is established by
the user (red-current-adj-ms is set to 500 milliseconds) in order to let values stabilize.
Once the DC values match, SpO2 is calculated by dividing the logarithms of the root mean
square (RMS) values of the measurements. The RMS values ought to be calculated for the whole
signal, not only when a pulse is detected. Since the RMS is a mean of a number of samples, it
should be reset after a period of time (final implementation is set to 4 heart beats)
This is an empirical estimation, since it is needed to properly calibrate your sensor in order
to produce accurate and precise measurements (empirical data is needed and it varies with each
patient). Nonetheless a standard model for computing SpO2 [45] is represented in Equation 3.10.
SpO2 = 110−25∗R (3.10)
3.4.4 Code organization
The program consists of two tasks: "task-BPM" and "task-sleep" (Figure 3.9). "Task-sleep"
has a higher priority and is used to either just pause "task-BPM" or to enter a sleep mode. For this
to be feasible, this task has a higher priority (value 2) than task-BPM (value 1). Both tasks are
synchronously released, since "task-sleep" has a higher priority it will preempt "Task-BPM".
-
26 Photoplethysmography sensor based on ESP32
Figure 3.9: Execution of tasks with CH1="task-BMP"" and CH2="task-sleep"
3.4.4.1 Task-BPM
As the name suggests, this task does the actual work of measuring HR and SpO2. In order
to accomplish this, it is a constantly updating both red and IR raw values and filtering the signal
(see previous Section 3.4.2). Once the signal is ready, it waits until "pulse-detect()" returns true,
when so, it calculates the BPM and SpO2 values and prints them. Subsequently it goes to sleep
accordingly to the sensor’s update rate using "vTaskDelay(1/Update-rate)".
Therefore, this task has a period of 1/Update-rate. The final system has 50 Hz which corre-
sponds to a period of 0.02 seconds as it can be seen in Figure 3.10. The execution time of the task
with pulse width of 200 µs is 879.2 µs (Figure 3.11).
3.4.4.2 Task-sleep
This task is used to pause "task-BPM" in order to save energy. This task will allow taking
advantage of light-sleep and deep-sleep modes, since the processor needs to stop sampling to
enter them due to the high sampling rate.
As it was previously mentioned, this task has a higher priority, allowing it to interrupt "task-
BPM". For this, "Task-sleep" will stop executing for a period of time (vTaskDelay(delay)) en-
abling the CPU to execute the other task for the amount of time specified in "delay". Afterwards,
it suspends "Task-BPM" ("vTaskSuspend(get-bpmHandler)") for a period of time specified in
"xTimerStart()". When timer reaches the specified value, it resumes "task-BPM" (vTaskResume(get-
bpmHandler)).
-
3.5 WiFi transmission 27
Figure 3.10: Frequency of task-BPM
Different times will be tested in Chapter 4. In order to further study the energy consumption of
the system created, instead of simply suspending "task-BPM", deep-sleep and light sleep modes
will be configured to start with a pre-defined timer as wake-up cause ("esp-sleep-enable-timer-
wakeup(time-to-sleep)" and "esp-deep-sleep-start()" or "esp-light-sleep-start()").
3.5 WiFi transmission
The ESP32 has a WiFi module built in which enables it to create TCP/IP connections over
wireless communication links. It can play one of two different roles, or even both:
1) Access Point: This entity acts as a hub of communications. It is connected to a router
(also an Access Point) and acts as one for the rest of the network. Moreover, WiFi connections are
then formed to the access point (through devices called stations) and TCP/IP traffic flows through
the access point.
2) Station: this mode allows the ESP node to connect to an existing WiFi infrastructure,
through the respective AP. This is the mode used in this system and is the only one supported
when using modem-sleep mode.
Since the major focus of this work was the programming of the MAX30100 and studying the
system’s power consumption with different configuration modes, the actual sending of messages
was not inserted in the program. However, the measurement on the impact of the connection to an
AP was made, since it is part of the infrastructure energy cost.
-
28 Photoplethysmography sensor based on ESP32
Figure 3.11: Execution time of task-BPM
3.6 Conclusion
This chapter presented a description of how to build a PPG sensor using the MAX 30100
sensor attached to the ESP32 IoT node. Furthermore the Chapter assessed how the sensor provides
data, how it can be connected to the processor and how the signal must be processed in order
to extract HR and SpO2 values. This work used used the functions provided by Angelo Elias
Dalzotto [46] were used to develop the software application using two tasks of the FreeRTOS
operating system. The next chapter will describe and characterize experimentally the operation of
the device in different configurations while measuring the current consumption for each one.
-
Chapter 4
Experimental characterization
This section presents an evaluation of different system configurations, not only assessing Qual-
ity of Service (QoS) but also taking into consideration the overall energy consumption of the sys-
tem. The experiments conducted aim at finding the best effective and robust configurations while
weighting and judging the trade-off between performance and energy consumption in order to
build a final system with an adequate autonomy.
4.1 MAX30100 parameters
The MAX30100 sensor has 3 variable parameters:
1) LED current.
2) Sampling Frequency.
3) LED Pulse Width.
Led current can be controlled through registers Red-PA [3:0] OR IR-PA [3:0] for each
LED, red and infra-red respectively. Since it is a 4 bit register for each LED 16 currents can be set
(Table 3.4). LED-PW[1:0] register can be used to choose both LEDs pulse width. Because it has
only two bits, it allows 4 different configurations shown in Table 3.3. The Frequency at which the
MAX30100 samples data can be set in SPO2-SR [2:0] register. Since it has 3 bits it corresponds
to 8 possible values represented in Table 3.2.
Some configurations cannot be chosen since the LED pulses start to overlap each other due to
high sampling frequency and pulse width values. Moreover it is needed to take into consideration
the rising and falling time of the current levels. The Tables in Figures 4.1 and 4.2 represent the
allowed configurations (in green).
29
-
30 Experimental characterization
Figure 4.1: HR only mode (allowed settings)
Figure 4.2: HR and SpO2 mode (allowed settings)
4.2 Quality of Service experiments
Since there are 16 possible LED currents, 4 pulse width values and 8 different frequencies, this
leads to a total of 512 possible configurations. To reduce test time a set of values was chosen that
can represent the relationships between variables:
1) LED current (mA): 50.0, 43.6, 37.0, 30.6, 24.0, 17.4, 11.0 and 4.4.
2) Sampling frequency (Hz): 800, 400, 200, 100 and 50.
3) Pulse width (µs): 1600, 800, 400 and 200.
Firstly, experiments were carried out to assess the system’s time to stabilize around a value.
This time depended on the configuration since some have more samples per second than others.
On most setups this time was around 2 to 4 seconds ranging up to 6.5 seconds.
Since the sensor is highly unstable, in order to access Quality of Service, sets of 10 different
measurements were made, each during 10 seconds, counting how many measurements reached a
stable value. This way the system had enough time to reach a stable condition feeding the user
-
4.2 Quality of Service experiments 31
correct information. This experiment aims to quantify the relationship between relevant samples
and total number of samples, thus allowing the classification and comparison of different config-
urations. Furthermore, a clock glass was used since it was observed that it improved significantly
the finger steadiness, resulting in more beats detected and more precise results. For a sample of
10 second to be considered acceptable it must meet the following requirements:
1) Values must be reasonably close to each other.
2) At least half of the heart beats must be detected.
The number 6 was chosen as the minimum value of beats that need to be detected because the
best configurations acquired 12 results .
The results (displayed in Tables 4.1 to 4.8) were divided in 4 different groups according to the
number of valid measurements:
1) Less than five (red).
2) 5-6 (orange).
3) 7-8 (yellow).
4) 9-10 (green).
Table 4.1: Results for IR LED current = 50 mA)
Table 4.2: Results for IR LED current = 43.6 mA
As expected, the results obtained with the two highest currents considered (50.0 and 43.6 mA)
are almost all acceptable.
-
32 Experimental characterization
Table 4.3: Results for IR LED current = 37 mA
With 37.0 mA of current it is noticeable that some configurations are unstable, although most
of them show 9 or 10 valid measurements.
Table 4.4: Results for IR LED current = 30.6 mA
With IR LED current values of 30.6 mA or less, the results obtained are very unstable with
many configurations not being able to retrieve any values at all.
Table 4.5: Results for IR LED current = 24 mA
Since the 37mA was the lowest IR LED current that had configurations which produced 9 or
10 valid measurements out of 10, it was chosen for the final implementation. The pulse width and
frequency values chosen were 200 µa and 50 Hz, respectively, since this arrangement generates
-
4.3 Energy consumption experiments 33
Table 4.6: Results for IR LED current = 17.4 mA
Table 4.7: Results for IR LED current = 11 mA
Table 4.8: Results for IR LED current = 4 mA
valid results, making the system robust, while lessening the current consumed by the module as it
will be mentioned afterwards.
4.3 Energy consumption experiments
In this section, experiments were conducted with the purpose of choosing the most energy-
efficient configuration that still provides the desired quality of service (Section 4.2). In order to
measure the energy consumption, Monsoon Low voltage Power Monitor was used [47]. The power
monitor can measure the current consumption through an USB cable that can be directly connected
-
34 Experimental characterization
to the ESP32. In a first phase, measurements were made on the average current consumed varying
all different parameters. Since the data acquired for each configuration had over 500 000 values,
box-plots were created to facilitate comprehension and analysis (Figures 4.3, 4.4, 4.5 and 4.6).
Afterwards, with the average current consumption for each configuration, it was easily understood
that the overall consumption of the system depends linearly of each variable (Figures 4.7, 4.9 and
4.8).
Figure 4.3: Box plot of Currents Consumed while varying Frequency for 200µs Pulse Width
Since 43.6 mA was the lowest IR LED current that produced stable results for all variable
arrangements, average current consumption of the system was measured for all configurations
with this current supply. After having the measured values, a 3D plot was created with the device’s
average consumed current as a function of pulse width and sampling frequency (Figure 4.10)
containing the representation of all measured points used to create this surface as well.
With the observed consumption values an empirical model was developed in order to represent
the variation of the device’s current consumption as a function of the referred configurations.
Figures 4.7, 4.8 and 4.9 show a clear linear relationship with respect to each of the configuration
dimensions. Microsoft Excel’s GRC non-linear engine was used to compute the parameters of the
linear tri-dimensional model (z = a∗ x+b∗ y+ c), which resulted in the following:1) a = 0.015082.
2) b = 0.037259.
3) c = 53.31001.
4) coefficient of determination (R2) = 0.78
-
4.3 Energy consumption experiments 35
Figure 4.4: Box plot of Currents Consumed while varying Frequency for 400µs Pulse Width
Figure 4.5: Box plot of Currents Consumed while varying Frequency for 800µs Pulse Width
Since "b" is more than the double of "a", it can be concluded that sampling frequency (y) has
more impact than pulse width (x) with respect to current consumption, thus on the system’s battery
life.
-
36 Experimental characterization
Figure 4.6: Box plot of Currents Consumed while varying Frequency for 1600µs Pulse Width
Figure 4.7: Plot of average Current Consumed while varying Frequency for each Pulse Width
The coefficient of correlation is a value ranging from 0 to 1. This values quantifies how much
the linear model resembles the empirical data, with 1 being a perfect match.
-
4.3 Energy consumption experiments 37
Figure 4.8: Plot of average Current Consumed while varying IR LED current with 200 µs PulseWidth and 50Hz of sampling Frequency
Figure 4.9: Plot of average Current Consumed while varying Pulse Width for each Frequency
4.3.1 Sleep modes
This section shows the current consumption of the device as a function of different sleep
modes, to assess their effectiveness. The ESP32 has 3 pre-configured sleep modes: Modem-sleep
-
38 Experimental characterization
Figure 4.10: Surface created with average current consumed for each configuration with LEDcurrent = 43.6 mA
mode, in which the module’s WiFi circuit is shut down when at idle for a certain time, but without
breaking WiFi connectivity; Light-sleep mode, which differs from the Modem-sleep by pending
the module’s CPU, shutting down the crystal oscillator-based clock, keeping a less precise RTC
clock; and, finally, Deep-sleep mode, where the whole module is shut down, breaking the WiFi
connectivity.
Considering that the sensor needs constant sampling, activating sleep modes between sampling
is not possible, since these occur with relatively high frequency (at least 50 Hz). Following this
idea, 3 scenarios will be tested, and in all of them task-BPM will have an execution time of 10
seconds (time during which the sampling is carried out) but its period will vary : 10, 20 and 40
seconds, caused by the preemption of task-sleep.
Since light and deep-sleep modes set the processor to an idle state, they cannot be used while
the ESP32 module is acquiring samples from the MAX30100 sensor. The reason for pausing the
task that does the actual sampling ("task-BPM") is to enable the microprocessor to enter these
low-power modes, in order to further improve battery lifetime.
Differently, "modem-sleep" mode can be turned on and the system chooses when to take ad-
vantage from it, by reducing the number of WiFi transmissions. For this it is needed to set the
following configuration in "idf menuconfig": enable support for power management and tickless
idle mode and use RTC timer as reference.
Furthermore, more configuration regarding this power mode can be set:
-
4.3 Energy consumption experiments 39
1) WiFi listen interval: Interval for a station to listen to the beacon from the AP. The unit
of listen interval is one beacon interval. For example, the beacon interval is 100 ms and listen
interval was set to 3, meaning that the interval the station had to listen to the beacon is 300 ms.
2) Power save mode can be set to 3 different values: none, minimum modem and maximum
modem. This is the power save mode for the ESP32 to use. Modem sleep mode includes minimum
and maximum power save modes. In minimum power save mode, the station wakes up every
Delivery Traffic Indication Message (DTIM) to receive a beacon (this was the chosen mode).
Broadcast data will not be lost because it is transmitted right after DTIM. However, it can not
save much more power if DTIM is short and DTIM is determined by AP. In maximum power save
mode, the station wakes up every listen interval to receive the beacon. Broadcast data may be lost
because the station may be in sleep state at DTIM time. With a longer listen interval, more power
is saved but broadcast data can be lost more easily.
3) Maximum CPU frequency: Maximum CPU frequency to use for dynamic frequency
scaling. 3 values can be set: 80 MHz, 160 MHz or 240 MHz. The module was programmed to
have a maximum CPU frequency of 80 MHz.
4) Minimum CPU frequency: Minimum CPU frequency to use for dynamic frequency scal-
ing. Should be set to XTAL frequency or XTAL frequency divided by integer. This value was set
to 10 MHz.
The actual current consumption measurements were made in the following order:
1) Normal operation mode: firstly, always sampling i.e., no pauses. Then setting "task-
BPM" to 10, 20 and 40 second period.
2) Modem-sleep: continuous sampling and setting "task-BPM" period to 10, 20 and 40
seconds.
3) Light-sleep and deep-sleep: setting "task-BPM" period to 10, 20 and 40 seconds.
In order to calculate battery life a 1000 mAh battery was taken into consideration, from full
charge to a 10% depletion, because it can achieve a sufficient battery life for the use cases that
were considered and it has a small size which does not compromise the size of the wearable. The
results obtained with the power monitor can be seen in Figures 4.11 to 4.18.
When observing Figures 4.11 and 4.12 it is clear that using modem-sleep has a considerable
impact regarding the overall energy consumption of the system. This is accomplished because
the previously mentioned sleep-mode, although maintaining WiFi connectivity, turns off the WiFi
circuit, reducing the amount of data transmitted. Therefore leading to a significant decrease in the
average current consumed by the system, when compared to normal operation mode.
The spikes seen in both images are a result of WiFi connectivity: the AP is constantly sending
periodic beacon messages that are vital for the proper operation of the network. They contain all
its information and are also used to synchronize the members of this network.
-
40 Experimental characterization
Figure 4.11: Current consumed in normal mode with task-sleep deactivated
Figure 4.12: Current consumed in modem-sleep mode with task-sleep deactivated
When inspecting Figures 4.13 to 4.16 there are some important facts that can be related to
these consumption graphs. With respect to Figures 4.13 and 4.14 there is a clear offset current
when task-sleep is not preempting task-BPM, but the WiFi beacons from the AP are still present.
When task-sleep is being executed by the CPU the overall consumption of the module drops due
to CPU idle-task being activated. This task decreases the power consumption of the module when
the CPUs are not being used, even in normal operation mode.
Looking at Figures 4.15 and 4.16 it is clearly identified when the processor is in light-sleep
or deep-sleep mode, since the current drops abruptly. it is noticeable a major increase in current
when waking up from deep-sleep. When the system enters this power saving mode, shuts down the
-
4.3 Energy consumption experiments 41
Figure 4.13: Current consumed in normal mode with task-sleep active for 10 seconds
Figure 4.14: Current consumed in modem-sleep mode with task-sleep active for 10 seconds
whole module, therefore, breaking WiFi connectivity. It keeps only an ultra-low-power processor
(ULT co-processor) which allows the module to wake up at a specified time, by external events, or
a combination of these. For that reason, when it wakes up from deep-sleep, it is needed to power
on the digital core (which is gated in light-sleep, stalling the CPUs) and to reestablish the WiFi
connection, leading to a substantial increase in current consumption roughly for the first 3 seconds.
Furthermore, there are some ripples when the system is in light-sleep that are not present when in
deep-sleep, these are due to stalling the CPUs and keeping a less precise RTC clock, instead of
powering them off.
-
42 Experimental characterization
Figure 4.15: Current consumed in light-sleep mode with task-sleep active for 10 seconds
Figure 4.16: Current consumed in deep-sleep mode with task-sleep active for 10 seconds
The measurements were made with the FTDI USB interface attached to the microproces-
sor, which consumes roughly 12 mA. This is the reason why it is not perceivable a difference in
consumption when the module is in deep-sleep (around 10 µA) when comparing to light-sleep(roughly 1 mA).
The graphic representations of the average current consumption of the system for each sleep-
mode are not all represented since they are identical with respect to the content that can be inter-
preted, varying only in the time which the current stays in a lower value (this time corresponds to
the task-BPM period).
In order to achieve the configuration with the best battery life possible, a combination of sleep
-
4.3 Energy consumption experiments 43
modes was implemented. Since light-sleep has best results for 10 and 20 seconds of "task-sleep"
execution time and deep-sleep for 40, the modes were implemented with the respective values.
The results are shown in Table 4.13.
Figure 4.17: Current consumed in modem-sleep combined with light-sleep with task-sleep activefor 20 seconds
Figure 4.18: Current consumed in modem-sleep combined with deep-sleep with task-sleep activefor 40 seconds
Tables 4.9 to 4.13 summarize this information for better visualization and understanding, one
for each operating mode.
-
44 Experimental characterization
Table 4.9: Current Consumption Average and Standard Deviation, and Battery life for Normaloperating mode
Task-sleep (seconds) Current (mA) Avg / Std Deviation Battery Life (hours)0 65.60 / 28.78 15.2410 59.31 / 34.34 16.8620 57.31 / 29.83 17.4540 52.52 / 29.19 19.04
Table 4.10: Current Consumption Average and Standard Deviation, and Battery life for Modem-sleep operating mode
Task-sleep (seconds) Current (mA) Avg / Std Deviation Battery Life (hours)0 44.58 / 36.19 22.4310 39.20 / 37.48 25.5120 35.10 / 32.28 28.4940 32.91 / 35.79 30.39
Table 4.11: Current Consumption Average and Standard Deviation, and Battery life for Light-sleep mode
Task-sleep (seconds) Current (mA) Avg / Std Deviation Battery Life (hours)10 33.61 / 41.17 29.7520 26.61 / 39.11 37.5840 21.89 / 38.20 45.68
Table 4.12: Current Consumption Average and Standard Deviation, and Battery life for Deep-sleepmode
Task-sleep (seconds) Current (mA) Avg / Std Deviation Battery Life (hours)10 39.84 / 50.15 25.1020 31.00 / 49.85 32.2640 20.58 / 33.56 48.59
Table 4.13: Current Consumption Average and Standard Deviation, and Battery life for Modemsleep combined with Light-sleep or Deep-sleep mode
Sleep-Mode Task-sleep (seconds) Current (mA) Avg / Std Deviation Battery Life (hours)Light&Modem 10 26.19 / 27.90 38.18Light&Modem 20 21.73 / 32.46 46.02Deep&Modem 40 18.98 / 35.19 52.69
-
4.4 Designing a production-ready device 45
When observing the consumption in continuous sampling with modem-sleep mode and normal
operation mode, it is clear a reduction in current consumption when using this power saving mode.
For constant sampling, the battery life had an increase of 47%. Modem sleep increases battery life
in an average of 55% when compared to normal operating mode.
Light-sleep has an increase from 76% (task-BMP period of 10 seconds) up to 140% (task-BMP
period of 40 seconds) when comparing to normal operating mode.
In contrast, deep-sleep mode does not present an improvement in current consumption for all
values of task-sleep execution time, when compared to light sleep mode. Only when task-sleep has
an execution time of 40 seconds this sleep mode has an increase of 6% comparing with light-sleep,
leading to an increase of 155% regarding normal operation mode battery life. When task-BPM has
a period of 10 or 20 seconds this sleep mode is less efficient than light sleep, having an increase in
current consumption of 16% and 14% respectively.
Lastly, comparing the combined sleep modes configurations’ battery life to the normal operat-
ing mode’s, it was measured an increase of 126%, 164%, 176% for 10, 20 and 40 seconds.
As it was previously mentioned, these tests were conducted with the complete ESP32 devel-
opment module, including the FTDI USB interface, which consumes roughly 12mA.This means,
for example, that producing the device without the USB interface, and using the last configuration
measured (Figure 4.18) would have a consumption of roughly 7 mA leading to a battery life of
114 hours.
4.4 Designing a production-ready device
The use case scenarios that were considered may require more precision and efficiency, such
as emergency wards, or not so much, like home monitoring. However, it was considered that
the following configuration satisfies the requirements of all use cases, since it produces reliable
results while maximizing battery life: an IR LED current of 37 mA, sampling frequency of 50Hz
and pulse width of 200µs.
As it was previously mentioned, the system battery life was calculated for a 1000 mAh bat-
tery. In some use-cases, for example home monitoring, a larger battery could be used, leading to
proportionally longer battery life time.
With respect to power saving modes, in a scenario where the acquisition of the physiological
signals is of major importance (for example in emergency wards) the light and deep-sleep modes
should not take place since they imply relatively long periods (some seconds) without sampling,
thus not supplying information to the user. In these cases, modem-sleep brings a significant im-
provement regarding battery life time, allowing to extend it from 15h to over 22h.
On the other hand, when the service interruptions can be tolerated, the use of deep-sleep mode
provides a considerably longer battery life, extending beyond 48h when task-sleep is set to cause
suspensions of 40s. Furthermore, if continuous monitoring is not mandatory, a combination of
deep-sleep and modem sleep should take place since it enhances the system’s battery life in 8%
-
46 Experimental characterization
when compared to deep-sleep mode, leading to an estimate of almost 53 hours of life between
charges.
4.5 Conclusion
In this chapter we presented an extensive experimental characterization of the ESP32-based
PPG device proposed. In particular, measurements of the current consumption for all possible
configurations and with different sleep-modes.
The configuration that produced valid results and consumed less energy was: IR LED current
of 37 mA, sampling frequency of 50Hz and pulse width of 200µs.It is noticeable an increase in battery life when using the sleep modes provided by esp-idf,
becoming an asset when there is the possibility of halting the sampling of values for sub-minute
intervals.
One of the major difficulti