Internet of Things-Based ECG and Vitals Healthcare Monitoring System

Health monitoring and its associated technologies have gained enormous importance over the past few years. The electrocardiogram (ECG) has long been a popular tool for assessing and diagnosing cardiovascular diseases (CVDs). Since the literature on ECG monitoring devices is growing at an exponential rate, it is becoming difficult for researchers and healthcare professionals to select, compare, and assess the systems that meet their demands while also meeting the monitoring standards. This emphasizes the necessity for a reliable reference to guide the design, categorization, and analysis of ECG monitoring systems, which will benefit both academics and practitioners. We present a complete ECG monitoring system in this work, describing the design stages and implementation of an end-to-end solution for capturing and displaying the patient’s heart signals, heart rate, blood oxygen levels, and body temperature. The data will be presented on an OLED display, a developed Android application as well as in MATLAB via serial communication. The Internet of Things (IoT) approaches have a clear advantage in tackling the problem of heart disease patient care as they can transform the service mode into a widespread one and alert the healthcare services based on the patient’s physical condition. Keeping this in mind, there is also the addition of a web server for monitoring the patient’s status via WiFi. The prototype, which is compliant with the electrical safety regulations and medical equipment design, was further benchmarked against a commercially available off-the-shelf device, and showed an excellent accuracy of 99.56%.


Introduction
The use of Internet of Things (IoT) sensors for assessing the human body's vital signs has grown in prominence in recent years [1]. While the primary driver for such devices has been ubiquitous on-demand healthcare monitoring, there is an increasing case for their use in enabling and improving the healthcare provisions in low-and middle-income countries (LMICs) [2,3]. The existing healthcare facilities in LMICs range from being inadequate to virtually non-existent, and this stems from a lack of finance, infrastructure, and trained manpower amongst other systemic factors [3]. As a result, a significant population and many communities are often deprived of medical care which invariably is expensive and inaccessible. At the same time, chronic disorders such as hypertension, diabetes, heart disease, and chronic obstructive pulmonary disease are becoming more prevalent [4]. In fact, cardiovascular diseases (CVDs) accounting for nearly 17.9 million deaths per year are now the leading cause of mortality across the world [4]. According to the World Health Organization (WHO), in 2016, CVDs accounted for more than 840,000 mortalities in the United States alone [4][5][6]. Similarly, according to the 2017 edition of the European Cardiovascular Disease Statistics, CVDs led to over 5.7 million deaths across Europe and European Union (EU), accounting for nearly 40% of all fatalities [7]. Globally, nearly 80% of CVD deaths occur in LMICs, where often the burden of disease is the greatest [8]. The

1.
The device must display an ECG signal on a local display screen, and it records the data on a server.

2.
To show the signal on a custom mobile application, the signal must be delivered over Bluetooth.

3.
It should include capabilities that enable MATLAB integration; the ECG signal should be sent to MATLAB for further analysis. R-wave detection must be used to compute and display the heart rate on all of the display outputs. 4.
All the user interfaces should record and show additional information such as blood oxygen level (SpO 2 ) and skin temperature. The sensor data should be delivered via a WiFi connection to a ThingSpeak server. 5.
The final prototype design should be printed on a high-quality PCB and housed in a protective casing. The device must be both portable and wireless. 6.
The device must include a low-power sleep mode to enhance the battery's lifetime and enhance the product's portability requirements.

Materials and Methods
Here, we discuss the theoretical aspects which underpin the practical considerations employed in the system design.

