Energy Eﬃcient Fog-assisted IoT System for Monitoring
Diabetic Patients with Cardiovascular Disease
Tuan Nguyen Gia1, Imed Ben Dhaou2, Amir M Rahmani3,4,
Tomi Westerlund1, Pasi Liljeberg1, and Hannu Tenhunen1
1Department of Information Technology, University of Turku, Turku, Finland
2Department of Electrical Engineering, Qassim University, Saudi Arabia
3Department of Computer Science, University of California Irvine, USA
4Institute of Computer Technology, TU Wien, Vienna, Austria
Blood glucose plays an important role in maintaining body’s activities. For
example, brain only uses glucose as its energy source. However, when blood
glucose level is abnormal, it causes some serious consequences. For instance,
low-blood glucose phenomenon referred to as hypoglycemia can cause heart
repolarization and induce cardiac arrhythmia causing sudden cardiac deaths.
Diabetes, which can be viewed as a high-blood glucose level for a long period
of time, is a dangerous disease as it can directly or indirectly cause heart
attack, stroke, heart failure, and other vicious diseases. A solution for re-
ducing the serious consequences caused by diabetes and hypoglycemia is to
continuously monitor blood glucose level for real-time responses such as ad-
justing insulin levels from the insulin pump. Nonetheless, it is a misstep when
merely monitoring blood glucose without considering other signals or data
such as Electrocardiography (ECG) and activity status since they have close
relationships. When hypoglycemia occurs, a fall can easily occur especially
in case of people over 65 years old. Fall’s consequences are more hazardous
when a fall is not detected. Therefore, we present a Fog-based system for
remote health monitoring and fall detection. Through the system, both e-
health signals such as glucose, ECG, body temperature and contextual data
such as room temperature, humidity, and air quality can be monitored re-
motely in real-time. By leveraging Fog computing at the edge of the network,
the system oﬀers many advanced services such as ECG feature extraction,
security, and local distributed storage. Results show that the system works
accurately and the wearable sensor node is energy eﬃcient. Even though
Preprint submitted to Elsevier Future Generation Computer Systems JournalSeptember 16, 2020
the node is equipped with many types of sensors, it can operate in a secure
way up to 157 hours per a single charge when applying a 1000 mAh Lithium
Keywords: Glucose, Diabetes, ECG, Hypoglycemia, Fall Detection, Health
Monitoring, IoT, Fog/Edge Computing, Energy Eﬃciency.
Hypoglycemia describes an abnormal phenomenon when the blood glu-
cose level goes below 60 mg/dl. Hypoglycemia causes heart repolarization
and may induce cardiac arrhythmia which is one of the primary causes of
sudden cardiac deaths [1, 2]. According to Centers for Disease Control and
Prevention , millions of peoples are aﬀected by arrhythmia. Especially,
people with the age of 60 or more are at high risk of arrhythmia or atrial
ﬁbrillation (AF). QT-interval lengthening of ECG is a sign of arrhythmia.
Recently, research works have proposed the prediction of hypoglycemia by
analyzing QT-period and T-Wave [1, 4]. Hyperglycemia describes an abnor-
mal high-blood glucose level (e.g. 100-125 mg/dl as pre-diabetes and higher
than 126 mg/dl as diabetes). Heart repolarization time is altered by hy-
perglycemia [5, 6]. Similarly, hyperglycemia can be predicted by measuring
QT-interval length, QT-interval variability (QTV) and corrected QT interval
variability (QTcV). According to WHO, this number increased dramatically
from 108 to 422 million during 1990 - 2014  and is projected to raise up to
at two or three times by 2030 . People from any gender and any age can
have diabetes. For example, approximately 200,000 people who live in the
USA and are under 20 years old have diabetes . Diabetes not only occurs
in developed countries but also in developing countries. According to Na-
tional Vital Statistics Reports (NVSR), diabetes has a rank of 7 among the
15 leading causes of deaths in 2014 . The number of deaths directly caused
by diabetes is approximately 1.5 million in 2014 . In addition, diabetes can
directly or indirectly cause heart attack, stroke, heart failure, kidney failure,
blindness and other vicious diseases which are primary causes of deaths.
Unfortunately, diabetes cannot be cured with the existing knowledge. One
of the methods for reducing the serious consequences caused by diabetes is to
continuously monitor the blood glucose level and adjusting the insulin level
Fall and its consequences cannot be neglected or underestimated because
they might be the cause of serious injuries and traumas. For instance, bone
fracture, broken knee, neck fracture, head bruises and head traumas can be
caused by falls [11, 12]. The injuries require a long period of time to be healed
and fully recovered. Correspondingly, they cause signiﬁcant costs and reduce
the quality of life . However, merely 50% of the falling cases are reported
and in-time aided. Unreported cases might cause diﬃculty and complication
in treatments later.
Diabetes, cardiovascular diseases, fall and old people often have some re-
lationships. Diabetes has been identiﬁed as a risk factor for falls [14, 15].
For example, people who are over 65 years old are like to have diabetes,
cardiovascular diseases and fall more often. According to statistics, more
than 25% of people who are over 65 years old have diabetes and more than
30% of these people fall every year with hazardous consequences [11, 16]. In
addition, more than 68% of these people having diabetes die from cardiovas-
cular diseases . Therefore, it is required to have a system which can both
monitor diabetes, ECG and inform abnormalities (e.g., a fall, very low or
high glucose level, and abnormal heart rate) in real-time without interfering
the patient’s daily activities.
Internet of Things (IoT) can be considered as one the most suitable can-
didates for addressing the target. IoT can be expressed as a platform where
physical and virtual objects are interconnected and communicate together.
IoT consisting of many advanced technologies such as sensing, sensor net-
work, Internet and Cloud computing is capable of providing remote health
monitoring in real-time while the quality of life can be maintained. Via IoT
systems, collected data is stored in Cloud servers. Therefore, real-time data
and the historical data can be accessed remotely in anytime. In addition,
IoT systems are able to perform real-time responses or actions. For example,
an insulin pump of IoT systems can automatically or be remotely controlled
for injecting insulin into the patient’s blood when the blood glucose is low.
Although glucose monitoring IoT systems have advantages such as re-
mote real-time monitoring and global data storage, they have limitations.
For example, most of them are not secured because the data transmitted
over the network is not protected and encrypted. The transmitted data can
be listened and altered by unauthorized parties . Furthermore, most of
the existing health monitoring IoT systems do not support distributed local
storage. Critical data may be lost when the connection between the sys-
tems and Cloud servers are interrupted. In healthcare domains, losing some
critical data can lead to incorrect diagnosis and treatments of diseases.
A proper approach to solve the challenges in IoT systems is to apply an
extra layer named as Fog between gateways and Cloud servers. Fog layer is
run on the top of smart gateways to provide advanced services for enhancing
the quality of services. For example, Fog helps to save network bandwidth
between gateways and Cloud servers by processing and compressing data
[18, 19]. Furthermore, Fog helps to reduce the burdens of Cloud servers by
pre-processing data at smart gateways. Fog provides distributed local storage
for temporarily storing data. In addition to mentioned services, Fog facili-
tates many other advanced services such as system fault detection, database
synchronization, and interoperability. Moreover, Fog creates a convergent
network of interconnected and intercommunicated gateways, that helps to
overcome service interruption. With the beneﬁts of advanced services, Fog
not only solves many challenges of IoT systems but also enhances the quality
of services dramatically.
In this paper, a smart IoT system based on Fog for real-time and re-
mote healthcare monitoring is introduced. For improving the accuracy of
diseases analysis and diagnosis, the system monitors not only e-health data
such as blood glucose, ECG, patient’s movement and body temperature but
also contextual data such as room temperature, humidity, and air quality.
The system helps to detect abnormalities (e.g., a fall, high heart rate or high
blood glucose) and inform to responsible persons (e.g., caregivers or system
administrators) in real-time. The system is secured with cryptography al-
gorithms for protecting the collected data. Particularly, data is encrypted
at sensor nodes before being transmitted and decrypted at smart gateways.
The system with the Fog layer oﬀers advanced services such as interoperabil-
ity, distributed local storage, data processing (i.e., QT intervals extracted
from an ECG waveform, activity status categorization, and fall detection via
lightweight algorithms). Last but not least, the energy-eﬃcient sensor node
for monitoring vital signals is presented.
The rest of the paper is organized as follows: Section II includes related
work and motivation for this work. Section III provides an overview architec-
ture of the health monitoring IoT system having Fog assistance. Section IV
emphasizes on Fog services such as the algorithm for extracting QT intervals
from an ECG waveform, fall detection, and activity status categorization.
Section V presents test-bed and the system implementation. Section VI pro-
vides insights about experimental results. Finally, Section VII concludes the
2. Related work and motivations
Many eﬀorts have been made for proposing real-time and remote health
monitoring IoT-based systems. Rahmani et al.  present an IoT system
with a smart gateway for e-health monitoring. The gateway supports inter-
operability with Bluetooth Low Energy (BLE), Wi-Fi, and IPv6 over Low-
Power Wireless Personal Area Networks (6LoWPAN). The gateway provides
many advanced services such as data compression, data storage, and secu-
rity. In [21, 22], an ECG monitoring IoT-based system using 6LoWPAN is
proposed. The system consists of smart gateways and energy eﬃciency sen-
sor nodes. In [23, 24], authors present IoT systems for fall detection. The
systems use wearable sensor nodes for collecting 3-dimensional (3-D) accel-
eration and 3-D angular velocity. The systems with smart gateways oﬀer
push notiﬁcation services for informing a fall to caregivers. In , authors
present a glucose monitoring IoT-based system which shows some levels of
energy eﬃciency by applying 6LoWPAN and RFID. The system can distin-
guish non-fasting and fasting cases for an accurate diagnosis. In , authors
propose an IoT system for non-invasive glucose level sensing. The system uses
a laptop as a gateway for receiving data from 6LoWPAN nodes and sending
the data to Cloud servers. In most of the discussed work, security is not
attentively considered. Especially, the connection between sensor nodes and
the smart gateway is not fully protected. Some of the works provide smart
gateways. However, services provided at the smart gateways are limited.
Some of the works do not support interoperability which limits the ﬂexibility
and ubiquity of the health monitoring systems.
Other works [27, 28] consider high levels of security for health monitoring
IoT systems. The connection between sensor nodes and smart gateways
are secured by light-weight cryptography algorithms. However, the energy
eﬃciency of sensor nodes is not attentively considered.
Recently, researchers have proposed health monitoring IoT systems with
Fog computing. The Fog-based systems have advantages such as bandwidth
saving, energy eﬃciency, and a high level of security. In , authors apply
a smart gateway and Fog computing into an ECG monitoring IoT system.
The system provides many services such as categorization, push notiﬁcation
and distributed local storage. In , authors propose an IoT system with
Fog computing for continuous glucose monitoring system. The system uses
a mobile-based gateway for processing and analyzing data. When the smart
gateway detects abnormalities such as too low or too high blood glucose
level, it sends push messages for informing medical doctors in real-time. In
[18, 19], authors propose a Fog approach for ECG monitoring systems. The
systems can extract ECG features at Fog and achieve some levels of energy
eﬃciency at sensor nodes. In [31, 32], health monitoring IoT systems with
Fog computing are proposed. These systems provide many advanced Fog
services such as data analysis, data fusion, distributed local data storage,
and data compression. By using a web-browser, real-time ECG data can
be remotely and real-time monitored. Dubey et al.  propose a Fog
approach for enhancing telehealth big data. The system analyzes ECG data
for ﬁnding similar patterns. Cao et al.  propose a Fog approach for a
fall detection IoT system. Fog computing and Cloud servers run the U-fall
algorithms for detecting fall automatically in real-time. Azimi et al. 
present a Fog approach for a medical warning system. ECG is analyzed
at Fog for early-detecting patient deterioration. Cao et al.  present a
Fog computing, distributed analytics-based fall monitoring system. In the
system, a new set of fall detection algorithms is investigated and developed
for improving the results of fall detection. Craciunescu et al.  apply Fog
computing for reliable e-health applications (i.e., human fall detection). The
system has both e-health and contextual sensor nodes which are built from
general purpose devices (e.g., Arduino Uno and Lilypad). These sensor nodes
transmit the collected data to a computer for processing.
Although the mentioned Fog-based approaches provide advanced services
for enhancing health monitoring systems, none of them considers aspects of
sensor node’s energy eﬃciency, security, and the relationship of e-health data
(i.e., diabetes, ECG, body motion and body temperature). Energy eﬃciency
is a vital characteristic of healthcare IoT systems. When a sensor node is
not energy eﬃcient, it can cause service interruption which is one of the rea-
sons for reducing the accuracy of disease analysis. When the system is not
secured, patient’s information can be stolen or the system can be instructed
for doing unacceptable actions. Disease analysis and diagnosis might be inac-
curate when standalone e-health data is used without considering contextual
data or activity status. For instance, heart rate during sitting and training
is diﬀerent. In this paper, we propose an IoT system with Fog computing for
health monitoring. The system not only monitors e-health (i.e., blood glu-
cose, ECG, and body temperature), daily activity, and contextual data (i.e.,
room temperature, humidity, air quality) but also provides advanced services
for improving the accuracy of disease analysis and informing abnormalities
(i.e., hypoglycemia, hyperglycemia, and cardiac disease) in real-time. An
Figure 1: Architecture of Fog-assisted IoT system for monitoring diabetes patients with
end-user such as caregiver can monitor e-health data in textual and graph-
ical forms in real-time. In addition, many techniques and Fog approaches
are applied to achieve a high level of energy eﬃciency while the connection
between sensor nodes and smart gateways is protected by an AES algorithm.
The architecture of the proposed system shown in Figure 1 has 3 layers
including sensor node layer, Fog computing layer consisting of Fog-assisted
smart gateways, and Cloud servers with end-user terminals. Each layer is
discussed as follows:
3.1. Sensor layer
Sensor layer includes diﬀerent types of sensor nodes such as contextual
nodes, e-health nodes, and actuator nodes. Contextual nodes can be ﬁxed at
a single room for gathering contextual data from surrounding environments
such as a room temperature, humidity, time, location and air quality. The
contextual data plays an important role in achieving accurate analysis. For
example, human pulse rate is likely to increase when the temperature rises.
In , from the experiments with more than 30 thousand children, authors
showed pulse rate increases more than 20 pulses when the temperature rises
from 35 to 40 Celsius degrees.
E-health nodes can be categorized into diﬀerent types depending on the
given health monitoring application. In this paper, three types of e-health
sensor nodes such as low data rate sensor nodes, high data rate sensor nodes
and hybrid sensor nodes equipped with both low and high data rate sensors.
Low data rate sensor nodes can be used for acquiring blood glucose, body
temperature, and humidity. High data rate sensor nodes can be used for
collecting ECG and body motion (e.g., acceleration and angular velocity).
Hybrid sensor nodes can be used for collecting all mentioned data.
Actuator nodes are used for controlling actions related to health or the
surrounding environment. Actuator nodes often receive instructions from a
smart gateway. For example, an atmosphere controlling actuator can adjust
a room’s temperature and humidity.
The collected data from sensor nodes is sent to smart gateways via one of
several wireless protocols. A choice of a speciﬁc wireless protocol depends on
the application’s requirements. For example, Wi-Fi is used for high data rate
monitoring applications (e.g., 8-channel EMG monitoring in which each chan-
nel collects 1000 24-bit samples/s [39, 40]). Bluetooth Low Energy (BLE)
or IPv6 over Low-Power Wireless Personal Area Networks (6LoWPAN) is
used for low data rate health monitoring applications (1-channel ECG mon-
itoring in which each channel collects 125 16-bit samples/s [21, 22]). In the
proposed system, an nRF protocol, which is ultra low power 2.4 GHz ISM
band wireless protocol, is utilized because of its ﬂexibility of data rate sup-
port and energy eﬃciency . The nRF protocol supports data rates of 250
kbps, 1 Mbps, and 2 Mbps. In addition, it supports many-to-many commu-
nications which are not supported by BLE. The collected data can be kept
intact or pre-processed before being transmitted. In most of the cases, sen-
sor nodes merely perform simple computations whilst heavy computational
tasks are run at Fog-based smart gateways. For instance, basic ﬁlters based
on thresholds can be used at sensor nodes for eliminating abnormal values
while complex algorithms based on wavelet transformation for extracting
ECG features are run at Fog [19, 18].
3.2. Fog computing layer consisting of Fog-assisted smart gateways
Smart gateways can be ﬁxed or movable depending on the given appli-
cation. In many health monitoring applications in hospitals, ﬁxed gateways
are more preferred because they can use power and Ethernet from wall sock-
ets. Accordingly, ﬁxed gateways can serve many sensor nodes simultaneously
and oﬀer advanced services running heavy computational algorithms whilst
movable gateways are not capable due to limited battery capacity. In addi-
tion, ﬁxed gateways are more secured because they are kept intact and can
perform advanced security algorithms.
In addition to conventional tasks of receiving and transmitting data, Fog-
assisted smart gateways proﬀer many advanced services for enhancing the
quality of healthcare services. Some of the Fog services are distributed lo-
cal storage, data compression, localhost with user interface, categorization
service, and push notiﬁcation.
Distributed local storage often consists of synchronized and intact databases.
The synchronized database stores real-time contextual and e-health data
while the intact database stores data used for algorithms, services and the
system’s conﬁgurations such as username and password and algorithm’s pa-
rameters. The synchronized database is synchronized with Cloud servers’
database while data in the intact database is only updated by system ad-
ministrators. Due to the limited storage of the synchronized database, the
oldest data is purged for storing incoming data.
Data compression helps to save network bandwidth. Although compress-
ing and decompressing cost some resources and latency, they do not aﬀect
the performance of other services and only increase the total latency slightly
Categorization service is used to categorize local users and external users.
Particularly, the categorization service scans Wi-Fi devices around smart
gateways. As a result, local devices are stored in smart gateways’ database.
When a user tries to connect to smart gateways, the system checks the
database. If the user is a local user, the smart gateways send real-time
data directly to the user’s terminal without going through Cloud servers.
Push notiﬁcation is one of the most important services in Fog. Push
notiﬁcation is used for informing abnormalities in real-time to responsible
persons such as system administrators or caregivers.
These services are explained in detail in our previous works [31, 29, 32].
Although these services are not the main focus of this paper, they are still
implemented in the system. In addition to mentioned services, there are vital
services such as data analysis, data processing, interoperability, and security.
Detailed information of these services is discussed in section 4.
3.3. Cloud servers and end-user terminals
Cloud servers provide many beneﬁts such as centralized global storage,
scalability, data security and data processing. Heavy computational tasks,
which cannot be run at Fog, can be processed smoothly in Cloud servers.
For example, Cloud servers support modern machine learning services with
pre-trained models. In addition, Cloud servers support powerful search, dis-
covery and image analysis. E-health and other related data (e.g., records of
patient’s health status) can be stored at Cloud servers. Diﬀerent technolo-
gies (e.g., WebSockets and JSON) can be installed at Cloud for hosting a
comprehensive website showing real-time data in both textual and graphi-
cal interfaces [42, 43]. Furthermore, Cloud servers support push notiﬁcation
sending the instant messages to an end-user in real-time. In the proposed
system, push notiﬁcation is used for informing abnormalities (i.e., related to
patient health and the system’s technical problems) to responsible persons
such as caregivers or system administrators. End-users can use terminals
such as smart phone’s app or web browsers to access both real-time data
and the historical data. In addition, end-users such as caregivers can provide
instructions or advice via the terminals.
4. Fog services
As mentioned, smart gateways in Fog computing can oﬀer many advanced
services (e.g., localhost, categorization, and push notiﬁcation) and thereby
potentially enhance the quality of healthcare services. In this paper, interop-
erability, security, data processing are investigated and explained as follows:
4.1. Data processing
Data processing and data analysis in Fog-assisted smart gateways play
important roles in health monitoring systems. They not only help to reduce
the burden of Cloud servers but also help to extract important information
which can be used for real-time critical decision making and push notiﬁcation.
In this paper, heart rate, QT intervals, corrected QT intervals are extracted
from an ECG waveform. The extracted information combined with other e-
health data such as blood glucose level, body temperature, and body motion
is used for detecting hypoglycemia and hyperglycemia in real-time.
4.1.1. Heart rate and the QT interval extraction algorithm
ECG can be deﬁned as a periodic signal in which each normal ECG
waveform represents the electrical events in one cardiac cycle. A normal
ECG waveform, shown in Figure 2, often consists of several waves named as
P, Q, R, S, T, and U. If the baseline of the ECG is zero, the three waves P,
R, and T often have positive peaks whereas the waves Q and S often have
Figure 2: ECG signal generated using Matlab (Ideal).
From an ECG signal, heart rate can be calculated based on the formula:
Heart rate =60 / RR interval . RR interval can be easily calculated
since R peaks have the highest amplitude among all waves.
Peak detection can be computed using a linear time algorithm that seeks
the determination of local extreme. The algorithm to determine the QT-
period starts by ﬁrst locating the lowest interval IPin which the P-wave
reaches its maximum. Then, the same procedure is applied to compute IP,
IR,ISand IT, where the subscript in Idesigned the type of the wave. The
QT-length is then computed using IQT =IR+IQ+IS+IT. The pseudo-
algorithm to compute the lowest interval in which a function f(x) reaches
its local maximum is shown in Alg.1. The algorithm takes two inputs: xi=
f(ti), where tiis the instant of time ti. The algorithm is a stream type,
consequently, does not consume memory which makes it suitable for tiny
When QT interval is extracted, corrected QT (QTc) interval can be easily
calculated by one of the formulas shown in Table 1. Currently, Bazett’s QTc
(QTcB) is used as a clinical standard but authors  showed that Fridericia’s
QTc (QTcFri) might become the next clinical standard replacing for QTcB.
In this paper, Bazett’s QTcB is applied for the experiments.
Algorithm 1 Algorithm to compute local maximum of a function f(x)
if (xi−1= 0 and xi>0) then
else if (I16= 0 and xi>0) then
M=Max(xi, M )
else if (I16= 0 and xi= 0) then
return M, [I1, I2]
where x: value of ECG
t: speciﬁc time(s)
4.1.2. Activity status categorization and fall detection algorithm
It is inaccurate to analyze only ECG without considering an activity sta-
tus because ECG signals change dramatically based on the current activity
status. For example, ECG of a person during resting and running is diﬀer-
ent. Therefore, ECG and activity status must be monitored and analyzed
Activity status representing daily physical activities of a person can con-
sist of three primary groups such as non-moving/resting, walking, and train-
ing exercises. Each group can have many activities (e.g., sleeping, lying,
standing and sitting belong to a non-moving/resting group or running, push
up, weight lifting and other heavy activities belong to a training group). Ac-
tivities belong to the same group have similar eﬀects to the ECG waveform.
Miao et al.  show that ECG of a person during standing and sitting are
almost similar. Therefore, the paper only focuses on standing, walking and
running where each activity represents for each group of three mentioned
A person’s activity status can be detected by using camera or wearable
motion sensors. In this paper, wearable motion sensors are used because it
Table 1: Formulas for calculating corrected QT interval
Bazett (QTcB)  QTc = QT / (√RR)
Fridericia (QTcFri)  QTc = QT / ( 3
QTc = QT + 0.154 x (1 - RR)
Hodges (QTcH) QTc = QT + 0.00175 x ([60 / RR] - 60)
Rautaharju (QTcR) QTc = QT - 0.185 * (RR - 1) + k
(k=+0.006 seconds for men and +0 seconds
does not limit a person’s activities. In addition, wearable motion sensors can
be used to detect a human fall [52, 23]. A person’s activity status and a
human fall are detected by the algorithm shown in Figure 3.
The algorithm includes many steps such as the acquisition of 3-D accelera-
tion and 3-D angular velocity, data ﬁltering and fall detection. The algorithm
uses both 3-D acceleration and 3-D angular velocity because according to Gia
et al. , they help to improve the accuracy of a fall algorithm. Similar to
ECG signals, motion-based signals are aﬀected by surrounding noise. There-
fore, noise must be removed by using ﬁlters (e.g., moving average and 50
Hz low pass) to achieve a high quality of signals. The ﬁlter data is used to
calculate activity-related parameters by the following formulas :
Φ = arctan py2
SVM : Sum vector magnitude
i: sample number
x,y,z: accelerometer value or gyroscope value of x, y, z axis
Φ : the angle between y-axis and vertical direction
The calculated parameters are compared with a ﬁrst set of thresholds in-
cluding activity status categorization threshold and fall detection threshold.
For example, activity status categorization threshold consists of 1.2 g and
30 deg/s for 3-D acceleration and 3-D angular velocity, respectively. For de-
tecting a human fall, the ﬁrst fall detection threshold is 1.6 g and 100 deg/s
for 3-D acceleration and 3-D angular velocity, respectively. If the collected
data surpasses the ﬁrst set of thresholds, they are marked as ”possibility”
data and they are compared with both the second set of thresholds and the
historical data. For instance, 1.6 g and 100 deg/s can be used as the sec-
ond activity status categorization thresholds while 1.8 g and 130 deg/s can
be used as the second fall detection thresholds for 3-D acceleration and 3-D
angular velocity, respectively. If one of the values surpasses the second fall
detection thresholds, a human fall is detected. Simultaneously, the activity
status is detected based on the number of values surpassing the ﬁrst and
second activity status categorization threshold. In most of the cases, mo-
tion data only surpasses the ﬁrst activity status threshold when a person is
walking. When the person is running, the number of values which are higher
than the second activity status threshold is large. The results of comparing
the data with the history data help to categorize activity status more ac-
curately. For instance, some periods of the 3-D acceleration should have a
similar pattern (i.e., rising up to peak then decreasing) when a person walks
or runs. In addition, the results help to detect the malfunctioned sensors.
If one of the sensors (accelerometer or gyroscope) and is the historical data
do not provide the expected values (i.e., 1 g and 0 deg/s for acceleration
and angular velocity, respectively when standing or lying in bed), the push
notiﬁcation service is triggered.
Figure 3: Activity status and fall detection algorithm
In general, most of the traditional monitoring systems merely support a
speciﬁc type of sensor nodes such as Wi-Fi-based node for EMG monitoring
, 6LoWPAN-based node for ECG monitoring [21, 22], classic Bluetooth-
based node for ECG, EMG monitoring  or BLE-based node for human
fall detection . Some other systems can support some of the wireless
communication protocols such as Wi-Fi and BLE . These systems are
not suitable for sensor nodes using other communication protocols such as
LoraWan, Zigbee or nRF. Fog computing with its capability oﬀers interop-
erability to solve these challenges. The interoperability is a capability of
supporting not only sensors from diﬀerent manufacturers but also diﬀerent
communications protocols including wire and wireless protocols. For exam-
ple, Fog-assisted smart gateways can support Ethernet, Wi-Fi, classic Blue-
tooth, BLE, nRF, and 6LoWPAN. Depending on applications, other wire
or wireless communication protocols can be added into Fog-assisted smart
gateways. For instance, LoraWan can be added for supporting long-range
distance related applications. When the new hardware (i.e., LoraWan chip)
is added to a smart gateway, the operating system of the gateway automat-
ically detects a new device or component. A new thread can be created for
transmitting the data via the added component. Sensor nodes in the Fog-
based system can work both independently and cooperatively. The sensor
nodes can communicate with each other via Fog-assisted smart gateways. In
this work, smart gateways support Wi-Fi, BLE, Ethernet, and nRF.
4.3. Security with Lightweight Cryptography
In health monitoring IoT systems, the connection between sensor nodes
and gateways is often the most vulnerable part of the system. The main
reason is that the sensor nodes are wearable and resource constraint devices.
Therefore, they cannot run complex security algorithms. Even though com-
plex security algorithms can be run successfully at sensor nodes, they are not
applied because latency requirements of the system might be infringed and
their battery is depleted. In many IoT systems [24, 23, 52], raw data is often
transmitted for saving sensor nodes’ battery life. This approach is dangerous
because data can be listened by unauthorized parties. In the worst case, they
can instruct commands to cause a harm to a patient. For example, Klonoﬀ
 uses his software to steal the security credential of the glucose monitor-
ing system. As a result, he has a full control to an insulin pump. In order to
avoid such cases, lightweight security algorithm must be run at sensor nodes.
The algorithm must provide some levels of security while sensor node’s bat-
tery life cannot be reduced signiﬁcantly. In the paper, the AES algorithms
 are applied. The AES algorithm consists of four basic primary opera-
tions (i.e., SubBytes, ShiftRows, MixColumns, and AddRoundKey). Each
sensor node or a group of sensor nodes has its private keys for encrypting
the data while a gateway has all private keys of all sensor nodes and groups
of sensor nodes. The keys are hard-coded in the sensor node’s ﬁrmware and
their length can be 128, 192 or 256 bits. In detail, each sensor node has three
diﬀerent private keys where each private key has an ID and is used during a
period of time (e.g., 1 hour). Before a new key is applied, the sensor node
sends messages to inform a corresponding gateway about the key ID. At a
smart gateway, the encrypted data received will be decrypted by the correct
private key which has been retrieved from a table of all private keys based
on the received ID.
5. Test-bed and system implementation
A complete IoT-based system with Fog computing for continuous glucose,
ECG, body temperature and body motion monitoring is implemented. The
system includes 4 smart gateways, 6 contextual sensor nodes, 4 e-health
sensor nodes, Cloud servers, and end-user terminals such as mobile apps.
Two gateways are placed in two adjacent rooms while other two are placed
at corridors. These gateways are connected to the Internet via Ethernet
cables and supplied with power from wall sockets. Each of the rooms has
3 contextual sensor nodes placed at middle, top and back corners of the
room. Each e-health sensor node is attached to a chest of volunteers who are
about 30 years old and healthy male and female persons. The e-health sensor
node collects ECG data via electrodes placed at left arm, right arm, and left
leg. The experimented rooms are oﬃce rooms consisting of computers and
furniture such as tables and chairs. Detailed information of the system’s
components are explained as follows:
5.1. Sensor layer implementation
The system has two types of sensor nodes consisting of contextual sensor
nodes and e-health sensor nodes. Each sensor node has ﬁve primary com-
ponents including microcontroller, sensors, energy harvesting unit, power
management unit and wireless communication chip. These sensor nodes are
discussed in detail as follows:
An ultralow power ATmega328P - 8-bit AVR microcontroller is used in
sensor nodes. The microcontroller ﬂexibly supports diﬀerent frequencies
(e.g., up to 20 Mhz) and various sleep modes for saving energy. In the
proposed system, a sensor node merely performs simple computational tasks
whilst heavy computational tasks are processed at Fog. Therefore, the sen-
sor node does not need to run at a high clock frequency for saving energy
consumption. In the implementation, 1 Mhz clock frequency is applied to all
The microcontroller supports diﬀerent communication interfaces such as
SPI, I2C, UART and many GPIO ports (i.e., digital and analog ports). Cor-
respondingly, it can connect to various sensors and components produced
by diﬀerent manufacturers. Furthermore, the microcontroller has 1 KBytes
EEPROM and 2 KBytes internal SRAM. Hence, it is capable of supporting
many libraries for collecting data from diﬀerent sensors. In , authors show
that SPI is more energy-eﬃcient and has a higher bandwidth than other in-
terfaces. Therefore, SPI is used in most of the cases such as the connection
between the microcontroller and other components (i.e., wireless communi-
cation chip and sensors). In case of unavailable SPI, I2C is preferred.
Contextual sensor nodes are equipped with BME280, SNS-MQ2, SNS-
MQ7, SNS-MQ135 for collecting room temperature, humidity, and air qual-
ity levels. DHT22 is a small size humidity and temperature sensor which
outputs the calibrated digital signals. With a high operating range (i.e., 0-
100% for humidity and -40 - 80 Celsius degrees), the sensor can operate in
harsh environments. The sensor has a high resolution (0.1% RH for humidity
and 0.1 Celsius for temperature) and it is accurate (e.g., +-2%RH and +-0.5
Celcius). SNS-MQ2, SNS-MQ7, and SNS-MQ135 are air sensors for collect-
ing LPG, propane, hydrogen, methane, CO, NH3, NOx, alcohol, benzene,
smoke, CO2 from the air. These contextual sensor nodes are ﬁxed in a room.
Therefore, the contextual sensor nodes can use power from a large capacity
battery (e.g., 3.7 V 10000 mAh Lithium battery having a size of 5 x 120 x
90 mm) or from a wall socket with a voltage adapter. The detailed informa-
tion of power consumption of these contextual sensor nodes is presented in
E-health sensor node can be categorized into low data rate, high data
rate, and hybrid nodes where hybrid node consists of both low and high data
rate sensors. Low data rate nodes are equipped with a glucose sensor and a
body temperature sensor. The glucose sensor includes an implantable sensor
under a patient’s skin and a transmitter placed on a top of the skin. In
the implementation, the transmitter is connected to the microcontroller via
SPI. The glucose sensor collects glucose level every 5 minutes as the glucose
level does not change rapidly. Similarly, the body temperature sensor (i.e.,
BME280 produced by Bosch) is connected to the microcontroller via SPI.
The temperature data is collected every 2 minutes.
High data rate e-health sensor nodes are equipped with a motion sensor
and an ECG analog front-end. A motion sensor (i.e., MPU-9250) is an ul-
tralow power sensor for collecting 3-D acceleration, 3-D angular velocity, and
3-D magnetism. The data rate of the motion sensor is 50 samples/s. The
low-power ECG analog front-end can be TI ADS1292 or AD8232. In the
implementation, a data rate of 125 samples/s is used.
A power managing unit is a low-power Schmitt trigger based circuit hav-
ing several super-capacitors. The power managing unit can detect the energy
level of the battery, power, and current via INA226 which is a current shunt
and power monitor produced by TI.
The wireless communication chip is nRF24L01 which is an ultralow power
RF transceiver supporting many-to-many communications. The nRF24L01
chip supports up to 2 Mbps. However, 250 kbps is used for saving energy
consumption. The chip can run with low-power, average-power or maximum
power. In this paper, it is conﬁgured to run at low-power mode and is
connected with the microcontroller via SPI.
5.2. Smart gateway and Fog services implementation
A smart gateway of the system is built with Pandaboard which has a 1.2
GHz dual-core Arm Cortex microprocessor and 1 GB low-power DDR2-RAM.
Pandaboard supports several communication interfaces such as Wi-Fi, Blue-
tooth, and Ethernet by built-in components. In addition, it supports a 32 GB
SD-card which can be used for installing embedded operating systems. In
the implementation, a lightweight version of Ubuntu based on Linux is used.
Many services such as security (AES), data decompression, data processing
and data analysis have built on the operating system.
For providing interoperability, several wireless communication compo-
nents are added into Pandaboard. To receive data from the sensor nodes
which are equipped with nRF, an nRF24L01 chip is connected to Pandaboard
via SPI. The nRF24L01 chip in the gateway is similar to the nRF24L01 chip
used in sensor nodes except that it has some extra circuits and uses a large
external antenna. Using a large antenna costs higher energy consumption,
but it increases the quality of collected signals. For supporting 6LoWPAN,
a composition of a CC2538 module and a SmartRF06 board is added into
Pandaboard. The detailed information of the connection can be seen in our
previous works [21, 22]. These components are connected to Pandaboard
via Ethernet and USB ports because Ethernet can provide high transmis-
sion bandwidth. To support several BLE sensor nodes, the smart gateway
can be equipped with BLE components (i.e., CYBLE-202007-01 provided by
Cypress Semiconductor). The number of added BLE components depends
on the available UART ports of Pandaboard. However, these UART ports
are limited. To overcome the issue, an FTDI chip and an ATmega328P mi-
crocontroller are added to Pandaboard. These components can facilitate 7
BLE components which are connected via software-based or hardware-based
UART. When the number of BLE sensor nodes is larger, more components
can be added to Pandaboard via USB hubs. Due to a built-in Wi-Fi chip in
Pandaboard, it can support high-speed Wi-Fi based sensor nodes.
Since sensor nodes run the AES algorithm for encrypting transmitted
messages, the smart gateway has to run the AES algorithm for decrypting
the received messages. For being compatible with other services, the AES
algorithm run in the smart gateway is implemented in Python. Decrypted
messages are stored in the smart gateway’s database which is built from
MongoDB and JSON objects. The database combines with HTML5, XML,
a user accesses the data, the system categorizes the user as a local user or
an external user via the categorization service. If a user belongs to a local
network, the system directly sends the data from Fog to the user. This
method helps to reduce the large latency of transmitting real-time data via
Cloud servers. The categorization service is implemented by Python and
Linux packages such as ”iw” and ”iwconﬁg”.
For protecting the smart gateways, Iptables and a part of our advanced
security methods presented in [27, 55] are implemented in the system. Par-
ticularly, the part of these methods for protecting the connection between the
smart gateways and Cloud servers is merely applied. Other parts are not uti-
lized because they can cause an increase in latency and energy consumption
of sensor nodes.
In the smart gateway implementation, the QT detection algorithm, data
ﬁltering, and data processing are implemented in Python because it remains
the consistency with other services. For instance, moving average ﬁlters and
50 Hz low pass ﬁlters for removing noise out of ECG signals are implemented
5.3. Cloud servers and end-user terminals
In the implementation, Google Cloud servers, API, and Cloud’s services
are used for storing, processing data and providing advanced services. For
instance, the push notiﬁcation service of the system is primarily implemented
at Cloud. Similar to localhost in Fog, Cloud servers host the global web-pages
which can show both real-time data and the historical data in textual and
graphical forms. For accessing data, end-users can use the global web-pages
or a mobile app which is built by PhoneGap for supporting both IOS and
6. Experimental results
At Fog-assisted smart gateways, collected e-health data such as accelera-
tion, angular velocity, and ECG is processed with 3 primary steps, shown in
Figure 4 and Figure 5, including data ﬁltering, baseline detection, and base-
line wander removal. As mentioned, raw data is ﬁltered to eliminate noise
from surrounding environment. In most of the cases, the ﬁltered data has
a diﬀerent baseline than the reference baseline which is 1 g, 0 deg/s, and 0
voltage for acceleration, angular velocity, and ECG, respectively. Therefore,
baseline detection and baseline wander removal are applied for shifting the
signals’ baselines into the expected ones. Figure 4 does not show the baseline
detection step because the signals and the detected baseline overlapped in
several periods. Two diﬀerent methods are applied for detecting the baseline
of diﬀerent signals. A mean value is applied for detecting the baseline of
acceleration and angular velocity while Daubechies d4 wavelet transform is
applied for detecting the baseline of ECG. The processed data has the same
magnitude and waveform as the ﬁltered data and are used as inputs for al-
gorithms such as fall detection, heart rate calculation and QT wave’s length
extraction shown in Section 4.1.
Figure 4: Acceleration and angular velocity processing
Figure 5: ECG processing
Parameters of the experimented room environment are 22 degrees Celsius,
31% humidity, 0.6 ppm for CO, around 8 ppb for NO2, and 6 ppb for SO2.
These values indicate that the room environment is good. Body temperature
and glucose are collected but it is not used for the comparison because its
value merely slightly changes during diﬀerent activities. For instance, the
collected body temperature and glucose of a volunteer are around 37 degrees
Celsius and around 100 mg/dL for all activities except for training (e.g., run-
ning), respectively. When a volunteer intensively runs, the core temperature
increases. The blood glucose level varies depending on the monitoring time.
For instance, the glucose level in the morning is lower than in the after-
noon and after lunch. In our experiments, the glucose level of that person
ﬂuctuates around 90-98 mg/dL for all measurement cases.
In the experiments, data shown in Figure 6 including acceleration, angu-
lar velocity, and ECG is collected from diﬀerent activities such as standing,
lying in bed, walking and running. Data in the same category is presented
in the same scale for fair comparisons. Data in both cases of lying in bed
and standing is stable and similar (e.g., 1 g acceleration, 0 deg/s angular
velocity, and stable ECG waveform). The ECG waveform has waves such
as P wave, Q, wave, R wave, S wave and T wave which are needed for al-
gorithms (e.g., heart rate calculation and QT’s length extraction). In case
of lying and standing, results of the algorithms show that heart rate is 59
beats/minute, the length of QT and QTcB is around 390 and 387, respec-
tively. In Figure 6(a), acceleration and angular velocity slightly changes
(i.e., 1.08 g acceleration and 10 deg/s angular velocity) at some moments
(i.e., around 166-172th samples and 235-240th samples). These variations are
expected as the user slightly moves his body two times during lying in bed.
Fortunately, the ECG waveform in those moments remains stable (e.g., ECG
before and during those moments is similar in terms of the number of waves,
waves’ magnitude, and shape of the waves such as P wave and QRS waves).
Figure 6: Acceleration, angular velocity and ECG in diﬀerent activity status
Figure 7: Acceleration, angular velocity and ECG when a user falls in diﬀerent cases
Although acceleration and angular velocity ﬂuctuate during walking, the
amplitude of the ﬂuctuation is small when comparing to pre-deﬁned thresh-
olds (i.e., 2 g and 200 deg/s for acceleration and angular velocity, respec-
tively) in the fall detection algorithm. However, the ﬂuctuation helps to
identify a walking status and calculate the number of steps of a user (e.g., by
counting the number of top peaks of the ﬂuctuation). Angular velocity can
be used as the compliment parameter to distinguish diﬀerent activities such
as movement and non-movement. The shape of angular velocity waveform
can be diﬀerent depending on the walking or running style of the user (e.g.,
swinging arms and hands during walking). ECG moderately changes during
walking. QRS wave, T wave, and QT’s length can be detected in most of
the ECG cycles whilst P wave merely appears in some of the ECG cycles
(i.e., one per every 6-8 ECG cycles). In this case, QT’s length and QTcB’s
length is around 395 and 392 ms, respectively. Comparing with ECG waves
in standing and lying in bed, the ECG wave during walking is not as good
as others in terms of stability.
In case of running, data ﬂuctuates dramatically when compared with
their baseline. Acceleration, in this case, shows the number of steps of a
user (i.e., top peaks have much higher amplitude than the amplitude of the
acceleration baseline which is 1 g). At a moment of 87-92th samples, the
acceleration is higher than the pre-deﬁned acceleration thresholds 2 g in
the fall detection algorithm. However, the fall case is not detected by the
system in this case because of two reasons. First, during 87-92th samples,
angular velocity is not higher than angular velocity thresholds in the fall
detection algorithm. Second, historical data shows that none of the sensors
is malfunctioned. Similarly, the case of angular velocity at 58-64th samples is
higher than angular velocity threshold but the fall event is not detected. ECG
during walking is not as good as ECG in other statuses such as standing and
lying in bed. However, P, Q, R, S and T waves appear in some of the ECG
cycles (i.e., at 140-150th samples). The value of QT’s length and QTcB’s
length varies dramatically. Therefore, it is not recommended to monitor
ECG during intensive activities such as running or jumping.
In some of the experiments, a user falls in some random moments. There
are 3 diﬀerent falling cases during walking such as fall forward, fall back and
fall aside. In this paper, fall cases during walking are focused because people
are more likely to fall during activities than in static cases such as lying in bed
and standing. In addition, when fall cases during activities (e.g., walking) can
be detected, fall cases in other static statuses (e.g., lying in bed and standing)
can be also successfully detected. Acceleration, angular velocity and ECG of
these fall cases during walking are shown in Figure 7. In most of the cases,
a person tends to sit up or stand up after falling. When he sits up or stands
up, the acceleration should increase to peak values. Correspondingly, two
peaks including a falling peak and a standing/sitting up peak (i.e., having
a higher amplitude compared to other peaks) are expected to appear in
both acceleration and angular velocity waveform. In all experimented cases,
these two peaks appear in the collected data. For example, two peaks of
acceleration and two peaks of angular velocity appear 58-65th samples and
110-115th samples in the fall forward case. The ﬁrst peak representing a fall
moment often has the highest amplitude while the amplitude of the second
peak varies depending on speciﬁc situations such as sitting up, standing up
or crawling up. Therefore, the second peak can be smaller or larger than
pre-deﬁned thresholds. A distance between two peaks varies depending on
diﬀerent situations. In case of fall aside, at a moment after falling, angular
velocity (at 125-1130th samples) does not change dramatically (i.e., reaching
to a peak value) while acceleration reaches to a peak value. The reason is
that a user slowly crawls and sits up after falling. It can be concluded that
during fall moments, ECG ﬂuctuates whilst ECG remains good during other
Table 2: Area of gateway zones in diﬀerent conﬁgurations in case of a single adjacent
BME280 X X X
Samples/minute 1 1 1
Glucose sensor X X X
Sample/minute(s) 1 1 1
MPU-9250 X X X
Sample/second(s) 50 50 50
AD8320 X X X X X
Sample/second(s) 60 120 60 120 120
Voltage (V) 3.3 3.3 3.3 3.3 3.3 3.3 3.3 3.3
Current (mA) 1.65 3.15 4.58 5.76 0.22 0.45 0.61 6.35
Figure 8: Power consumption of e-health sensor node (in diﬀerent conﬁgurations) with
1000 mAh battery
In the experiments, power consumption of an e-health sensor node in
diﬀerent conﬁgurations is measured. In each conﬁguration, a sensor or a
group of several sensors is integrated into a sensor node. Data collected from
the sensor(s) is transmitted to a gateway via nRF. Detailed information of
the conﬁgurations and results of power consumption are shown in Table 2
and Figure 8, respectively. In Table 2, the ﬁrst four conﬁgurations (i.e.,
from Conf 1 E to Conf 4 E) are the conﬁgurations of high data rate e-health
sensor nodes while the other three conﬁgurations (i.e., from Conf 5 E to Conf
7 E) are the conﬁgurations of low data rate e-health sensor nodes. The last
conﬁguration (i.e., Conf 8 E) is for the hybrid sensor nodes having low and
high data rate sensors. Results show that high date rate sensors (i.e., motion
sensor and ECG sensor) consume a large amount of energy while low data
rate sensors consume a small amount. By using 1000 mAh Lithium battery
(a size of 60 x 32 x7 mm), the low data rate sensor node (i.e., Conf 7 E) can
be used up to 1639 hours while the high data rate sensor node (i.e., Conf
4 E) can be used up to 173 hours. In case of the hybrid sensor node, it can
be used up to 157.5 hours with the same battery.
Contextual sensor nodes collect and send data in every second to a gate-
way. Conﬁgurations and power consumption of the sensor nodes are showed
in Table 3 and Figure 9. Results show that these sensors for collecting air-
related parameters (i.e., Mq2, MQ7, and MQ125) consume a large amount
of power. When applying the 10000 mAh battery having a size of 5 x 120 x
90 mm, contextual sensor nodes can operate up to 46 hours. As mentioned,
contextual sensor nodes are ﬁxed in a room. Therefore, it is recommended
that contextual sensor nodes should be supplied with wall-socket power. The
battery is only used for a case of electricity cut.
Table 3: Area of gateway zones in diﬀerent conﬁgurations in case of a single adjacent
Conﬁguration Conf 1 C Conf 2 C Conf 3 C Conf 4 C Conf 5 C
MQ2 X X
MQ7 X X
MQ135 X X
DHT22 X X
Voltage (V) 3.3 3.3 3.3 3.3 3.3
Current (mA) 84.3 66.1 73.6 1.68 216.5
Figure 9: Power consumption and working hours of contextual sensor nodes (in diﬀerent
conﬁgurations) with 10000 mAh battery
Figure 10: Power consumption and working hours of sensor nodes in diﬀerent conﬁgura-
tions with AES-256
Table 4: Area of gateway zones in diﬀerent conﬁgurations in case of a single adjacent
Device Algorithm Latency (µs)
Our sensor node AES-256 encryption 1358
Smart gateway AES-256 decryption 43
Smart gateway AES-256 encryption 52
Cloud server AES-256 decryption 10
In the experiments, sensor nodes in diﬀerent conﬁgurations are applied
with AES-256. Power consumption of the sensor nodes with and without is
shown in Figure 10. The results show that power consumption of the sensor
nodes increases slightly (i.e., about 11% of total power of the e-health hybrid
sensor node) when applying encrypting with AES-256. In this case, the
hybrid sensor node can operate up to 183 hours. In case of contextual nodes,
power consumption of the nodes increases less then 0.01%. The contextual
sensor nodes still operate up to 46 hours when they are supplied with the
10000 mAh battery.
Results of latency for encrypting and decryption with AES-256 shown in
Table 4 indicate that the latency of the sensor node increases slightly (i.e.,
about 1.358 ms). Correspondingly, the requirements of latency (e.g., less
than 500 ms for ECG and approximately in seconds for glucose) are still
Table 5: Area of gateway zones in diﬀerent conﬁgurations in case of a single adjacent
in  ATmega32L
256 8 Motion 5 Low
in  ATmega128L
128 4 Motion 3 Medium
in  MSP430F2617
92 8 Motion 3.7 Low
in  MSP430 (8) 48 10 Motion 3 Low
in  MSP430F1611
48 10 Motion 3.7 High
in  ATmega328P
32 2 Motion 3 Low
in  Arm Cortex
512 32 ECG 3.3 Ultralow
in  MSP430 (8) 48 10 ECG 3.3 Low (36
in  ATmega328
32 2 ECG 3.3 Low
in  MSP430 (8) 48 10 ECG 3.3 Medium
in  ATmega328P-
32 2 Motion,
32 2 Motion,
In this paper, power consumption of our sensor node is compared with
other state-of-the-art nodes. Results shown in Table 5 indicate that our
sensor node is one of the most energy-eﬃcient sensor nodes even though our
sensor node is equipped with many types of sensors for collecting motion-
related data, ECG, body temperature, and glucose.
In this paper, we presented a novel and smart Fog-based system for con-
tinuous, remote monitoring glucose, ECG and other signals in real-time.
The complete IoT system consisting of sensor nodes, smart gateways with
Fog computing and a back-end server was implemented. By simultaneous
monitoring diﬀerent types of signals from bio-signals (i.e., glucose, ECG,
and body temperature) to contextual signals (i.e., air quality, room humid-
ity and temperature), the accuracy of disease analysis was improved. By
leveraging smart gateways and Fog computing in the system, loads of sensor
nodes were alleviated whilst augmented services (e.g., local data storage, se-
curity, interoperability) were provided. In addition, we proposed algorithms
for calculating the duration of QT length, fall detection, and activity status
detection, respectively. These algorithms combining with the push notiﬁca-
tion service helped to improve quality of healthcare services. Results from
the experiments showed that the complete sensor node for gathering glu-
cose, ECG, motion-related signals and body temperature is one of the most
energy-eﬃcient sensor nodes and it can operate in a secured way up to 157.5
hours with a 1000 mAh Lithium battery.
The authors would like to thank Academy of Finland, Nokia Foundation,
University of Turku Graduate School (UTUGS), the doctoral programme
in mathematics and computer sciences (MATTI), Finnish Foundation for
Technology Promotion (TES), IoT4Health group for the ﬁnancial support
 R. T. Robinson et al. Mechanisms of abnormal cardiac repolarization
during insulin-induced hypoglycemia. Diabetes, 52(6):1469–1474, 2003.
 R. Vedanthan et al. Sudden cardiac death in low-and middle-income
countries. Global heart, 7(4):353–360, 2012.
 Atrial ﬁbrillation fact sheet.
Available: https://www.cdc.gov/dhdsp/data statistics
/fact sheets/fs atrial ﬁbrillation.htm [Accessed: May 2018].
 H. T. Nguyen et al. Detection of nocturnal hypoglycemic episodes
(natural occurrence) in children with type 1 diabetes using an optimal
bayesian neural network algorithm. In IEEE Engineering in Medicine
and Biology Society 2008, pages 1311–1314. IEEE, 2008.
 D. Pickham, E. Flowers, and B. J. Drew. Hyperglycemia is associated
with qtc prolongation and mortality in the acutely ill. The Journal of
cardiovascular nursing, 29(3):264, 2014.
 L. L. Nguyen, S. Su, and H. T. Nguyen. Eﬀects of hyperglycemia on
variability of rr, qt and corrected qt intervals in type 1 diabetic patients.
In IEEE Engineering in Medicine and Biology Society 2013, pages 1819–
1822. IEEE, 2013.
 K. D. Kochanek et al. Deaths: Final data for 2014. National Vital
Statistics Reports, 65(4), 2016.
 WHO. Diabetes. 2017.
Available: http://www.who.int/mediacentre/factsheets/fs312/en/ [Ac-
cessed: Jan 2018].
 Rates of new diagnosed cases of type 1 and type 2 diabetes on the rise
among children, teens.
cessed: May 2018].
 C. D. Mathers, and D. Loncar. Projections of global mortality and
burden of disease from 2002 to 2030. PLoS medicine, 3(11):e442, 2006.
 D. A. Sterling, J. A. O’connor, and J. Bonadies. Geriatric falls: injury
severity is high and disproportionate to mechanism. Journal of Trauma
and Acute Care Surgery, 50(1):116–119, 2001.
 J. A. Stevens et al. The costs of fatal and non-fatal falls among older
adults. Injury prevention, 12(5):290–295, 2006.
 CDC. Important facts about falls. 2017.
/adultfalls.html [Accessed: Jan 2018].
 S. Volpato et al. Risk factors for falls in older disabled women with dia-
betes: the women’s health and aging study. The Journals of Gerontology
Series A: Biological Sciences and Medical Sciences, 60(12):1539–1545,
 Cardiovascular Disease & Diabetes. Dec.2017.
Diabetes UCM 313865 Article.jsp/ [Accessed: Jan.2018].
 M. S. Kirkman et al. Diabetes in older adults. Diabetes care,
 N. Paul, T. Kohno, and D. C. Klonoﬀ. A review of the security of in-
sulin pump infusion systems. Journal of diabetes science and technology,
 T. N. Gia et al. Fog Computing in Healthcare Internet-of-Things A Case
Study on ECG Feature Extraction. IEEE International Conference on
Computer and Information Technology (CIT’15), pages 356–363, 2015.
 T. N. Gia et al. Fog computing in body sensor networks: An energy
eﬃcient approach. In Proc. IEEE Int. Body Sensor Netw. Conf.(BSN),
pages 1–7, 2015.
 A. M. Rahmani et al. Smart e-health gateway: Bringing intelligence
to internet-of-things based ubiquitous healthcare systems. In Consumer
Communications and Networking Conference (CCNC), 2015 12th An-
nual IEEE, pages 826–834. IEEE, 2015.
 T. N. Gia et al. Customizing 6lowpan networks towards internet-of-
things based ubiquitous healthcare systems. In NORCHIP, 2014, pages
1–6. IEEE, 2014.
 T. N. Gia et al. Fault tolerant and scalable IoT based architecture for
healthcare monitoring. Sensors Applications Symposium (SAS), pages
 I. Tcarenko et al. Energy-eﬃcient iot-enabled fall detection system with
messenger-based notiﬁcation. In International Conference on Wireless
Mobile Communication and Healthcare, pages 19–26. Springer, 2016.
 T. N. Gia et al. Iot-based fall detection system with energy eﬃcient
sensor nodes. In Nordic Circuits and Systems Conference (NORCAS),
2016 IEEE, pages 1–6. IEEE, 2016.
 A. J. Jara et al. An internet of things-based personal device for diabetes
therapy management in ambient assisted living (aal). Personal and
Ubiquitous Computing, 15(4):431–440, 2011.
 R. S. H. Istepanian et al. The potential of internet of m-health things
for non-invasive glucose level sensing. In Engineering in Medicine
and Biology Society, EMBC, 2011 Annual International Conference of
the IEEE, pages 5264–5266. IEEE, 2011.
 S. M. Moosavi et al. Sea: a secure and eﬃcient authentication and au-
thorization architecture for iot-based healthcare using smart gateways.
Procedia Computer Science, 52:452–459, 2015.
 S. M. Moosavi et al. Session resumption-based end-to-end security for
healthcare internet-of-things. In CIT 2015, pages 581–588. IEEE, 2015.
 T. N. Gia et al. Low-cost fog-assisted health-care iot system with energy-
eﬃcient sensor nodes. In Wireless Communications and Mobile Comput-
ing Conference (IWCMC), 2017 13th International, pages 1765–1770.
 T. N. Gia et al. Iot-based continuous glucose monitoring system: A
feasibility study. Procedia Computer Science, 109:327–334, 2017.
 A. M. Rahmani et al. Exploiting smart e-health gateways at the edge of
healthcare internet-of-things: A fog computing approach. Future Gen-
eration Computer Systems, 78:641–658, 2018.
 B. Negash et al. Leveraging fog computing for healthcare iot. In Fog
Computing in the Internet of Things, pages 145–169. Springer, 2018.
 H. Dubey et al. Fog data: Enhancing telehealth big data through fog
computing. In Proceedings of the ASE BigData & SocialInformatics
2015, page 14. ACM, 2015.
 Y. Cao et al. Distributed analytics and edge intelligence: Pervasive
health monitoring at the era of fog computing. In Proceedings of the
2015 Workshop on Mobile Big Data, pages 43–48. ACM, 2015.
 I. Azimi et al. Medical warning system based on internet of things
using fog computing. In Big Data and Information Security (IWBIS),
International Workshop on, pages 19–24. IEEE, 2016.
 Y. Cao et al. Fast: A fog computing assisted distributed analytics system
to monitor fall for stroke mitigation. In Networking, Architecture and
Storage (NAS), 2015 IEEE International Conference on, pages 2–11.
 R. Craciunescu et al. Implementation of fog computing for reliable
e-health applications. In Signals, Systems and Computers, 2015 49th
Asilomar Conference on, pages 459–463. IEEE, 2015.
 P. Davies, and I. Maconochie. The relationship between body temper-
ature, heart rate and respiratory rate in children. Emergency Medicine
Journal, 26(9):641–643, 2009.
 M. Jiang et al. Iot-based remote facial expression monitoring system
with semg signal. In Sensors Applications Symposium (SAS), 2016
IEEE, pages 1–6. IEEE, 2016.
 V. K. Sarker et al. Portable multipurpose bio-signal acquisition and
wireless streaming device for wearables. In Sensors Applications Sym-
posium (SAS), 2017 IEEE, pages 1–6. IEEE, 2017.
 2.4GHz RF - Ultra low power 2.4GHz RF ICs/solutions.
Available: https://www.nordicsemi.com/eng/Products/2.4GHzRF [Ac-
cessed: May 2018].
US/docs/Web/API/WebSocket [Accessed: May 2018].
 Introducing to json.
