Heart Rate Monitoring with Smart Wearables using Edge Computing

Heart is a vital component of every human health. The development of wearables and its sensor enables the possibility of easy-to-use real-time monitoring. The goal of this study is to improve an IoT monitoring system by enabling realtime heart rate monitoring and analysis, also to assess the use of PPG sensors in smart wearables compared to other clinicaltested heart rate sensors. The PPG sensor will be used to record heart rate data of the user physically. The measurements are then sent to the application for pre-processing. The application can then transmit the pre-processed measurements to the cloud server for monitoring or further analysis, i.e. to assess the health of users’ heart. The measurement comparison with measurement collected by a BCG sensor is carried out in this paper. While neither are standard for heart rate measurements, the findings of the evaluation show that the PPG sensor achieves quite similar input data and assessment results during awake stages. The Fitbit sensor tested often underestimates, with sometimes delayed or doesn’t detect a sudden increase in heart rate during sleeping. Keywords—Internet-of-things; heart rate; smart wearables; real-time monitoring


I. INTRODUCTION
Cardiovascular health is vital to individual's health and performance. Several researches have studied the relationship between cardiovascular and physical activity [1]- [3]. Several more researches that study people with bad habits such as smoking or drinking with their cardiovascular health and along with other health problems [4]- [5].
It's recommended to get enough exercise to improve cardiovascular health and reduce the risk of getting cardiovascular disease. Author in [6] suggests an increase of physical fitness during childhood can improve cardiovascular health during adolescence. Another research studies the relationship of sleep problems and cardiovascular disease [7]. As a prevention measure, a method or mechanism is needed to be able to track cardiovascular health by monitoring heart rate.
Currently, heart rate (HR) monitoring often involves the use of electrocardiography (ECG) and often used for polysomnography (PSG). PSG is a multi-parametric test for quantifying sleeping quality from multi sensors and is adaptable.
PSG sensors typically consist of electroencephalography (EEG), electrooculography (EOG), electromyogram (EMG), and ECG. The use of ECG sensors requires the assistance of an expert and often requires body contact, which can disturb the sleeping process itself.
Newer technology aims to eliminate the disturbance caused by sensors, such as ballistocardiograph (BCG) sensor. In 2019, Surantha et al. studied the use of BCG sensor along with developing an IoT network [8] which consists of microcontrollers and web applications for sleep quality monitoring. The use of BCG sensor introduces the possibility of daily and portable monitoring for sensor data.
Meanwhile, installation of BCG sensor and the IoT system proposed in previous study requires the assistance of an expert. The installation of the sensor requires a static placement and sensor calibration before use. It is also focused to sleep-related activities and problems.
This scientific study has been carried out in response to previous research which still needs studies for practical sensor that could improve and/or replace the use of BCG sensors. The result of this research is expected to provide options to set up individually a real-time monitoring system and to provide reports for medical experts periodically using IoT. The presentation of the result from the extracted health data itself should not be treated as a medical advice from an expert and should only be used as analytical data.
The remainder of the paper is structured as follows. The related works are listed in Section II of this paper. The Section III explains the background material and research methodology. The system designs and the simulation results are explained and evaluated in Section IV. Finally, the conclusion is presented in Section V.

II. BACKGROUND MATERIALS
Some of the background materials and research methods shown in Fig. 1 are discussed in this section. (IJACSA) International Journal of Advanced Computer Science and Applications, Vol. 11, No. 3, 2020 142 | P a g e www.ijacsa.thesai.org

A. Fitbit Charge 3
The Fitbit Charge 3 is a fitness tracker that can track activity, nutrition, and sleep by using inputs from user such as weight, drinks, food, or inputs from sensors for measuring heart rate, and location. The sensor is using a PPG signal, where a pulsatile waveform measures relative blood volume changes from blood vessels that is located close to the skin [9]. The waveform is superimposed with a lower frequency one that usually corresponds to respiration and nervous activity.