Analog Front End (AFE)
The low amplitude raw ECG signal necessitates amplification [34], while the elimination of the noise components arising from a range of sources demands strong attenuation (see Figure 1). To eliminate any noise components that were recorded during the ECG capture, the amplified signal needs to pass through a filter. To reduce the AC noise produced by the mains power-50 Hz in Europe and 60 Hz in America-a band-pass or notch filter is generally utilised. If the patient is not motionless throughout the recording, an electromyogram-type noise is created, which alongside the respiration, might cause baseline drift. This is in addition to the electrode offset noise which can occur owing to the poor connection between the patient's skin and the electrodes. To ensure that the ECG signal is suitable for the analysis, all these noise components must be removed or attenuated significantly prior to digitisation [10,26,35]. While there are several off-the-shelf fully integrated ECG front ends (see Table 2), based on the low-power consumption and low-cost criteria, we have utilised the AD8232 integrated signal conditioning block [10,36,37] (Analog Devices, USA). The AD8232 has a voltage range of 2-3.5 V and a low supply current of 170 µ A, making it simple to integrate with an external microcontroller such as Arduino [38]. Moreover, the 4 mm × 4 mm packaging enables it to have a small PCB design, and it features a shutdown pin, allowing it to be configured to save the power. Additionally, the integrated circuit includes a two-pole adjustable high-pass/low-pass filtering arrangement as well as an adjustable gain (maximum gain of 100 V/V), allowing for the configurable capabilities to be tailored for performance testing. There are several features in the AD8232 including a right-leg driver (RLD), leads-off detection, and an in-built fast restore circuit. Given the safety considerations and requirements for a high signal-to-noise (SNR) ratio, a three-electrode design comprising of RA, LA, and RL (RLD) was chosen wherein the RLD/ground-electrode minimises the effects of common noise by extracting the common-mode voltage and driving an opposing signal into the patient. The 1 nF integrator capacitor (C2) works in conjunction with an internal 150 kΩ resistor for driving the RLD. To ensure the patient's safety, a 360 kΩ resistor (R5) was used to ensure that the current was limited to less than 10 µ A. For the three-electrode configuration, the DC leads-off detection mode works by setting the AC/DC ̅̅̅̅ line to ground via the R19 resistor (see Figure 1). The leads-off mechanism relies on pull-up resistors (R1, R2) connected to the positive supply (3V3), and it senses when either of the instrumentation amplifier input voltage is within 0.5 V from the positive rail. Thus, the leads-off detection pins remain low if the electrodes are connected correctly, and this will change to high when they are disconnected. While there are several off-the-shelf fully integrated ECG front ends (see Table 2), based on the low-power consumption and low-cost criteria, we have utilised the AD8232 integrated signal conditioning block [10,36,37] (Analog Devices, USA). The AD8232 has a voltage range of 2-3.5 V and a low supply current of 170 µA, making it simple to integrate with an external microcontroller such as Arduino [38]. Moreover, the 4 mm × 4 mm packaging enables it to have a small PCB design, and it features a shutdown pin, allowing it to be configured to save the power. Additionally, the integrated circuit includes a two-pole adjustable high-pass/low-pass filtering arrangement as well as an adjustable gain (maximum gain of 100 V/V), allowing for the configurable capabilities to be tailored for performance testing. There are several features in the AD8232 including a right-leg driver (RLD), leads-off detection, and an in-built fast restore circuit. Given the safety considerations and requirements for a high signal-to-noise (SNR) ratio, a three-electrode design comprising of RA, LA, and RL (RLD) was chosen wherein the RLD/ground-electrode minimises the effects of common noise by extracting the common-mode voltage and driving an opposing signal into the patient. The 1 nF integrator capacitor (C2) works in conjunction with an internal 150 kΩ resistor for driving the RLD. To ensure the patient's safety, a 360 kΩ resistor (R5) was used to ensure that the current was limited to less than 10 µA. For the three-electrode configuration, the DC leads-off detection mode works by setting the AC/DC line to ground via the R19 resistor (see Figure 1). The leads-off mechanism relies on pull-up resistors (R1, R2) connected to the positive supply (3V3), and it senses when either of the instrumentation amplifier input voltage is within 0.5 V from the positive rail. Thus, the leads-off detection pins remain low if the electrodes are connected correctly, and this will change to high when they are disconnected.