Available: https://www.json.org/ [Accessed: May 2018].
 K. W. Goh et al. A pda-based ecg beat detector for home cardiac
care. In IEEE-EMBS 2005. 27th Annual International Conference of
the Engineering in Medicine and Biology Society, 2005., pages 375–378.
 B. Vandenberk et al. Which qt correction formulae to use for qt moni-
toring? Journal of the American Heart Association, 5(6):e003264, 2016.
 H.C. Bazett. An analysis of the time-relations of electrocardiograms.
Annals of Noninvasive Electrocardiology, 2(2):177–194, 1997.
 L. S. Fridericia. Die systolendauer im elektrokardiogramm bei normalen
menschen und bei herzkranken. Journal of Internal Medicine, 53(1):469–
 A. Sagie et al. An improved method for adjusting the qt interval for heart
rate (the framingham heart study). American Journal of Cardiology,
 M. Hodges. Bazett’s qt correction reviewed: evidence that a linear qt
correction for heart rate is better. J Am Coll Cardiol, 1:694, 1983.
 P. M. Rautaharju et al. Assessment of prolonged qt and jt intervals
in ventricular conduction defects. American Journal of Cardiology,
 F. Miao et al. A wearable context-aware ecg monitoring system in-
tegrated with built-in kinematic sensors of the smartphone. Sensors,
 T. N. Gia et al. Energy eﬃcient wearable sensor node for iot-based fall