B. Smartphone Application (Data Preprocessor)
In this study, data preprocessor is implemented by an Android application. The Fitbit Charge 3 is a tracking-only device, and the only way to get sensor data from a Fitbit Charge 3 is by utilizing built-in Fitbit APIs. The Fitbit Charge 3 is designed to be automatically synced to Fitbit servers using Android's Fitbit application, or Fitbit Connect for desktop and microcontrollers. After getting authorization using OAuth 2.0 for obtaining data, the data is then downloaded and preprocessed for the same output from the Data Concentrator. This enables Fitbit to act as an optional input the IoT system.

C. IoT System
Previously, Utomo et al. (2020) developed an IoT system using an ECG sensor as input [10]. The system is developed further [11] for performance optimizations and the use of BCG sensor as input. The BCG sensor uses Murata's SCA11H sensor and all measurements taken is preprocessed first by the Data Concentrator, before being sent to the IoT system. The system contains a cloud server that acts as cloud database and web application that retrieves sensor data and serves sleep report to user and experts.

D. OAuth
The Fitbit-based application requires user authorization before being able to obtain data using OAuth 2.0 protocol. The OAuth 2.0 is one of the popular protocols [12] mostly used for authorizing single sign-on (SSO). Currently, there are 4 OAuth grant types depends on usage and purposes of the authorization. Both client and server who uses OAuth 2.0 protocol must adhere to best practice guidelines.

E. Polling
Polling is a technique that simulates server push using asynchronous requests [13] as to make events and updates delivered quickly to client. Polling works by sending a periodic request to a specific API endpoint and compares the response to check whether a server event has happened or not within a specified interval. Polling works on top of web protocols such as HTTP, so benefits of using HTTP protocols apply. The only downside is the required overhead for HTTP protocol header size compared to WebSocket protocol [14]. There are two types of polling for server-side implementation. Fitbit uses short polling, which returns a response despite no new updates and in turn requires a predefined interval. Meanwhile, a long polling implementation will hold the server from sending a response until a server event happened.

F. Long Short-Term Memory
Recurrent Neural Network (RNN) excels at making prediction or classification through a time-series based input data. This is because there is a feedback of the next iteration from the previous result as input. The negative effects are that RNN requires a longer time for training and some does not work at all. Long short-term memory (LSTM) addresses this issue by removing unused gradient from each iteration feedback [15] with the implementation of gates in each LSTM "cell".

III. RELATED WORKS
There are several methods that have been researched and developed further to monitor heart rate using portable, compact, and less complex sensors.
Montgomery-Downs et al. (2011) [16] created a study to compare Fitbit devices in terms of sleep efficiency calculations along with PSG and actigraphy, using each built-in sleep calculation algorithms. The Fitbit system relies on PPG and accelerometer sensor to infer sleep or wake and classification of sleep stages. Both Fitbit and actigraphy calculations are overestimated, with Fitbit calculations still has discrepancy even when compared to actigraphy. Paalasmaa et al. (2012) [17] proposed method uses a force sensor that detects heartbeat intervals and respiration cycle lengths. The data was compared with ECG reference with 99% precision and 88.73% recall. The sensor is connected to a microcontroller where the data can then be analyzed locally.
The analysis consists of sleep stage classification, stress reactions, heart rate curve and average heart rate, and restlessness index. The result can be accessed with a web application where it is presented as graphs and other statistical data. Santos et al. (2016) [18] proposes an IoT system for health gateway integrated with intelligent personal assistant (IPA). The system autonomously collects measurements from the user when required from the IPA. The IPA has a specific set of algorithms for required actions and alarm alert that can be defined. The proposed method can only do specific actions depending on the capability of IPA.
Pandey (2017) [19] proposes a machine learning model for prediction and detection of stress based on heart rate using an IoT system. The proposed method pushes raw data from the sensor directly to an IoT system setup in the cloud. The prediction and detection of stress uses logistic regression and support-vector machine (SVM) with an accuracy of 66% and 68% respectively during test.