Choice of Microcontroller
A microcontroller is required to process the signal that has been amplified and filtered by the front end. To avoid the necessity for an external analogue-to-digital converter (ADC), such as the MCP3208, a microcontroller with an on-board high-resolution ADC is required. Typically, the ADC resolution for mobile health devices is 10-12 bits, however, a 12-bit ADC resolution was required to ensure that the developed system was future-proof. In addition to an on-board ADC, the microcontroller must have at least 8 digital IO pins, with at least three of these enabling pulse width modulation (PWM) to enable the system to work with a wide range of input/output devices. Bluetooth and WiFi capabilities were other requirements for the chosen microcontroller to enable easy communication between the designed system and the peripheral devices. Table 3 lists the specifications of each of the Arduino platforms that were evaluated. In the literature, while Arduino Uno [38,42], and Arduino Mega [43][44][45] are the most popular microcontroller options for usage with the AD8232, we have discounted Mega owing to its large footprint. We have implemented the prototype on an Arduino MKR 1010 (Arduino, Italy) owing to its 12-bit resolution, large flash memory, in-built Bluetooth feature, multiple PWM-enabled pins (see Table 3) and the fact that it is about ten years newer than other models, and to the best of our knowledge, has not been evaluated for ECG signal processing. An infrared temperature sensor is necessary for non-contact temperature measurements. We have utilised MLX90614, a medical-grade Arduino-compatible sensor with a 0.02 • C resolution [46] and an accuracy of ±0.2 • C (Melexis, Belgium). It is a small, low-cost device with power-saving modes, operates via the I2C protocol, and has been used in earlier works as well [47,48].

Blood Oxygen Sensor
In view of the COVID-19 pandemic, the measurement of the specific blood oxygen level (SpO 2 ) is extremely important, and was included in the overall device to produce a multi-functional product. From the literature review of such SpO 2 sensors, a range of products from Maxim Integrated were found to be available (a comparison can be seen below in Table 4). We have utilised the MAX30100 sensor, which has a small breakout board [49], and as compared to MAX30102, has a smaller footprint (Maxim Integrated, San Jose, CA, USA). The sensor is cost-effective, with a low-power mode for reduced current consumption during the sleep mode. Table 4. SpO 2 and temperature sensor options ( √ means that the feature is available, while means that the feature is unavailable).

Data Output and Communications
As stated in the previous section, the system should provide a live ECG signal on a local display. For such displays, the Organic Light Emitting Diodes (OLED) and Liquid Crystal Display (LCD) are the two most common options for Arduino. While the OLED displays are emissive, which means they generate their light, the LCDs are non-emissive and require a backlight [50]. If only the heart rate were to be displayed to the user, the LCD display would have been optimal, however, as the live ECG signal is to be displayed, the 1.3" OLED with the highest resolution (see Table 5) and lowest power consumption is considered to be ideal [10]. The live ECG signal should also be presented on a mobile application, with the data being transmitted through Bluetooth in addition to the OLED display. The Arduino MKR 1010 has a built-in Bluetooth Low Energy (BLE) feature, making it an excellent choice for this work. However, it should be noted that mobile health services and applications should be driven by the use of the lowest common denominator technology, such as classic Bluetooth, which is supported by a higher percentage of mobile phones (as compared to BLE), particularly in LMICs [51]. Given that Android phones hold around 73% of the global mobile operating system market as of June 2021 [52], particularly in LMICs, a no-code approach was utilised to design an application compatible with Android phones. For this, the MIT App Inventor, a web-based, open-source development tool that offers a graphical interface for creating fully working Android apps, was chosen [53]. The finished software will have a primary screen that will show the user the live ECG signal as well as the patient's heart rate, blood oxygen level, and body temperature. It will work with any smartphone that has Android 2.3 Gingerbread or a higher version.

Web Server
A web server was added with the Bluetooth programme to monitor information such as heart rate, SpO 2 level, and body temperature. Arduino IoT [54], Thingworx [55], and ThingSpeak [56] are examples of pre-made systems that offer such functionality. Since ThingSpeak can execute the MATLAB code, allowing for live signal processing and analysis, it was therefore chosen as the IoT server for patient data monitoring. It also makes it simple to import the sensor data into MATLAB. The Arduino MKR 1010 has a u-blox NINA-W102 multi radio module multi-radio that also supports WiFi connectivity, eliminating the need for a separate WiFi shield. The capability of reading raw ECG data from the AD8232 into MATLAB (through USB Serial) through the Arduino MKR 1010 has been introduced to the system.