detection systems. Microprocessors and Microsystems, 56:34–46, 2018.
 D. C. Klonoﬀ. Cybersecurity for connected diabetes devices. Journal of
diabetes science and technology, 9(5):1143–1147, 2015.
 N.F. Pub. Advanced encryption standard (aes). Federal information
processing standards publication, 197(441):0311, 2001.
 S. M. Moosavi et al. End-to-end security scheme for mobility enabled
healthcare internet of things. Future Generation Computer Systems,
 O. Biros et al. Implementation of wearable sensors for fall detection
into smart household. In Applied Machine Intelligence and Informatics
(SAMI), 2014 IEEE 12th International Symposium on, pages 19–22.
 S. Z. Erdogan, and T. T. Bilgin. A data mining approach for fall detec-
tion by using k-nearest neighbour algorithm on wireless sensor network
data. IET Communications, 6(18):3281–3287, 2012.
 P. Pivato et al. A wearable wireless sensor node for body fall detection.
In Measurements and Networking Proceedings, 2011 IEEE International
Workshop on, pages 116–121. IEEE, 2011.
 Y. Li et al. Accelerometer-based fall detection sensor system for the
elderly. In Cloud Computing and Intelligent Systems (CCIS), 2012 IEEE
2nd International Conference on, volume 3, pages 1216–1220. IEEE,
 F. Wu et al. Development of a wearable-sensor-based fall detection
system. International journal of telemedicine and applications, 2015:11
 R. Dilmaghani et al. Wireless sensor networks for monitoring physi-
ological signals of multiple patients. IEEE transactions on biomedical
circuits and systems, 5(4):347–356, 2011.
 S. Mahmud et al. An inexpensive and ultra-low power sensor node for
wireless health monitoring system. In E-health Networking, Applica-
tion & Services, 2015 17th International Conference on, pages 495–500.
 S. Lee, and W. Chung. A robust wearable u-healthcare platform in
wireless sensor network. Journal of Communications and Networks,