Li et al. (2017) [20] proposes a monitoring system based on
IoT for heart rate. The interval of the IoT monitoring system is based using predefined risk category, where higher risk requires real-time monitoring and lower risk requires an event trigger. The proposed method uses ECG as the sensor and shows that the network quality demand is higher for real-time high-risk user.
Araujo et al. (2018) [21] proposes ApneaLink, which is a portable PSG sensor that is used to read data while the user is sleeping and processes the raw data obtained into a sleep apnea analysis. The proposed method requires the ApneaLink sensor to be bound to the chest and user's stomach. While the analysis happened real-time, it is done offline and only enables the user to monitor themselves. www.ijacsa.thesai.org Utomo et al. (2019) [10] proposes an IoT platform to analyze the sleep classification or stages of sleep as a measure of sleep quality. The proposed method uses ECG signals that is streamed real-time to the platform for monitoring and further analysis.
The continuation of the study by Utomo et al. (2020) [11] proposes an optimization of the platform, along with the use of real-time BCG sensor. The proposed method uses heart rate variability and beat-to-beat data from the BCG sensor. The result of this study introduces a less complex system for realtime monitoring, especially for monitoring heart rate.
Challenged for the ease-of-use to the users and real-time monitoring and analysis, smart wearables heart rate sensor is considered. Consequently, modern smart wearables only require installation of a smartphone application. Most smart wearables heart rate sensor uses PPG sensor technology that can assess heart rate in real-time, but most also requires Bluetooth connection for data syncing.
As it can be seen from previous research and studies, there is a need for easier to setup real-time heart rate monitoring system for regular use. There is also a need for improvement on existing IoT systems to be able to retrieve, store, and process data reliably without hogging too much resources.
Most smart wear sensor technologies have been explored for the possibility of portable monitoring, with ease and comfort in mind along with recurring use that doesn't negatively affect the user. Because of technological advancements of built-in smart wear sensors and increasing level of comfort, it can be considered as an alternative. Thus, the real-time monitoring system using smart wearables sensor is proposed in this research.

IV. PROPOSED ARCHITECTURE
The proposed architecture focuses on the use of Fitbit Charge 3 as an alternative to BCG sensor that introduces easy to use HR monitoring system at home, which can then be integrated to IoT system. This study also focuses on using edge computation technology to process data offline. After processing, the data can be sent to the server to be directly used, or further processing. Utomo et al. has developed the system that can monitor sleep quality [11] using real time HR data measured from BCG sensors. This research implements a simpler system with some modifications to allow real-time HR monitoring. This research also compares the HR data obtained between Fitbit Charge 3 and SCA11H BCG sensor.

A. Data Acquisition
For this study, the sensor used is Fitbit Charge 3 PPG sensor, a smart wearable in the form of a wristwatch with Fitbit OS firmware version 28.20001.63.5. The watch will be connected using Bluetooth to a Fitbit account via Fitbit application version 3.14 on Android version 9. After setting up Fitbit Charge 3 connection, the Fitbit application will be synced to Fitbit server. There is an All-Day Sync option in the Fitbit application settings, which when turned on will periodically sync every 15 -20 minutes.
The challenges while doing the research, is that it is noticeable the All-Day Sync option isn't working well. The workaround is by using Bluetooth-enabled microcontroller with the PC version Fitbit application installed, since the Fitbit smartphone application doesn't seem to work in the background. By linking the same account to both application, Fitbit can now sync seamlessly using either microcontroller or smartphone.
The second challenge is that there will always be a delay about 20 minutes for syncing Fitbit by design. The solution in this proposed design is to delay the data stream for around 20 minutes. By doing that, it will also enable you to use more advanced preprocessing algorithms since there's future data, relatively from 20 minutes ago, of the sensor. This is required for simulating beat-to-beat data given a valid heart rate for a given period.
Lastly, the heart rate data from Fitbit Charge 3 is measured in beat per minutes, while the current IoT system requires beatto-beat measurement data in milliseconds, also for comparison with SCA11H BCG sensor. The solution is by simulating beatto-beat data based on future heartbeat per minutes, using long short-term memory (LSTM) recurrent neural network (RNN).  Table I shows available sensor data from Fitbit.