Component Block Diagram
The inputs and outputs, as well as how they are interfaced with the microcontroller, are shown in Figure 1, and they are further described in the block diagram below (Figure 2). The MKR 1010 is powered by a USB 5 V or a 3.7 V LiPo battery, and the Phantom 320 (Medtec Science GMBH, Germany) generates the raw ECG signal, which is then processed by the AD8232 before entering an ADC pin on the MKR 1010. It should be noted that the ECG signal can also be captured from a live subject (as denoted by the dashed line). Their blood oxygen levels, and skin temperature may be measured and sent to MKR 1010 via contact with the human. A local OLED, a Bluetooth application, and MATLAB are used to display the processed ECG signal, while the basic patient data are shown using the ThingSpeak server. the patient's heart rate, blood oxygen level, and body temperature. It will work with any smartphone that has Android 2.3 Gingerbread or a higher version.

Web Server
A web server was added with the Bluetooth programme to monitor information such as heart rate, SpO2 level, and body temperature. Arduino IoT [54], Thingworx [55], and ThingSpeak [56] are examples of pre-made systems that offer such functionality. Since ThingSpeak can execute the MATLAB code, allowing for live signal processing and analysis, it was therefore chosen as the IoT server for patient data monitoring. It also makes it simple to import the sensor data into MATLAB. The Arduino MKR 1010 has a u-blox NINA-W102 multi radio module multi-radio that also supports WiFi connectivity, eliminating the need for a separate WiFi shield. The capability of reading raw ECG data from the AD8232 into MATLAB (through USB Serial) through the Arduino MKR 1010 has been introduced to the system.

Component Block Diagram
The inputs and outputs, as well as how they are interfaced with the microcontroller, are shown in Figure 1, and they are further described in the block diagram below ( Figure  2). The MKR 1010 is powered by a USB 5 V or a 3.7 V LiPo battery, and the Phantom 320 (Medtec Science GMBH, Germany) generates the raw ECG signal, which is then processed by the AD8232 before entering an ADC pin on the MKR 1010. It should be noted that the ECG signal can also be captured from a live subject (as denoted by the dashed line). Their blood oxygen levels, and skin temperature may be measured and sent to MKR 1010 via contact with the human. A local OLED, a Bluetooth application, and MATLAB are used to display the processed ECG signal, while the basic patient data are shown using the ThingSpeak server. Figure 2. Component block diagram. The dotted line represents that ECG can be acquired either from a simulated source or from a human.

System Flow Design
Following the selection of the hardware, the following phase in the design process was to determine how the system should function. The fundamental system flow diagram

System Flow Design
Following the selection of the hardware, the following phase in the design process was to determine how the system should function. The fundamental system flow diagram for the two developed modes, the consumer, and medical modes, is shown in Figure 3. The medical mode was created with MATLAB in mind for an extensive heart condition analysis. The consumer mode, on the other hand, is designed for the regular user who wants to track their heart rate, SpO 2 levels, and body temperature and examine the information on an OLED display, a mobile phone app, or a web server. for the two developed modes, the consumer, and medical modes, is shown in Figure 3. The medical mode was created with MATLAB in mind for an extensive heart condition analysis. The consumer mode, on the other hand, is designed for the regular user who wants to track their heart rate, SpO2 levels, and body temperature and examine the information on an OLED display, a mobile phone app, or a web server.

PCB Design
Once the hardware and system design were completed, the next stage was to construct a breadboard-based circuit and to follow it up with the corresponding PCB design. The prototype PCB with the dimensions of 140 × 100 × 0.8 mm (Figure 4) had an MKR 1010 positioned in the center of the PCB to make track routing for extra components easier. It was linked through two 14-pin female headers onto which the MKR 1010 was inserted. The I2C line was used to link the MLX90614, MAX30100, and OLED. For the I2C line and 3.3 V, the MLX90614 (Melexis, Belgium) required two 10 KΩ pull-up 0402 resistors. The I2C lines and 3.3 V were necessary for the MAX30100 breakout board to function. For it to work, the OLED required I2C lines and 5 V. For these connections, female headers were installed on the PCB. A 4-pin female header was used to link the Bluetooth classic module to the MKR 1010 via SPI and 5 V line.

PCB Design
Once the hardware and system design were completed, the next stage was to construct a breadboard-based circuit and to follow it up with the corresponding PCB design. The prototype PCB with the dimensions of 140 × 100 × 0.8 mm (Figure 4) had an MKR 1010 positioned in the center of the PCB to make track routing for extra components easier. It was linked through two 14-pin female headers onto which the MKR 1010 was inserted. The I2C line was used to link the MLX90614, MAX30100, and OLED. For the I2C line and 3.3 V, the MLX90614 (Melexis, Belgium) required two 10 KΩ pull-up 0402 resistors. The I2C lines and 3.3 V were necessary for the MAX30100 breakout board to function. For it to work, the OLED required I2C lines and 5 V. For these connections, female headers were installed on the PCB. A 4-pin female header was used to link the Bluetooth classic module to the MKR 1010 via SPI and 5 V line. Two female headers for the switches were included on the PCB. A 3-pin header with two digital pins and 3.3 V was required for the mode selection switch. A 10-KΩ 0402 resistor linked to the ground and a 3.3 V supply powered the interrupt switch, which was a 2-pin header attached to a digital pin. To limit the potential of noise interfering with the raw ECG input signal, the AD8232 was positioned next to the five-pole 3.5 mm surfacemounted audio jack in conjunction with the passive 0402 and 0603 components. The short tracks near the AD8232 were 0.25 mm wide, whereas the longer tracks were made to be 0.75 mm wide to ensure that they were not damaged during handling.
A two-pole 0.5 Hz high-pass filter was followed by a two-pole 40 Hz low-pass filter in the AD8232 circuit. The gain of the op-amp was set to 11, resulting in a total system gain of 1100. The following equation was used to create the high-pass filter: The low-pass filter was designed using the following equation: = 1 + 1 × 10 6 100 × 10 3 = 11 (6) As such, the complete electronic bill of materials (BOM) is shown in Table 6.  Two female headers for the switches were included on the PCB. A 3-pin header with two digital pins and 3.3 V was required for the mode selection switch. A 10-KΩ 0402 resistor linked to the ground and a 3.3 V supply powered the interrupt switch, which was a 2-pin header attached to a digital pin. To limit the potential of noise interfering with the raw ECG input signal, the AD8232 was positioned next to the five-pole 3.5 mm surface-mounted audio jack in conjunction with the passive 0402 and 0603 components. The short tracks near the AD8232 were 0.25 mm wide, whereas the longer tracks were made to be 0.75 mm wide to ensure that they were not damaged during handling.

System Flow Design
The final system flow diagram was developed prior to building the software for the MKR 1010, providing a full overview for completing the code. Figure 5 shows the flow diagram for the system operation. The two major modes, medical and consumer, both record the ECG signal for 30 s. When the device is in medical mode, the user is provided with graphs and charts, highlighting the identified QRS complexes, and when the ECG recording is completed, and the Arduino system goes to sleep. The live ECG signal is shown on both the OLED and Android apps when it is recording in the consumer mode. The patient's SpO 2 level and body temperature, as well as the computed heart rate and the voltage level of the on-board LiPo battery, are recorded and relayed to the OLED display, Android application, and the ThingSpeak Web Server, simultaneously, when the ECG recording is completed. The system will then go into sleep mode and stay there until the push button interrupt is used to wake it up. This is true in both the medical and consumer settings.

Code Design
The following sections provide a brief introduction of some of the codes' most important features.

OLED Live ECG Signal
One of the main features of the system is that it displays the live ECG signal on the OLED display during the consumer mode. When the analogRead() command is used to import the ECG signal from the AD8232 (10-bit ADC for consumer mode), the map function is used to reformat the data so that they may be shown on the OLED. The 'drawLine' command from the 'u8g2' library is then used to construct the ECG plot. The current and prior 'x' and 'y' values are among the four variables. This provides two co-ordinates between which a line can be drawn. When the value of 'x' surpasses 127 (the OLED is 128 pixels wide), the OLED is cleared, and graphing resumes on the left side of the display, moving towards the right.