B. Data Preprocessor
Data Preprocessor is implemented as an Android application. The application uses implicit grant using OAuth 2.0 to Fitbit server, and will start polling for Fitbit sensor data updates. The polling implements a short polling system with an interval of 1 minute to request intra-day heart rate data with interval of 1 second.
Fitbit WebAPIs sends a response containing the specified dataset in a minified JSON format, and subsequent interval with the same heart rate is removed. The Data Preprocessor applies the following algorithm before transmitting data to cloud:  B2B simulation: Due to the required input of the IoT system and the unavailability of B2B data from Fitbit Charge 3, it is required to predict HRV based on future heart rate per minutes and infer B2B time from predicted HRV. It is done using future time-series HR data with RNN. The input feature is future time-series HR data for a whole minute, passed into an LSTM layer with 8-time steps with relu as an activation function. The output of the LSTM layer is directed to a single dense layer using sigmoid activation function. As the heart rate between person differs, the training and testing should be done separately. Adam is used as an optimizer and the model is evaluated using mean absolute error (MAE) as the loss function.
 Data normalization: The current implementation of IoT system [11] requires B2B and HRV data and concatenates every 3 seconds of data for optimization requirements.

C. IoT System
Data that have been preprocessed by Data Preprocessor will be sent directly to the current implementation of IoT hosted on cloud platform using RESTful APIs. The data is uploaded through a REST interface with the following specification: Users data can be monitored in real-time with a data delay of around 20 minutes because of Fitbit API system implementation. This study uses a similar IoT system that has been developed [11] with the following hardware and software used:

GHz or 5GHz Wireless LAN 802.11ac for Data
Preprocessor, requiring a stable uplink internet connection for data retrieval from Fitbit server and data upload through REST API to the specified IoT system endpoint.

V. RESULTS
In this study, an examination was done on 2 healthy adults within age range of 20-25, 1 male and 1 female. The examination will be divided into resting phase and sleeping phase. For the resting phase, examinees are required to sits down and do light or no physical activity for the duration of the examination. For the sleeping phase, examinees are required to sleep normally while wearing BCG sensor and Fitbit Charge 3, with the required monitoring application installed on their smartphone.
Before examination, data are collected from both adults on a 30 minutes rest. The data are then used for training the RNN model to predict HRV values and B2B simulation. The pretrained model is compiled as a smartphone application which then installed on examinees' smartphone. For the examination, both adults are examined for 30 minutes of rest once a day for a total of 2 days, and 1 night of sleep.
All sensor data are collected using data concentrator for BCG sensor and Fitbit WebAPI for Fitbit sensor. Both data is then compared against each other by aligning the timestamp generated from the sensor. The data is saved as a commaseparated values (CSV) with filename formatted as log-[user]-[rest or sleep]-[n, if any].

A. Integration with IoT System
Integration with existing IoT system can supply another source of real-time data. After authorization through Fitbit server for data access to the examinee, the application will send a HTTP POST request to IoT server REST interface for Fitbit's user ID association. Afterwards, in this study, the only measurement used is the beat per minutes of examinee's heart rate.
After uploading the data to the IoT system, a real-time monitoring is possible. Fig. 3 demonstrates an implementation of IoT system with simple real-time chart for monitoring, where horizontal axis denotes time elapsed in seconds since IoT system started. The system is then tested for 5 hours of real-time monitoring.
The measurement taken for the monitoring dashboard is latency and packet loss. The measurement taken for the Data Preprocessor is packet loss. Both measurements are largely dependent to connectivity. www.ijacsa.thesai.org  During the test, there are 0 packet loss through a stable wireless LAN internet connection for both Monitoring Dashboard and the Data Preprocessor, which means all API responses are 200 OK. Meanwhile, the dashboard latency which uses long-polling is around 35-45ms. Fig. 4 shows a detailed latency throughout a random hour of the test for every second in 1-minute average.
The measurements for the server-side IoT system is Disk I/O for storing and retrieving measurements through API, and bandwidth for inbound and outbound traffic. This study implemented a simple IoT system which has little to none impact to memory footprint and CPU usage.
During the test, the IoT system is only running the required process for running the server. Fig. 5 shows server CPU usage, Fig. 6 shows server memory usage, Fig. 7 shows server Disk I/O usage, Fig. 8 shows server bandwidth and Fig. 9 shows average server load. All figures are monitored throughout 6 hours, two ±2.5 hours of test between 1 hour of idle system.