Lead-Off Detection
It is critical to verify that there is no distortion between the body and the electrode while it is measuring a patient's ECG signal, otherwise the stated findings may not correctly reflect the patient's genuine cardiac status due to distortion. Techniques such as

Code Design
The following sections provide a brief introduction of some of the codes' most important features.

OLED Live ECG Signal
One of the main features of the system is that it displays the live ECG signal on the OLED display during the consumer mode. When the analogRead() command is used to import the ECG signal from the AD8232 (10-bit ADC for consumer mode), the map function is used to reformat the data so that they may be shown on the OLED. The 'drawLine' command from the 'u8g2' library is then used to construct the ECG plot. The current and prior 'x' and 'y' values are among the four variables. This provides two co-ordinates between which a line can be drawn. When the value of 'x' surpasses 127 (the OLED is 128 pixels wide), the OLED is cleared, and graphing resumes on the left side of the display, moving towards the right.

Lead-Off Detection
It is critical to verify that there is no distortion between the body and the electrode while it is measuring a patient's ECG signal, otherwise the stated findings may not correctly reflect the patient's genuine cardiac status due to distortion. Techniques such as lead-off detection are recommended for ensuring that the electrodes are correctly attached to the patient, and it will alert the user/medical worker if they are not. The lead off detection subroutine as implemented on Arduino is shown in Figure 6.
Micromachines 2022, 13, x FOR PEER REVIEW 12 of 19 Figure 6. Lead off detection subroutine. "F" represents the action if the condition is false, while "T" represents the action if the statement is true.

Sleep Mode
The addition of a sleep mode is beneficial in extending the battery source's longevity as the system is meant for portable use. The 'ArduinoLowPower' library, which is meant for use with SAMD compatible boards such as the MKR1010 one, has been used to construct a hardware interrupt. At the end of both the medical and consumer modes, the machine goes into sleep mode. The function 'wakeUpArduino' executes whenever the low power interrupt is hit, and the system reboots via an internal reset.

MATLAB Data Import
The ECG signal must be imported into MATLAB to implement the medical mode as previously described. The 'Serial.print()' method in Arduino is used to do this. In this case, it is utilised to communicate the ECG signal over USB to a PC running MATLAB. A 12-bit ADC resolution is employed in the medical mode to provide a higher signal accuracy. MATLAB additionally requires 'Carriage Return' and 'Linefeed' terminators.

Android Application
The Android application contains a real-time graphing of the recorded ECG signal, as well as displays of the heart rate, blood oxygen level, and body temperature. Figure 7a displays an early version of the Android app with a noisy ECG signal and minimal human-machine interaction elements. This was enhanced until the final application, Figure  7b, incorporated real-time ECG graphing and additional health care statistics. Figure 6. Lead off detection subroutine. "F" represents the action if the condition is false, while "T" represents the action if the statement is true.

Sleep Mode
The addition of a sleep mode is beneficial in extending the battery source's longevity as the system is meant for portable use. The 'ArduinoLowPower' library, which is meant for use with SAMD compatible boards such as the MKR1010 one, has been used to construct a hardware interrupt. At the end of both the medical and consumer modes, the machine goes into sleep mode. The function 'wakeUpArduino' executes whenever the low power interrupt is hit, and the system reboots via an internal reset.

MATLAB Data Import
The ECG signal must be imported into MATLAB to implement the medical mode as previously described. The 'Serial.print()' method in Arduino is used to do this. In this case, it is utilised to communicate the ECG signal over USB to a PC running MATLAB. A 12-bit ADC resolution is employed in the medical mode to provide a higher signal accuracy. MATLAB additionally requires 'Carriage Return' and 'Linefeed' terminators.

Android Application
The Android application contains a real-time graphing of the recorded ECG signal, as well as displays of the heart rate, blood oxygen level, and body temperature. Figure 7a displays an early version of the Android app with a noisy ECG signal and minimal humanmachine interaction elements. This was enhanced until the final application, Figure 7b, incorporated real-time ECG graphing and additional health care statistics.
ThingSpeak A ThingSpeak server, as shown in Figure 7c, was created as part of the work to allow for the remote monitoring of the patient's heart rate, SpO 2 , and temperature levels, as well as the voltage of the internal LiPo battery. A channel was constructed in ThingSpeak to display these data, with each variable displayed on a graph and a text box displaying the last value received from the Arduino. The data were transferred wirelessly from the MKR 1010 to the ThingSpeak server via an API key for publishing to the server as well as the channel ID. The 'write2TSData' method, a part of the Arduino ThingSpeak library, was used to transmit the variables to the server.

ThingSpeak
A ThingSpeak server, as shown in Figure 7c, was created as part of the work to allow for the remote monitoring of the patient's heart rate, SpO2, and temperature levels, as well as the voltage of the internal LiPo battery. A channel was constructed in ThingSpeak to display these data, with each variable displayed on a graph and a text box displaying the last value received from the Arduino. The data were transferred wirelessly from the MKR 1010 to the ThingSpeak server via an API key for publishing to the server as well as the channel ID. The 'write2TSData' method, a part of the Arduino ThingSpeak library, was used to transmit the variables to the server.

ECG Signal Processing
As cardiovascular disease is the leading cause of mortality worldwide, substantial research and development into the diagnosis and prevention of CVD-related fatalities has been conducted [57]. The most important element of an ECG signal is the QRS complex. The QRS complex explains the electrical activity that occurs during Ventricular Depolarization, and it has been used to diagnose a variety of cardiac diseases. Throughout the 20th century, computer-based ECG equipment grew in popularity, and a survey in 1988 found that over half of the 100 million ECGs recorded in the United States were interpreted by computer ECG programs [58]. The advantages of computerised ECGs much outweighed the additional expense. The problem that hospitals faced was that there were just not

ECG Signal Processing
As cardiovascular disease is the leading cause of mortality worldwide, substantial research and development into the diagnosis and prevention of CVD-related fatalities has been conducted [57]. The most important element of an ECG signal is the QRS complex. The QRS complex explains the electrical activity that occurs during Ventricular Depolarization, and it has been used to diagnose a variety of cardiac diseases. Throughout the 20th century, computer-based ECG equipment grew in popularity, and a survey in 1988 found that over half of the 100 million ECGs recorded in the United States were interpreted by computer ECG programs [58]. The advantages of computerised ECGs much outweighed the additional expense. The problem that hospitals faced was that there were just not enough electro cardiographers to read all of the ECGs that were being generated. The computerization of ECGs has substantially shortened the time between recording an ECG and diagnosing a patient [59].
Software development for QRS complex detection has been investigated for over 30 years, however, the computers' capabilities limited any methods developed in the early phases. During the evolution of the microprocessor, the attention shifted away from hardware implementations and toward more software-based solutions for QRS detection [60]. For QRS detection, a variety of methods are utilised, including Pan-Tompkins, Hillbert Transform, and Wavelets Transform. A majority of these algorithms have a pre-processing step, which is followed by a decision stage that contains r-peak detection and decision logic. The focus these days is on AI-based systems that employ Convolutional Neural Networks (CNN) to recognise QRS complexes properly. The project 'Common Standards for Quantitative Electrocardiology' was a huge step forward in ECG signal processing. Many ECG datasets were created as part of this research, allowing for the extensive testing and development of new technologies. Some of the CSE project's specifications are still relevant today [61].