B. Sensor Accuracy
For each examinee, the heart rate measured from Fitbit is compared to the measurements using BCG in beat per minute (bpm). The calculation of error was done using mean square error (MSE) and rooted MSE (RMSE), which tends to give more weight to value that is further from the expected value. Both equations are:  For visualization, the heart rate data is compared within a Cartesian plot, where X-axis represents BCG measurement and Y-axis represents Fitbit measurements. Each point represents a point of time of heart rate measured with BCG sensors and Fitbit with 98% transparency. The ideal accuracy is represented with a black line which represents the same measurements from BCG sensor and Fitbit. The data is separated into resting phase and sleeping phase.  Fig. 11 for sleeping phase.
The MSE of the resting phase for both examinees are measured at 38.58222, when rooted measured at 6.211. The Fitbit tends to overestimate at a maximum of 31 bpm, while underestimate at a maximum of 18 bpm during the examination.
The MSE of the sleep phase for both examinees are measured at 206.45762, when rooted measured at 14.369. The Fitbit tends to overestimate at a maximum of 36 bpm, while underestimate at a maximum of 56 bpm during the examination.
During the sleeping phase, Fitbit method of measuring heart rate seems delayed or even doesn't detect a sudden, increased heart rate for a short period. This makes Fitbit Charge 3 unsuitable to detect disorders or problems during sleeping. While this might be an indicator of cardiovascular problems, both examinees admitted they have never had any, neither in person nor hereditary.

C. RNN Model Evaluation
Recurrent neural networks excel at forecasting using a time-series as inputs, with a total of two differing time-series from examinees sleeping phase. The sleeping phase is chosen for the length and duration of examination, containing more data individually compared to resting phase data combined. The feature selected are time-series data on the next 60 seconds to be predicted the HRV measurement.
Each of these data will be trained separately and evaluated using MAE. Before training, data from BCG sensor needs to be normalized, with the following rules: www.ijacsa.thesai.org  Removal of 0 HR / HRV measurements  Removal of status 0 [11] which means BCG sensor doesn't detect signal.
 Removal of greater than 3000 B2B measurements [22], since it is considered as a noise.
The MAE calculates the absolute error without weighting the distance between the error and the expected value. The MAE equation is: From each examinees' data, the training will use 75% of the dataset, while using the remaining 25% for testing. The evaluation is measured using MAE for both datasets and result in 2-5% loss for both training and validation dataset. Fig. 12 and Fig. 13 shows detailed training and validation loss during the process for each examinee.

VI. CONCLUSIONS
As observed, built-in heart rate sensors on smart wearables can be an alternative for monitoring heartrate which could be used for other applications such as sleep quality monitoring system. Despite the computing power of most smart wearables, it can be complemented with edge computing. In this study, a smartphone application is used for data preprocessing as an edge computation so the output data can be used directly to the IoT system. The IoT system would store the data for a registered user. Afterwards, an expert or the user can directly monitor user condition through web dashboard in real-time and the ability to view users' historical condition.
Although depending on the problem, the proposed method might prove impractical or inadequate when used as a solution. The proposed method uses Fitbit Charge 3 for its simplicity, security, and robust API documentation for developers. But due to unavailability of raw unprocessed data on Fitbit Charge 3, the Fitbit Charge 3 is not recommended for a more complex application such as sleep quality monitoring which requires HRV values and B2B data. Although this study proposes using RNN to predict HRV values and simulate B2B data using future time-series of measured HR, it is impractical and still requiring further studies.
Meanwhile, there might be other smart wearables with built-in heart rate sensors where it is possible to develop an application directly on the wearables to get and preprocess raw sensor data. While it requires more time to develop such application considering the limited computational power of smart wearables, it is more practical for the users and opens up the possibility of implementation for complex applications.
Currently, our research interest is focused on improving the IoT system by looking for an alternative sensor to get the required input data. The ideal sensor should be one that is practical and easy-to-use, without any discomfort when used regularly for a prolonged period. The objective of this study is also to reduce burden on the IoT system by taking advantage of edge computing for each node of the architecture.
On the other side, it is equally important to analyze the impact of modifications to the performance of IoT system and how much computational power can be distributed to the edge. By doing so, it would allow a balanced usage between edge computational power and improved IoT system efficiency and performance.