QRS Complex Detection Algorithm
A basic Pan-Tompkins algorithm was constructed in MATLAB to demonstrate the capabilities of the developed equipment [62]. The Pan-Tompkins algorithm relies on the detection of the QRS complex via the strongest observable feature which commences once the ECG signal is recorded into MATLAB using the 'Medical Mode'. The following steps are outlined.
Filtering-To eliminate the typical components of noise present in ECG data, a bandpass filter of total order four with a passband of 5-15 Hz is used.
Differentiation-The filtered signal is then differentiated, yielding information about the QRS slopes.
Squaring-Entails squaring the differentiated signal. This increases the signal's dominance of the frequencies known to include QRS information. It also lowers the chances of a T-wave being misidentified as an R-wave.
Integration-A moving mean integration window is used to integrate the squared signal. There are 54 samples in this window (150 ms). The QRS complexes will be distorted if the window is too large or too narrow, resulting in erroneous peak detections.
Peak detection-As the simulator, Phantom 320, produces a clear signal, sophisticated thresholding requirements are unnecessary. A simple 'findpeaks' function may be used to detect the R waves in the ECG data at that time. If the gadget is to be commercialised, a more complex algorithm needs to be incorporated. Figure 8 illustrates the technique outlined above graphically.
Besides the ECG capture accuracy, a basic performance test was performed to evaluate the accuracy of the SpO 2 sensor and the temperature sensor. The MAX30100 and the off-the-shelf Pulse Oximeter were used to collect a sample from the individual (Figure 9). The MAX30100 employed inside our developed system was 99% accurate in this testing situation, according to the results. Similarly, a performance test was performed to check the accuracy of the body temperature sensor. The MLX90614 and an infrared thermometer (Boots, United Kingdom) were used to record each patient's body temperature. Table 7 summarises these findings. Besides the ECG capture accuracy, a basic performance test was performed to evaluate the accuracy of the SpO2 sensor and the temperature sensor. The MAX30100 and the off-the-shelf Pulse Oximeter were used to collect a sample from the individual (Figure 9). The MAX30100 employed inside our developed system was 99% accurate in this testing situation, according to the results. Similarly, a performance test was performed to check ate the accuracy of the SpO2 sensor and the temperature sensor. The MAX30100 and the off-the-shelf Pulse Oximeter were used to collect a sample from the individual (Figure 9). The MAX30100 employed inside our developed system was 99% accurate in this testing situation, according to the results. Similarly, a performance test was performed to check the accuracy of the body temperature sensor. The MLX90614 and an infrared thermometer (Boots, United Kingdom) were used to record each patient's body temperature. Table 7 summarises these findings.

Conclusions
In this study, we propose a pervasive healthcare service based on IoT-based ECG and vitals monitoring system. This system continually monitors the patients' signs, such as ECG and SpO2, and offers data transmission modalities to balance the healthcare demand for communication and processing the resources. A prototype fulfilling the requirements of the amplification, filtering, digitization, processing, and transmission of the ECG signal

Conclusions
In this study, we propose a pervasive healthcare service based on IoT-based ECG and vitals monitoring system. This system continually monitors the patients' signs, such as ECG and SpO 2 , and offers data transmission modalities to balance the healthcare demand for communication and processing the resources. A prototype fulfilling the requirements of the amplification, filtering, digitization, processing, and transmission of the ECG signal was developed which further transmits it to multiple back-end devices including the displays, mobile applications, and web servers. In addition, the system keeps track of the SpO 2 levels and body temperature. It generates precise ECG signal recordings while remaining portable as well as user-friendly. Invariably, in its current state-of-the-art form, the wearables technology (including smartwatches, smart vest, etc.) for ECG are more expensive than the portable ECG monitors are, and is therefore, they are not being considered for use in the context of LMICs, and thus, our system could provide a solution. In its current format, our proposed solution is similar to the other devices (shown in Table 1) which are capable of recoding 25-30 s of ECG data, and they often provide data on heart rate (variability) with the additional features of a smartphone interface and/or display screen and cloud integration. The cheapest option with all-inclusive features is~$80, however, at such a price point, the end user's affordability often becomes the constraint for their use in LMICs. We believe that scaling up further design iterations will bring down our cost down dramatically, and the further integration of Data Stream Management System (DSMS) technology will enhance capabilities such as continuous query, windowing, and aggregation. Following that, data stream mining and context awareness technologies are being evaluated as ways to give more powerful ubiquitous healthcare services to patients, such as early warning and real-time knowledge assistance. Informed Consent Statement: Informed consent was obtained from all subjects involved in the cited studies used in our analysis and no information of the subjects was made public. No additional samples for the purpose of this study were collected. Patients were informed of the research and their nonobjection approval was confirmed.

Conflicts of Interest:
The authors declare no conflict of interest.