Wireless Hybrid Bio-Sensing with Mobile based Monitoring

Wireless Hybrid Bio-Sensing with Mobile based Monitoring
Wireless Hybrid Bio-Sensing with
Mobile based Monitoring System
LINLIN XU
KTH Information and
Communication Technology
Master of Science Thesis
Stockholm, Sweden 2013
TRITA-ICT-EX-2013:240
Master Thesis Report
Wireless Hybrid Bio-Sensing with
Mobile based Monitoring System
Linlin Xu
School of Information and Communication Technology
Kungliga Tekniska Högskolan
STOCKHOLM, 2013
TRITA-ICT-EX-2013:240
Abstract
Personal telehealth plays a crucial role in addressing global challenges of aging population
and rising cost for health care. Tiny and wirelessly connected medical sensors, for example
embedded in clothes or on the body, will be an integrated part of lifestyle, and will allow
hospitals to remotely diagnose patients in their home.
In this thesis, a wireless bio-sensing with smart phone based monitoring system is proposed to
provide a home based telehealth care for continuous monitoring. The system consists of two
main parts: a wireless sensor and a health application on the smart phone. This thesis is to
design the first part of the system - a wireless temperature and electrocardiography (ECG)
sensor. The sensor integrates ECG front-end analog block, a micro-controller and a Bluetooth
low energy (BLE) connectivity IC on a single board. To achieve the miniaturization of the
sensor and users’ comfort in mind, the sensor is designed as a miniaturized hybrid system
utilizing flexible batteries and printed electrodes. This can efficiently detect ECG signals and
transfer them to a smart phone through BLE link.
Keywords
Cardiovascular disease, Electrocardiogram, Bluetooth low energy, SPI interface
I
Acknowledgement
It would be not possible for me to carry out the master thesis project without the excellent
support and help from the following people.
First of all, I would like to express my very great appreciation to my supervisors Fredrik
Jonsson and Lubomir Gradinarsky for their valuable and constructive suggestions and
guidance during the thesis project. I would also like to express my deep gratitude to Dr. Geng
Yang and Li Xie who are so helpful for my detailed understanding and investigation.
I am grateful to the assistance from Venkat and Raj, my team members. Special thanks are
extended to Göran Nordahl who provides equipments and useful tips for QFN soldering.
Finally, I wish to thank my husband and my parents for their encouragement and support
throughout my study.
II
Contents
Abstract ....................................................................................................................................... I
Keywords .................................................................................................................................... I
Acknowledgement ..................................................................................................................... II
Contents .................................................................................................................................... III
1.
2.
3.
Introduction ......................................................................................................................... 1
1.1
Background .................................................................................................................. 1
1.2
Related Work ............................................................................................................... 1
1.3
Problems Statement ..................................................................................................... 2
1.4
Goals ............................................................................................................................ 3
1.5
Purposes ....................................................................................................................... 4
1.6
Delimitation ................................................................................................................. 5
1.7
Outline ......................................................................................................................... 5
Basic Concepts of Wireless ECG Monitoring System........................................................ 6
2.1
ECG Signal .................................................................................................................. 6
2.2
Wireless ECG Monitoring System .............................................................................. 7
2.3
Electrodes .................................................................................................................... 8
Hardware Design .............................................................................................................. 10
3.1
ECG Frond-end Analog Block .................................................................................. 10
3.1.1 The Front-End Circuit Implementation ................................................................... 12
3.1.2 Bandwidth and Gain ................................................................................................ 13
3.2
Microcontroller .......................................................................................................... 14
3.3
Bluetooth Low Energy Connectivity IC .................................................................... 16
3.3.1 SPI Interface............................................................................................................. 17
3.4
Power management circuit ........................................................................................ 18
3.5
System Implementation ............................................................................................. 18
III
3.5.1 Flexible substrate ..................................................................................................... 20
4.
Software Design ................................................................................................................ 21
4.1
Software Architecture ................................................................................................ 22
4.2
Hardware Abstraction Layer ..................................................................................... 23
4.2.1 SPI Configuration .................................................................................................... 23
4.2.2 SPI Communication ................................................................................................. 23
4.2.3 SPI Packet Format .................................................................................................... 25
4.2.4 Bluetooth Protocols .................................................................................................. 25
4.3
Application Layer ...................................................................................................... 26
4.3.1
ECG Monitoring Algorithm ............................................................................... 26
4.3.2 Battery Level and Temperature Algorithm .............................................................. 29
4.4
Main Loop ................................................................................................................. 29
4.4.1 Initialization ............................................................................................................. 30
5.
Results ............................................................................................................................... 32
5.1
ECG waveform .......................................................................................................... 33
5.2
Data Lost Rate ........................................................................................................... 34
5.2.1 Data Lost Rate versus Sampling Rate ...................................................................... 34
5.2.2 Data Lost Rate versus Distance ............................................................................... 36
5.3
Power Consumption Measurement ............................................................................ 37
6.
Conclusion ........................................................................................................................ 39
7.
Future Work ...................................................................................................................... 41
Reference .................................................................................................................................. 42
List of Tables ............................................................................................................................ 45
List of Figure ............................................................................................................................ 46
Appendix A .............................................................................................................................. 47
Schematics ................................................................................................................................ 47
Appendix B .............................................................................................................................. 48
IV
B.1 PCB Layout on Top Layer ................................................................................................. 48
B.2 PCB Layout on Bottom Layer ........................................................................................... 49
Appendix C Source Code ......................................................................................................... 50
C.1 Main Loop (ECG.ino)........................................................................................................ 50
C.2 Hardware Abstraction Layer Code (hal_aci_tl.cpp) .......................................................... 51
C.3 Application Layer Code (my_application.cpp) ................................................................. 55
C.3.1 State Transition between Four Modes ............................................................................ 55
C.3.2 Handle the Smart Phone Command................................................................................ 57
C.3.3 ECG Monitoring ............................................................................................................. 58
C.3.4 Battery Level Monitoring ............................................................................................... 61
C.3.5 Temperature Monitoring................................................................................................. 62
V
1. Introduction
1.1 Background
Nowadays, cardiovascular disease or heart disease is one of the leading causes of death
globally. 17.3 million people died from cardiovascular diseases in 2008, accounting for 30
percent of all global deaths [1]. According to World Health Organization (WHO) report, the
number of people who die from cardiovascular disease, mainly from heart disease and stroke,
will annually go up to 23.3 million by 2030 [2].
Cardiovascular disease is a group of diseases that affect cardiovascular system, including
heart and blood vessels. Heart attack and stroke are two of the most common cardiovascular
diseases. They are mainly caused by a narrowing or blockage of arteries that prevents blood
from flowing to the heart. The common symptoms of heart attack and strokes include pain
and discomfort in the center of chest, arms or left shoulders, and difficulty in breathing [3].
Unhealthy diet, lack of physical activities, tobacco use and excessive alcohol consumption are
the major risk factors to heart diseases.
Electrocardiogram (ECG or EKG) test is one of the most widely used health monitoring
methods for cardiovascular disease diagnosis. It is a painless noninvasive medical test that
measures the heart’s electrical activities as the heart contracts. The conventional clinic ECG
test is performed by a technician who places electrodes on the surface of human body at
certain places, usually on chest, arms and legs. These electrodes are connected to the ECG
machine through wires or cables. The ECG machine is capable of detecting and amplifying
tiny heart electrical impulse, and displaying this data on to a paper or a computer. Then the
ECG data can be interpreted by a health specialist. Heart disorders and irregularities can
change the characteristic shape of the ECG. The heart diseases that can be diagnosed by ECG
includes: heart attack (myocardial infarction), abnormal rhythm (arrhythmia) and enlargement
of the heart.
1.2 Related Work
ECG test can be performed by various methods and systems, such as clinic ECG machine,
Holter monitor or wireless ECG monitoring system.
1
The clinic ECG test is performed at traditional institutional settings, such as the hospital or
clinic. Most of clinic ECG machines are large and heavy. For example, Burdick Atria 6100
has a size of 14.0 cm x 33.4 cm x 38.1 cm, and has a weight of 5 kg. In addition, the standard
clinic ECG test employs 12 electrodes which connect to the machine by long cables. The
cumbersome device and the multitude of cables reduce the mobility and flexibility of patients.
Therefore, the clinic ECG test is used for short-term monitoring. So it is difficult to provide
an accurate diagnosis for transient arrhythmia [4].
The alternative to clinic ECG is the Holter monitor which promises a long-term monitoring.
The Holter monitor is a portable device that can provide a continuous recording for 24 hours.
It can be used at home or ambulances to detect heart arrhythmias that are hard to find in the
regular clinic test. However, after 24-hours monitoring, patients must take the monitor back to
the hospital, download the records into the Holter analyzer, and receive the diagnosis from the
doctors.
During recent years several wireless ECG monitoring systems have been proposed [4][5][6][7]
and [8]. The use of wireless technology enables the transmission of ECG from the patient
home to the remote health professional’s computer. It avoids frequently visits to the health
professional’s office and reduces hospitalization. The wireless system can benefit patients by
providing a real-time personal home based telehealth care without disturbing their daily
activities. Zigbee, ANT and Bluetooth are three wireless transmission technologies which are
commonly used in the wireless ECG monitoring systems.
Continua Alliance is non-profit, open industry organization of healthcare and technology
companies join together in collaboration to improve the quality of personal healthcare [9].
The Alliance is responsible for establishing an ecosystem of interoperable healthcare products
and services in order to help people to efficiently manage their health and reduce the
healthcare cost. So it enables the shift of healthcare from the traditional health institutions to
person home. The Continua Alliance issues design guidelines on how to use connectivity
standards and specification to build interoperable health products.
1.3 Problems Statement
The clinic ECG machine is large and heavy, and the Holter monitor can only record for 24
hours. They are not suitable for long-term monitoring. There are various wireless
2
communication protocols for the wireless ECG monitoring system which must be
interoperable with other information sources. What kind of interoperable system can provide
real-time long-term heart monitoring and bring the most convenient and low-cost telehealth
care application to users?
1.4 Goals
To tackle the above problems, a new wireless bio-sensing with smart phone based system is
proposed in this thesis to provide personal home based telehealth care solution. Several key
features are targeted: 1) miniaturization, 2) flexible substrate, 3) low power consumption and
4) Bluetooth low energy based wireless link.
Miniaturization is the development trend of the ECG system. The wireless ECG systems
proposed in [5] [7] and [8] contain several printed circuit boards. In these systems, one board
senses the ECG signal, while the other boards are responsible for wireless transmission of the
signal. But in our designed system, all the components would be integrated on to one single
board. The board aims to have a small size and light weight so that the health device can be
easily worn.
The miniaturized board would be mounted on the flexible substrate which comprises of
flexible batteries and printed electrodes. The use of the flexible substrate offers a number of
substantial advantages. First of all, the flexible capability of this substrate makes the ECG
device to be comfortably wearable. Secondly, soft and thin batteries which are integrated on
the substrate can save the space of the ECG device as well as provide power to the PCB board.
Thirdly, it increases patient mobility by printing short wires on the flexible substrate instead
of the long cables which connect electrodes to the ECG device.
In order to enable long-term monitoring, the system is aimed to consume low power. The low
power consumption feature promises the ECG system that can run for months or years on
flexible batteries. Therefore, all the components, especially the wireless transceiver, would be
selected to have the low power consumption feature.
Bluetooth low energy (Bluetooth LE) technology branded as Bluetooth Smart is adopted to
provide low-power short-range wireless transmission. Bluetooth v4.0 is the most recent
version of Bluetooth wireless technology which introduced low energy technology to
Bluetooth Core Specification, enabling new Bluetooth Smart device that can operate months
3
or even years on tiny, coin cell batteries [11]. Compared to classic Bluetooth, Zigbee and
ANT+, Bluetooth LE technology provides lower average and idle power consumption and
reduced cost. Furthermore, the Continua 2012 Design Guideline [10] defines the interface to
Personal Area Network (PAN-IF) health devices for Bluetooth LE which include
Thermometer, Heart Rate Monitor and Blood Pressure Monitor. The thesis is expected to add
Basic 1-3 Lead ECG to the device class for the low-power wireless PAN (Bluetooth Low
Energy).
In addition, the designed ECG system is intended to transmit the ECG signal via Bluetooth
wireless link to a smart phone instead of a computer or a database. The smart phone often acts
as a handheld computer rather than a phone nowadays. Its powerful on-board computer
capability and capacious memories [7] permit people to be instantly aware of their health
status by viewing the real-time ECG signal on the large screen of the smart phone. The use of
this small portable smart phone can allow the wireless ECG system to create more
convenience to patients compared to a computer or a database. In 2011 Apple released the
first Bluetooth Smart Ready device (iPhone 4S) which supports Bluetooth v4.0 specification.
The next version of Android operating system will natively support Bluetooth Smart Ready
technology [12].
This thesis only focus on the design of the wireless ECG monitoring device, while the
healthcare mobile application which is used to receive and display the ECG signal is
developed by two other master students in this project.
1.5 Purposes
The purpose of the thesis is to provide personal home telehealth system. The designed system
can benefit patients with chronic heart diseases by improving the convenience and quality of
the ECG device and lowering the cost of the device. The system can help people to better
manage their health and improve the quality of their life. Moreover, it aims to make the
designed system interoperable. The system can have the ability to transmit the acquired ECG
signal via the Bluetooth link to any smart phone which supports the Bluetooth low energy
technology.
In addition, the thesis work can be beneficial to the pharmaceutical companies. Before a new
heart medicine is released to the market, it is required to undergo clinical trials to ensure the
4
safety of the usage. The collection of biomedical data under clinic trials can be made much
easier by using the proposed miniaturized system. Moreover, the system can be used to
analyze the condition of patients receiving certain heart medication and check how regularly
the patient takes the medicine.
1.6 Delimitation
This thesis is still under the development stage and the system prototype has been fabricated.
Only some important performances of the prototype, such as the quality of ECG signal, data
lost rate, power consumption and the device size, have been measured. A further delimitation
is that the tests were only conducted on the iPod Touch and a healthy subject. Hence, the
results are constrained by the testing environment. To put this health device into the market,
there is still a lot of work that should be done.
1.7 Outline
The thesis is organized in the following way.
Chapter 1 states problems which exist in the ECG systems and provides solutions on how to
design a wireless ECG monitoring system.
Chapter 2 gives an overview of the architecture of a wireless ECG measurement system. The
basic concepts of ECG signal as well as electrodes are also introduced.
Chapter 3 presents the hardware design for a wireless ECG system. The functionalities and
performance of three different modules, including a front-end analog amplifier (AD8232), a
microcontroller (ATmega328P) and a Bluetooth low energy connectivity IC, are explained
and described in detail.
Chapter 4 shows the software design in different layers: register layer, hardware abstraction
layer and application layer. The flow control and Bluetooth protocols are mainly presented in
this chapter.
Chapter 5 gives the results of the in-vivo tests. The performance of the designed ECG system
is measured and analyzed, such as data lost rate and distance.
Chapter 6 and 7 concludes the thesis and presents the future works respectively.
5
2. Basic Concepts of Wireless ECG Monitoring System
This chapter serves to provide an overview of existing knowledge on ECG and wireless ECG
monitoring systems which is necessary for the construction of our wireless ECG monitoring
system.
2.1 ECG Signal
The ECG output is a graphical representation of electrical activity of the heart recorded from
electrodes on the body surface. It records an electrical potential difference between two
prescribed sites on the body surface that vary during the cardiac cycle [13]. The graphing of
an ECG can assist in observing and diagnosing irregularities of heart beat, heart rate and heart
rhythm.
Figure 2-1 ECG waveform
A normal ECG signal, shown in Figure 2-1, consists of a P wave, a QRS complex, and a T
wave [14]. The P wave represents the atria depolarization, while the QRS complex and the T
wave are explained by the depolarization and repolarization of the ventricular muscle
respectively. An RR interval which is the time interval between two consecutive QRS
complexes, is used to measure heart rate or heart beat. The normal heart beat is between 60
and 100 bpm (beats per minute) [15]. A flat horizontal line between a T wave and the next P
wave is called the baseline of the electrocardiography. In the unhealthy heart, the baseline
may be elevated or depressed.
6
The ECG signal has two essential features: small QRS amplitude and low frequency range.
QRS amplitude is quite variable from person to person [15], and is from 0.5mV to 5 mV [15]
and [16]. The fundamental frequency for ECG ranges from DC level to several kilo Hertz.
2.2 Wireless ECG Monitoring System
A wireless ECG monitoring system is capable to acquire ECG signal from patients, amplify
and process the signal, and transmit the signal via wireless link to a smart phone. Figure 2-2
shows a block diagram of the wireless ECG monitoring system, which is summarized from [5]
[6] [8] [15] [17] [18] [19] [20] and [21]. The system consists of five major parts: signal
acquisition, amplification, signal processing, analog-to-digital conversion and wireless
transmission.
Figure 2-2 Block diagram of the wireless ECG monitoring system
Firstly, a single-channel ECG signal is acquired from two of electrodes (right arm and left
arm) placed on the chest, whereas the third electrode is positioned far from them as a ground
or a right leg drive (RLD) electrode to reduce noise.
Next, differential amplification is necessary and essential since the acquired signal from the
body is extremely weak. This stage is accomplished by an instrumentation amplifier with high
gain, high CMRR (common mode rejection ratio) and low noise. If the gain of the
instrumentation amplifier is not enough large, another operational amplifier is required. High
CMRR can reject common mode noise.
Then, signal processing sets a bandwidth for ECG signal, and eliminates noise that can
corrupt the signal. Noises mainly come from [13] [15] and [16]:

Motion artifact

Respiration
7

50/60 Hz power line interference

Radiated electromagnetic interference

Muscle contraction
Signal processing stage is formed by a series of filters. The low-pass filter can remove
unwanted high-frequency components that result from muscle contraction or electromagnetic
interference, whereas the high pass filter can reduce the low frequency noise produced by
motion artifacts or respiration. Furthermore, the notch filter is used to suppress the power line
interference at 50 or 60 Hz.
Finally, the processed analog signal is digitized with an ADC converter, and then transmitted
via a wireless radio (Bluetooth low energy) to a nearby smart phone. On the smart phone side,
this signal is received and displayed on the screen by a healthcare app which can also store the
data for further diagnosis by a cardiovascular professional.
2.3 Electrodes
Electrodes can work with an ECG machine to acquire and measure the electric potential on
the skin. It comes in a few different varieties, such as contact or non-contact, wet or dry. Two
types of electrodes were used in the thesis: commercial electrode (wet) and printed electrode
(dry).
Figure 2-3 Ag/AgCl Electrodes
The standard commercial electrode is made of Ag/AgCl, shown in Figure 2-3, which consists
of a metal pad coated with electrolytic gel to form a conductive interface between the skin and
electrode. This type of electrode is commonly used at clinic and hospital. Although this wet
electrode provides good signal quality [5], this wet electrode exhibits several disadvantages. 1)
Electrical conductivity could be lost when the gel becomes dry. 2) It is uncomfortable for
long-term wearing and may cause skin irritation and skin allergic reaction. Hence, it is
8
unsuitable for long-term ECG monitoring. This commercial electrode was only used in the
tests to measure performance of the designed system.
To overcome the shortages of commercial electrode, printed electrode is adopted by this
system which is integrated into the flexible substrate. It can be manufactured by printing and
patterning metal ink on the paper substrate or the plastic substrate. This dry electrode can
minimize allergic reaction caused by conductive gel of the wet electrodes. Furthermore, it can
also provide continuous electrical conductivity for prolonged use. Hence, the use of the
printed electrode fits for long-term ECG monitoring.
9
3. Hardware Design
This chapter presents the hardware design of the proposed wireless ECG monitoring system.
The system consists of two parts: 1) a printed circuit board which is capable to sense ECG
signal and transmit the signal via BLE and 2) a single-layer flexible substrate which integrates
flexible batteries and printed electrodes.
The design of PCB board adopts the architecture of the wireless ECG monitoring system
present in Figure 2-2. The board comprises of four important components: ECG front-end
analog block AD8232, ATmega328P microcontroller, Bluetooth low energy connectivity IC
nRF8001 and power management circuit (MIC5025). These components are demonstrated in
the following sections respectively.
3.1 ECG Frond-end Analog Block
The amplification and signal filtering are accomplished by a front-end analog block - AD8232
(from Analog Device). The reason to choose AD8232 includes that it has smaller package size
of 4mmx4mm and lower current consumption with a typical value of 170 uA, compared to
other components in the market. Furthermore, AD8232 configures high-pass and low-pass
filters.
AD8232 is a single-lead (one channel) integrated signal conditioning block for ECG or other
biopotential measurement applications [22]. It integrates the following functional blocks,
shown in Figure 3-1.

instrumentation amplifier (IA)

operational amplifier (A1)

right leg drive amplifier (A2)

midsupply reference buffer (A3)

leads off detection circuitry

an automatic fast restore circuit (s1, s2 and 10k resistors)
10
Figure 3-1 Block diagram of AD8232 [22]
Right arm and left arm electrodes are connected to the inputs (+IN and -IN) of the
instrumentation amplifier which is configured by a high gain of 100 and a high CMRR of 80
db. The operational amplifier contributes to an extra gain.
To improve common mode rejection, the right leg drive amplifier drives an inverted version
of the common mode signal at the instrumentation amplifier inputs into the user or patient
through the reference electrode. It can counteract common mode voltage variation [22].
The midsupply reference buffer output can provide a virtual ground level at mid-supply to the
instrumentation amplifier and the operational amplifier. The amplified ECG signal at the
output of AD8232 is referenced around this mid-supply voltage.
AD8232 features DC and AC leads-off detection modes. Our system employs DC leads-off
detection since the AD8232 datasheet [22] recommends the usage of DC leads-off detection
in the three-electrode configuration. In this mode, AD8232 indicates which electrode (+IN or
-IN) is disconnected from the skin by setting the corresponding LOD+ pin or LOD- pin high.
11
The fast-restore circuit reduces the duration of settling tails of the high-pass filters [22]. The
high-pass filter application is presented in the section 3.1.2.
3.1.1 The Front-End Circuit Implementation
Figure 3-2 Front-end analog circuit
The Figure 3-2 shows the schematic of the front-end circuit of the wireless bio-sensing system.
The five pins OUT, REFOUT, LOD+, LOD- and SDN are connected to a microcontroller.
The amplified ECG signal at the OUT pin is sent to an ADC embedded in the microcontroller.
The resistors R10, R11 and R2 are placed between the input pins (IN+, IN- and RLD) to
electrodes to limit current injection to the subject. Isolation from the power line can protect
the measured subject from the fault conditions.
Two 10MΩ resistors R8 and R9 form a voltage divider to set a mid-supply voltage level at the
REFIN pin. C7 in parallel with the lower resistor R9 is used for filtering noise and stability.
The REFOUT pin is the output of the reference buffer which provides the mid-supply
reference voltage.
12
Pull up resistors R12 and R13 are required to be connected to the supply in the DC leads-off
detection mode. In addition, in order to save power, the microcontroller place AD8232 in the
shutdown mode by setting the SDN pin low.
The rest of the cirrcuit is low-pass and high-pass filters which are demonstrated in the next
section.
3.1.2 Bandwidth and Gain
In addition to differentially amplify the acquired ECG signal, the front-end analog circuit can
implement low-pass and high-pass filters. These filters are designed by using the AD8232
filter design tool. The Figure 3-3 shows the high-pass and low-pass filter application.
Figure 3-3 High-pass filter and low-pass filter [23]
The resistors and capacitors (R1, R3, C1 and C3) create simple AC coupling high-pass filters
which are added at the output (IAOUT) of the instrumentation amplifier. The cutoff frequency
of the high-pass filter is set as 0.34 Hz in Equation 3.1, in order to eliminate noise caused by
motion artifact and electrode half-cell potential (DC offset rejection) [22].
(3.1)
The operational amplifier with R3, R4, R5, R6, R7, C3, C4 and C5 constructs a Sallen-Key
low-pass filter. The low-pass cutoff frequency, gain and Q can be calculated by using the
following equations [22].
(3.2)
13
(3.3)
(3.4)
The operational amplifier with the low-pass filter is configured to achieve a gain of 11 V/V
and a cutoff frequency of 35.24 Hz. The use of this low-pass filter is to filter unwanted highfrequency signals as well as remove the 50 Hz power line noise. Hence, there is no need to
have a notch filter in our system. The system size can be further minimized. In addition, the Q
value is configured to 1.027 to acquire maximum flatness and sharp cutoff.
Figure 3-4 Frequency response of the front end analog circuit
In conclusion, this ECG system has a total gain of 1100 (60 dB), and the frequency
components of the processed ECG signal is in the range of 0.34 Hz to 35.24 Hz.
3.2 Microcontroller
Since the first stage of the thesis work - the software development of the Bluetooth low
energy connectivity IC is implemented on the Arduino Nano board which has an Atmel
microcontroller, ATmega328P is selected as the microcontroller of this system. In addition,
this microcontroller can fulfill the requirements of miniaturization and low-power
consumption. ATmega328P has a small 5mmx5mm QFN32 package. In the active mode, the
power consumption is 0.2 mA at 1MHz and 1.8V, while it consumes only 0.1 uA in the
power-down mode [24].
14
ATmega328P is a low-power Atmel 8-bit AVR based microcontroller based on the AVR
enhanced RISC architecture [24]. It features a 32 Kbytes of Flash, 1 Kbytes EEPROM, 2
Kbytes RAM and 32 general purpose I/O pins.
Figure 3-5 ATmega328P microcontroller
ATmega328P runs at 3.3 V and 16 MHz. Decoupling capacitors (CM2, CM3 and CM4) and a
ferrite beat (L5) are placed nearby the supply pins for shunting noise from other components.
A 16 MHz resonator with 9 pF built-in capacitors offers an external clock to the
microcontroller. Moreover, the push button is connected to the reset pin to provide an external
hand reset.
Further, there are three interfaces for ATmega328P:

Interface to ECG front-end analog block (OUT, REFOUT, SDN, LOD+ and LOD-)

SPI interface to communicate with a Bluetooth module

Serial interface (TX1 and RX0) to a computer
A built-in analog-to-digital converter (ADC) of Atmega328P is connected to the analog
output pin OUT of ECG front-end block (AD8232) to sample and digitize the measured ECG
signal. The ADC has a 10-bit resolution and an input voltage range from 0 V to the supply
voltage. Hence, the LSB (Least Significant Bit) represents a voltage of 3.22 mV
15
(3.3/2^10=0.00322). After ADC conversion, the digital ECG signal is sent to the Bluetooth
low energy radio through the Serial Peripheral Interface (SPI).
On the other hand, ATmega328P can communicate with a PC through the serial transmit (TX)
and receive (RX) pins. The serial interface serves to upload and debug the program.
3.3 Bluetooth Low Energy Connectivity IC
For wireless data transmission, Bluetooth low energy connectivity IC - nRF8001 is employed
in the system. nRF8001 integrates a Bluetooth version 4.0 low energy radio with peak
currents as low as 12.5 mA and average currents down to 9 µA (for a 1s connection interval).
It features a 5mmx5mm QFN32 package which can totally satisfy miniaturization requirement.
Furthermore, nRF8001 involves a temperature sensor and a battery level monitor. In addition
to ECG monitoring, the designed system is also capable to sense temperature and battery level.
Figure 3-6 nRF8001 circuit
16
The wireless circuit of the ECG monitoring system, shown in Figure 3-6, contains the
following external components that are required for nRF8001.

16 MHz crystal oscillator (X1): provides reference clock to the RF transceiver [25]

32.768 KHz crystal oscillator (X2): provides the protocol timing [25]

Two inductors (LN4 and LN5) and a decoupling resistor (CN7): enable the DC/DC
converter embedded in nRF8001 that reduce peak current drawn from the supply.
DC/DC converter steps down the supply voltage to a lower voltage which is then fed
to the input of the internal linear regulator of nRF8001.

Balun (LN1 and LN3): converts a balanced RF signal at ANT1 and ANT2 pins to the
antenna. The RF choke (LN2) forms a DC path from ANT1 and ANT2 pins to the
VCC_PA pin.

Antenna matching network (CN5, CN6 and CN15)
In addition, this ECG monitoring system employs a PCB trace antenna which references the
antenna layout in the nRF2740 development kit board.
3.3.1 SPI Interface
As the nRF8001 plays a slave role for saving power, it requires that a microcontroller can
control and communicate with nRF8001 through a serial peripheral interface (SPI). However,
nRF8001 does not behave as a pure slave-mode transceiver [25]. It can also receive data over
the air.
Figure 3-7 SPI interface
The physical SPI interface consists of five pins: REQN, RDYN, SCK, MOSI and MISO. Two
active low handshake signals: REQN (request signal) and RDYN (ready signal) are used for
initializing the data transfer. The data exchange on the MOSI or MISO is triggered by the
17
sample clock SCK. Bluetooth protocol is performed on SPI interface, which will be described
in the next chapter.
3.4 Power management circuit
All the components operate at an internal 3.3 V supply voltage. The flexible batteries provide
a voltage of 4.5 V, so the low dropout regulator MIC5205 is employed in order to transform
the battery voltage to the internal 3.3V power supply voltage. Furthermore, the use of
MIC5205 can prevent the internal supply voltage from exceeding the maximum voltage rating
of components.
The 10 uF tantalum capacitor CP2 at the output of MIC5205 can avoid oscillation, while the
use of the 0.1 uF capacitor CP3 keeps output steady. The blue LED works as a power
indicator.
Figure 3-8 Power management circuit
3.5 System Implementation
This wireless ECG monitoring system is implemented by a standard 2-layer FR4 PCB board
(1.6 mm thickness). The schematic and layout of the PCB board are developed by using the
Eagle tool, shown in the appendix A.
18
(a) Top View
(b) Bottom View
(c) Side View
Figure 3-9 PCB Prototype
The PCB prototype board has a small size of 40mmx30mmx5mm. Components are
distributed on the top and bottom of the board. The microcontroller and the Bluetooth module
are placed on the top layer, while the ECG front-end analog circuit and power management
circuit are mounted on the bottom layer. The PCB trace antenna is on the left side and on the
top layer of the board. There is no ground plane under the antenna.
The six-pin header provides the communication interface between the board and a computer.
The program can be uploaded into the microcontroller by connecting a 3.3 FTDI cable from
the computer to this header. Moreover, the one-pin header connects to the output of AD8232.
It serves to measure ECG analog signal detected by AD8232. In addition, five 10mmx5mm
pads are responsible for providing the interface to the batteries and three electrodes.
The problem of this prototype is the absence of the ICSP header for burning bootloader. This
header will be added into the next version of the PCB board. In addition, a FFC/FPC
connector will replace five pads in order to connect the board to the batteries and electrodes
on the flexible substrate.
19
3.5.1 Flexible substrate
Since the flexible substrate is being manufactured when the thesis has been written, the
section only gives a prototype of the proposed flexible substrate. Figure 3-10 illustrates the
layout of the flexible substrate prototype which is designed by Fredrik Jonsson. The flexible
substrate is a plastic foil which integrates three serial Enfucell batteries and printed electrodes.
The Enfucell battery is a thin, flexible and soft battery. It can provide a voltage of 4.5 V to
supply the print circuit board, but also can save the space of the ECG device. Its drawback is
that high battery internal resistance (50 Ω) makes the battery output voltage drop. So the large
capacitor CP1 described in Figure 3-8 is mounted at the input of the voltage regulator to
tackle this problem.
Three electrodes are printed on the flexible substrate by using the Dry Phase Patterning (DPP)
technology. The electrode in the middle is the right leg drive electrode. Long cables which
connect the electrodes to the ECG device are replaced by short wires which are printed on the
flexible substrate. The printed wire traces can reduce noise which is introduced by the motion
of long cables.
Figure 3-10 Layout of the flexible substrate prototype
20
4. Software Design
In the software application, the system is capable of ECG monitoring as well as temperature
and battery level monitoring. This software application is developed on the Arduino
Integrated Development Environment (IDE). The reason for choosing Arduino is that it is an
open-source electronics prototyping platform based on flexible, easy-to-use hardware and
software [26]. In addition, the Arduino board consists of an Atmel microcontroller which is
the same microcontroller used in our system. Furthermore, the Arduino IDE includes a text
editor which is capable of editing, compiling and uploading the program to ATmega328P
microcontroller.
Figure 4-1 Arduino Development Environment [26]
The application development was divided into two stages. Because nRF8001 code provided
by Nordic Semiconductor is based on nRF8200 microcontroller, the port of Bluetooth
protocols to ATmega328P microcontroller was done firstly on two evaluation boards:
Arduino Nano and nRF2740 development kit, shown in Figure 4-2(a). Secondly, the ADC
algorithm for sampling and quantizing ECG analog signal was developed and implemented on
the prototype board, shown in Figure 4-2(b).
21
(a) Evaluation boards
(b) PCB prototype board
Figure 4-2 Software development platforms
4.1 Software Architecture
The ECG monitoring application consists of three layers: physical register layer, hardware
abstraction layer and application layer. Figure 4-3 shows the software architecture.
Application layer
Hardware Abstraction layer
Physical Register layer
Figure 4-3 Architecture of ECG monitoring application
The physical register layer module handles the operation of ATmega328P registers. Since the
Arduino IDE contains a software library called “Wiring” which defines the operations of
common input and output pins of ATmega328P microcontroller, there is no need to write
code on this layer. This is one reason for choosing Arduino which can reduce the
development time.
On the other hand, the Hardware Abstraction Layer (HAL) module defines SPI
communication between ATmega328P and nRF8001, which is present in the section 4.2. The
application layer module defines Bluetooth low energy protocols and ADC algorithm for
ECG, temperature and battery monitoring, which is present in the section 4.3.
22
4.2 Hardware Abstraction Layer
The port of Bluetooth protocol to ATmega328P microcontroller is performed on the
Hardware Abstraction Layer (HAL). The HAL layer module primarily defines logical
operations on how ATmega328P controls nRF8001 over the physical SPI interface. The HAL
code is written in the file hal_aci_tl.c described in Appendix C.2. It is responsible for the
following operations.

SPI configuration (hal_aci_tl_init function)

Sending commands (hal_aci_tl_send function)

Receiving events (hal_tl_poll_rdy_line function)
4.2.1 SPI Configuration
According to nRF8001 product specification [25], the SPI mode 0 is required to configure the
data exchange over the SPI interface. In the mode 0, the Least Significant Bit (LSB) is sent
first (for data order), the base value for clock is set as zero (for clock polarity) and the data is
read on the clock’s rising edge (for clock phase). The SPI operation is executed at a frequency
of 2 MHz.
4.2.2 SPI Communication
The data exchange between ATmega328P and nRF8001 is split into two types: command and
event. Command is a data exchange which is initiated by ATmega328P microcontroller and
transmitted to nRF8001, while event is a data exchange in the opposite direction.
Figure 4-4 Sending a command over SPI interface [25]
Figure 4-4 illustrates the process of sending a command from ATmega328P to nRF8001.
Firstly, ATmega328P sends a request of sending a command to nRF8001 by setting REQN
23
low. Next, nRF8001 responses the microcontroller by setting RDYN low when it is ready to
receive the command. Then ATmega328P starts to transmit this command over the MOSI pin.
On the other hand, the event is initialized by nRF8001 setting RDYN low. Then
ATmega328P informs nRF8001 that it is ready to receive events by setting REQN low. The
event is exchanged over the MISO pin.
Sending commands and receiving events are implemented by two important functions:
hal_aci_tl_send() and hal_aci_tl_poll_rdy_line(). The flow charts of these functions are
shown in Figure 4-5.
start
start
set REQN low
Is RDYN
No
low?
store a command into
data_to_send buffer
Yes
send the command
stored in data_to_send
buffer over MOSI
end
receive an event from
MISO
set REQN high
handle events
end
(a) hal_aci_tl_send () function
(b) hal_aci_tl_poll_rdy_line() function
Figure 4-5 Flow chart of SPI communication
Whenever ATmega328P microcontroller triggers a command, the hal_aci_tl_send function
would be called. This function sets REQN low and stores the command into the data_to_send
buffer. On the other hand, the hal_aci_tl_poll_rdy_line function is continuously called in the
main loop to monitor the RDYN signal. If the RDYN signal becomes low, the microcontroller
24
can send the command stored in the data_to_send buffer to nRF8001, or receive and handle
the event sent by nRF8001.
4.2.3 SPI Packet Format
Commands and events are organized in packets. Every packet consists of a two-byte header
followed by a variable length packet payload [25], described in Figure 4-6. The first byte of a
packet header represents the total length of this packet in bytes, and the second byte defines
the unique operation code for a specific command or event. The length of a payload is
command or event dependent. The least significant bytes in the text data of a command or an
event is transmitted first.
Figure 4-6 SPI packet format [25]
4.2.4 Bluetooth Protocols
Table 4-1 summarizes commands and the corresponding events in different modes which are
mainly used in the program. These commands and events are provided by nRF8001 SDK. The
first five commands are system commands for transferring operation modes described in the
section 4.3, while the sixth and seventh commands are used to get the internal temperature
and battery level from nRF8001. The data command lib_aci_send_data is responsible for
transmitting data via a Bluetooth link.
Table 4-1 nRF8001 commands and events [25]
Mode
Commands
Events
setup
lib_aci_setup
lib_aci_cmd_response_hook
standby
lib_aci_connect
lib_aci_connected_hook
standby & active
lib_aci_disconnect
lib_aci_disconnected_hook
standby
lib_aci_sleep
sleep
lib_aci_wakeup
active
lib_aci_get_temperature
lib_aci_cmd_response_hook
active
lib_aci_get_battery_level
lib_aci_cmd_response_hook
active
lib_aci_send_data
lib_aci_credit_hook
active
lib_aci_rcvd_hook
25
4.3 Application Layer
The application layer module defines ECG, battery level and temperature monitoring. The
system operates in four modes: setup, standby, active and sleep. The Figure 4-7 shows the
state transition between four operational modes. A mode is represented by a variable
app_state, and the transition is executed by the on_process_app function.
Figure 4-7 State transitions between four operational modes
When the power is on, the system is in the setup mode. After initialization, it is transferred to
the standby mode. Then, the Bluetooth low energy radio starts advertising and makes a
connection with a smart phone. Once it successfully establishes connection, the system enters
the active mode. In the active mode, a smart phone is able to control the ECG device by
sending a remote command. According to the received remote command from a smart phone,
the device starts to sense ECG signal, battery level or temperature and transmit them via the
Bluetooth link to the smart phone. When the connection between the smart phone and the
ECG device is lost, the system enters the sleep mode in order to save power.
4.3.1 ECG Monitoring Algorithm
Figure 4-8 illustrates the flow chart of the ECG monitoring algorithm.
26
start
read the current time
No
Is (current_timeprevious_time) ≥
sampling interval?
Yes
previous_time = current_time
read ECG data from ADC output
No
counter==0?
Yes
store time_step in the ‘counter’
position of the ecg_vector vector
increment time_step
increment counter
store the 2-byte ECG data in the
‘counter’ and ‘coutner+1’
positions of the ecg_vector vector
No
counter==11?
Yes
send data stored in the
ecg_vector vector
increment counter
end
Figure 4-8 Flow chart of ECG monitoring algorithm
27
The ECG monitoring algorithm is executed in the following steps:

ADC sampling

Quantization

Data transfer
A 10-bit ADC converter embedded in ATmega328P microcontroller samples the ECG analog
signal at the output of AD8232 at a sampling rate of 100 Hz (100 times per second), which
will be discussed in the section 5.2.1. This sampling rate is more than twice of the high cut-off
frequency (35 Hz) of ECG signals which satisfies the Shannon-Nyquist sampling theorem.
Next, the ADC converter quantizes each sampled voltage to a 10-bit digital value. The digital
output can be calculated by the following equation [24].
(4.1)
The ADC reference voltage is connected to the internal 3.3V power supply. The digitized
ECG signal is represented by an integer between 0 and 1023.
After ADC conversion, in order to reduce the TX power consumption of the radio, five digital
ECG data are grouped together and sent at the same time. Each data is represented by 2 bytes
because the maximum value 1023 occupies two bytes. In addition, a 1-byte time step is
required to be transmitted together with five ECG data. The time step can assist in the
reconstruction of the ECG signal on the smart phone. It can also be used to check if the data is
lost during transmission. Figure 4-9 shows the transmitted ECG data format.
Figure 4-9 The transmitted ECG data format
28
4.3.2 Battery Level and Temperature Algorithm
Figure 4-10 Flow chart of temperature or battery level monitoring algorithm
Battery level and temperature monitoring algorithms are executed in the same way. They
utilize the internal sensor of nRF8001. Firstly, ATmega328P microcontroller sends a
command to nRF8001 to get a value from the internal sensor. Then nRF8001 responses an
event with a temperature or a battery level to ATmega328P. Finally, the returned value is sent
via nRF8001 radio to a smart phone.
4.4 Main Loop
start
start
start
setup()
initialize I/O pins
handle remote
commands from
smart phone
loop()
configure SPI
set up nRF8001
check if RDYN pin
is low, and send
commands or
receive events
drive the system into
the SETUP mode
end
end
(a) main function
(b) setup() function
(c) loop() function
Figure 4-11 Flow chart of three major functions: main(), setup() and loop()
29
Every Arduino program has two specific functions: setup() and loop()[26], shown in Figure 411. Initialization is defined in the setup() function, which is called once at the beginning of the
program. The loop() function is infinitely implemented. In this main loop, ATmega328P
continuously polls the RDYN signal to handle events responsed by nRF8001 or a remote
command (an asynchronous event) from a smart phone. In terms of the remote command,
ECG, battery level or temperature monitoring is executed only after establishing connection
between the sensor and the smart phone.
4.4.1 Initialization
The initialization includes I/O pins initialization, SPI configuration and nRF8001 setup. SPI
configuration is explained in the section 4.2.1.
nRF8001 is required to be configured before the Bluetooth protocol operation. Its
configuration can be set up by nRFgo Studio (a Window application provided by the Nordic
Semiconductor), and can be saved to the file service.h. The nRF8001 setup is accomplished
by sending the setup information in the service.h file to nRF8001.
The nRF8001 setup involves configuration of the following [25]:

GATT service (Generic Attribute Profile)

GAP settings (Generic Access Profiile)

Hardware setting
Figure 4-12 demonstrates the ECG measurement profile for GATT service which is used in
this system. The ECG measurement service is stored in the local device – nRF8001. Every
characteristic value in the service is used to store one type of transmitted data and it has a
unique 128-bit UUID (Universally Unique Identifier). Each data is also transferred through a
service pipe which has its unique number and direction (Transmit or Receive).
The GAP setting defines the nRF8001 behavior in the active operating mode and defines
Bluetooth low energy specific parameters [25], such as:

Device name

Advertisement packet format and content

Encryption requirement
30
Figure 4-12 GATT services by nRFgo Studio
In nRF8001 hardware setting, an external 32.768 KHz crystal and an external 16 MHz crystal
are used as the clock source. The DC/DC converter is enabled to reduce power consumption.
31
5. Results
In-vivo tests have been carried out in order to measure the performance and functionalities of
the wireless ECG monitoring system prototype. ECG waveform, data lost rate and power
consumption are measured by experiments, and the results are analyzed in the following
sections.
In order to check the performance of the wireless designed ECG monitoring system, the
following setups have been done.

Two coin cell batteries provide power (6V) to supply the ECG sensor.

Three Ag/AgCl electrodes are placed on the chest of a healthy subject to acquire vital
signal. Two main sensing electrodes (RA and LA) have a distance of around 10 cm,
whereas the RLD electrode is mounted between two main sensing electrodes.

The ECG system is tested together with an iPod Touch which has an iOS healthcare
application responsible for receiving and displaying ECG signals sent by the system.
The application is developed by two master students, Venkat and Raj, who are also
involved in the project. Figure 5-1 shows the in-vivo test environment and the tested
subject.
Figure 5-1 In-vivo test environment

An oscilloscope is connected to the one-pin header of the prototype board, which is
used to measure the analog ECG signal at the output of AD8232.

A computer is connected to the prototype board by a 3.3V FTDI cable which is used to
measure the digitized ECG signal after ADC conversion.
32
5.1 ECG waveform
The capability of acquiring and displaying a clear ECG signal is the most significant feature
of the proposed wireless ECG system. In order to check the performance of each block of the
system, three ECG signals are observed and measured at the output of three blocks.

The analog ECG signal at the output of the front-end block AD8232 which is observed
by using an oscilloscope (Figure 5-2 (a)).

The digital ECG signal after ADC conversion which is printed on the computer screen
through a FTDI cable connected to the prototype board (Figure 5-2 (b)).

The ECG signal displayed on the iPod Touch (Figure 5-2 (c) and (d)).
(a) ECG waveform at AD8232 output
(c) ECG waveform on iPod Touch
(b) ECG waveform at ADC output
(d) ECG waveform drawn by using received data
Figure 5-2 ECG waveforms
Figure 5-2 shows clear ECG signals measured at different places of the system. Three most
representative characteristics (P wave, QRS complex and T wave) of the ECG waveform can
be clearly identified. All the signals have a baseline of around 1.6 V. The RR interval is
33
approximate 0.8 second, and hence the heart rate is 75 bpm. It indicates that the designed
ECG system has a capability of clearly and effectively monitoring ECG signals.
Figure 5-2 shows good quality of the ECG waveform with low noise. However, it should be
noted that the noise is increased with the movement of long wires connected between
electrodes and the prototype board. These long wires are only used in the testings, whereas
short wires would be employed and traced on the flexible substrate to reduce noise.
5.2 Data Lost Rate
As the ECG data is designed to be transmitted without acknowledgement via Bluetooth low
energy radio, data lost is unavoidable during transmission. Hence, it is necessary to measure
the data lost rate.
5.2.1 Data Lost Rate versus Sampling Rate
At the first, a sampling rate of 500 Hz was selected for ADC conversion, according to [5] [15]
and [27]. However, it was always found that some of QRS complexes were invisible on the
iPod Touch. Therefore the data lost rate measurement was conducted. The result showed that
during the wireless transmission an estimated 70 percent of ECG data was lost at the sampling
rate of 500 Hz, shown in Figure 5-3.
To measure the effect of sampling rate on the data lost rate, experiments are carried out at a
distance of 1 meter between the prototype board and the iPod Touch. It took 10 seconds for
the iPod Touch to receive and retrieve ECG signal. The time step described in the section
4.3.1 is used to calculate the data lost rate. Because one 1-byte time step is transmitted
together with five 2-bytes ECG data, the total number of the transmitted data bytes in 10
seconds is calculated as follow.
(5.1)
(5.2)
Table 5-1 illustrates five groups of data received by the iPod Touch at different sampling rates.
It clearly shows that at the 1-meter distance, the iPod Touch is only capable of receiving 2200
34
to 2900 bytes of data in 10 seconds even if the ADC converter increases its sampling rate in
order to transfer more digital data via the Bluetooth link. This is due to the fact that in the
iPod Touch, Wi-Fi, classic Bluetooth and Bluetooth low energy share the same antenna. It
significantly decreases the maximum throughput of the Bluetooth low energy transceiver in
the iPod Touch. This fact leads to the failure of reconstruction of the ECG signal on the iPod
Touch.
Table 5-1 Number of data bytes transmitted by the sensor and Number of data bytes received by the iPod
Touch at different ADC sampling rates in 10 seconds and at 1 meter distance
Sampling
Number
Group 1
Group 2
Group 3
Group 4
Group 5
rate (Hz)
Transmitted
Received
Received
Received
Received
Received
(bytes)
(bytes)
(bytes)
(bytes)
(bytes)
(bytes)
100
2200
2200
2200
2200
2200
2200
150
3300
2541
2563
2585
2596
2541
200
4400
2552
2618
2629
2574
2354
300
6600
2552
2618
2629
2574
2354
400
8800
2431
2541
2563
2585
2508
500
11000
2739
2442
2816
2750
2739
80
Data lost rate (%)
70
60
50
40
30
20
10
0
100
150
200
300
400
500
Sampling rate (Hz)
Figure 5-3 Data Lost Rate at different ADC sampling rates at 1m distance between the sensor and iPod Touch
According to the equations 5-1 and 5-2, the calculated average data lost rates are shown in
Figure 5-3. Higher is the sampling rate, more data is lost. The sampling rate has a significant
effect on the retrieval of the ECG signal. It can be clearly seen that it has a zero data lost rate
35
at 100 Hz sampling rate. Therefore, in this wireless ECG monitoring system, the 100 Hz
sampling rate is chosen in order to decrease the data lost rate and improve the quality of the
ECG signal on the smart phone.
5.2.2 Data Lost Rate versus Distance
The wireless transmission distance is constrained by the transmitted and received power of
nRF8001 and the antenna. In order to measure the effective transmitted distance of the
designed wireless ECG system, data lost rate is calculated at different distances between the
device and the iPod Touch.
The wireless link between the prototype board and the iPod Touch can be established under
the 20-meter distance. Data lost rate is measured at five distances: 1 meter, 5 meters, 10
meters, 15 meters, and 20 meters. There is no blocking between the sensor and the iPod
Touch. Table 5-2 illustrates five groups of results which are recorded in 10 seconds and at 100
Hz sampling rate.
Table 5-2 Number of data bytes received by iPod Touch at a 100Hz sampling rate and
at different distances to the ECG sensor
Distance
Group 1
Group 2
Group 3
Group 4
Group 5
(meter)
(bytes)
(bytes)
(bytes)
(bytes)
(bytes)
1
2200
2200
2200
2200
2200
5
2211
2189
2200
2200
2200
10
1958
1749
1683
2035
1419
15
2156
2167
2222
2035
2068
20
1210
935
770
770
1133
36
60
56.2
Data Lost Rate (%)
50
40
30
20
19.6
10
0
1
3.2
0.1
0
5
10
15
20
Distance (meter)
Figure 5-4 Data Lost Rate in 10 seconds and at 100 Hz sampling rate
Figure 5-4 shows the average data lost rate. Farther away from the prototype board that the
phone is, the more data is lost except at the 15-meter distance. At the 5-meter distance, only
0.1 percent of data is lost. Hence, the effective wireless transmission distance of the designed
wireless ECG monitoring system is 5 meters.
5.3 Power Consumption Measurement
Low power consumption is one of the most important features for the proposed wireless ECG
monitoring system. Therefore, the power consumption measurement is conducted to check if
the system can provide a long-term monitoring. In addition, the Enfucell battery in the
flexible substrate only fits for the 1mW low power consumption design.
The measured current consumption of the prototype board is 11.6 mA in the active mode. The
power consumption is relatively high, and this designed system is infeasible for the
continuous monitoring.
In order to check which part of the board consumes the greatest amount of power, current
analysis is performed on the every block of the prototype board. The power indicator – blue
LED and ATmega328P microcontroller are found to be two components which consume large
amount of current. After removing the LED from the board, the overall current is reduced to
7.8 mA. Therefore, LED should be avoided to be used as a power indicator in the PCB board.
37
14
12
11.6
Current (mA)
10
8
7.8
6
4
3.6
2.1
2
0
0
5
10
15
20
Clock frequency (MHz)
Figure 5-5 The overall current consumed by the ECG system
at different ATmega328P clock frequencies
In addition, ATmega328P microcontroller consumes approximately 6 mA current. Since the
microcontroller operates at a high frequency of 16 MHz, slowing down the clock can also
help reduce the power consumption. Figure 5-5 indicates that the overall current decreases to
2.1 mA at the 4 MHz frequency. Therefore, it is believed that the next version of the wireless
ECG monitoring system can fulfil the low power consumption requirement and can really
provide long-term monitoring.
38
6. Conclusion
In this thesis, a wireless bio-sensing with smart phone based monitoring system is proposed.
The system is designed as a wireless sensor. The sensor integrates ECG front-end analog
block (AD8232), ATmega328P microcontroller and Bluetooth low energy connectivity IC
(nRF8001) on a single board. The features of the system can be summarized as:

Compared to other wireless ECG monitoring systems in [5] [7] and [8], our designed
system is implemented by one single printed circuit board with a small size of
40mmx30mmx5mm. The miniaturized size promises the sensor to be wearable, and
the use of flexible battery and printed electrode can achieve users comfort.

The proposed system has been successfully proven to acquire, amplify, filter, digitize
and transmit ECG signal. The most representative characteristics of ECG signal, such
as P wave, QRS complex and T wave, can be clearly identified.

Apart from ECG monitoring, the capability of sensing temperature and battery level is
also achieved.

The sensor is capable of transmitting biomedical signal to the smart phone via wireless
link. Bluetooth low energy technology is adopted for wireless link due to its low
power consumption and reduced cost.

Since the wireless transmission capability is limited by the maximum throughput of
the antenna of the iPod Touch, the 100Hz sampling rate is selected by this system in
order to achieve a zero data lost rate.

The effective working distance of the system at the 100Hz sampling rate is 20 meters.
Besides, the system can achieve 0.1% data lost rate at the 5-meter distance.

The prototype board does not fulfil the low power consumption requirement. The
overall board consumes a relatively high current of 11.6 mA at the internal 3.3 V
supply voltage. The blue LED light and ATmega328P microcontroller with a high
frequency of 16 MHz are two main reasons for higher power consumption.
The iPod Touch is the Bluetooth Smart Ready device which was only used during the tests.
The system parameter such as the sampling rate is significantly dependent on the features of
the iPod Touch. In the future work, this system should be tested and evaluated with other
smart phones which support the Bluetooth low energy technology.
39
Furthermore, ECG signals acquired by this system operate at a frequency range of 0.34Hz to
35.24Hz. This bandwidth can be suitable for personal healthcare, but it is much narrower than
that of clinic ECG. The high cut-off frequency should be increased up to 150 Hz in order to
provide an accurate ECG diagnosis. It will lead to an increase in the sampling rate, and hence
it may affect the retrieval of ECG waveform on the smart phone.
In conclusion, the designed wireless ECG monitoring system is miniaturized, cost-efficient,
wearable and wireless, except for low power consumption. The reason for high power
consumption has been found, so it is believed that this system can support continuous ECG
monitoring in the future.
40
7. Future Work
Future improvements include the reduction of power consumption and the integration of
flexible substrate.
Low power consumption is required by the ECG system to provide continuous monitoring.
The following changes may be efficient to reduce power consumption.

Lower microcontroller clock frequency

Avoid the usage of LED lights

The microcontroller will be programmed to work in the power down mode when the
system does not transmit data.
Moreover, after the manufacture of the flexible substrate, the PCB board would be mounted
and integrated onto the flexible substrate. A FFC connector would replace the five pads on the
PCB board to provide an interface between the PCB board and the flexible substrate. The
performance of flexible battery and printed electrodes should be evaluated to ensure that the
overall system can provide the maximum convenience to users.
In addition, in-vivo tests would be conducted on both healthy and unhealthy subjects to verify
if the designed system has the ability to accurately detect the abnormalities of heart rate and
heart rhythm.
41
Reference
[1] Global status report on noncommunicable diseases 2010. Geneva, World Health
Organization, 2011.
[2] Mathers CD, Loncar D, “Projections of global mortality and burden of disease from 2002
to 2030,” PLoS Med, 2006, 3(11):e442.
[3] World Health Organization, July 2013, Cardiovascular diseases (CVDs). Retrieved from
http://www.who.int/mediacentre/factsheets/fs317/en/
[4] H. Sugano, T. Tsujioka, T. Inoue, S. Nakajima, S. Hara, H. Nakamura and K.Takeuchi,
“Clinical tests and evaluations of a Wireless ECG sensor for realization of ubiquitous health
care systems,” Engineering in Medicine and Biology Society, Aug. Sept. 2010, pp.2030-2033
[5] E. Nemati, M. J. Deen and T. Mondal, “A Wireless Wearable ECG Sensor for Long-Term
Applications,” IEEE Communications Magazine, Jan, 2012, Vol.50(1), p.36-43.
[6] C. Park, P.H. Chou, Y. Bai, R. Matthews and A. Hibbs, “An ultra-wearable, wireless, low
power ECG monitoring system”, 2006 IEEE Biomedical Circuits and Systems Conference,
Nov. Dec. 2006, pp.241-244.
[7] B. Yu, L. Xu and Y. Li, “Bluetooth Low Energy (BLE) Based mobile electrocardiogram
monitoring system,” 2012 IEEE International Conference on Information and Automation,
June 2012, pp.763-767
[8] Ming Hong, Yajun Zhang and Xiaoping Hu, “Portable ECG Measurement Device based
on MSP430 MCU,” 2008 International Conference on BioMedical Engineering and
Informatics, May 2008, Vol.2, pp.667-671
[9]
Continua
Alliance,
July
2013,
About
the
Alliance,
retrieved
from
http://www.continuaalliance.org/about-the-alliance/faqs
[10] Continua Alliance, July 2013, Continua Version 2012 Design Guidelines, retrieved from
http://www.continuaalliance.org/products/design-guidelines
[11] Bluetooth SIG, July 2013, Bluetooth 4.0 with low energy technology paves the way for
Bluetooth Smart devices, retrieved from http://www.bluetooth.com/Pages/Low-Energy.aspx
42
[12] Bluetooth SIG, July 2013, Google Announces Bluetooth Smart Ready Support for
Android Coming Later this Year, retrieved from http://www.bluetooth.com/Pages/PressReleases-Detail.aspx?ItemID=167
[13] Paul Kligfield, “Recommendations for the Standardization and Interpretation of the
Electrocardiogram,” Journal of the American College of Cardiology, Vol. 49, No. 10, 2007
[14] Frank G. Yanowitz, MD, “Introduction to ECG Interpretation V8.0 (July 2012),”
retrieved from http://ecg.utah.edu/introduction
[15] Enrique Company-Bosch and Eckart Hartmann, “ECG Front-End Design is simplified
with MicroConverter,” Analog Dialogue 37-11, November (2003)
[16] Geng Yang, “Hybrid integration of active bio-signal cable with intelligent electrode:
steps toward wearable pervasive-healthcare applications,” Doctoral Thesis, ICT KTH, 2012
[17] T.J. Sullivan, S.R. Deiss and G. Cauwenberghs, “A Low-Noise Non-Contact EED/ECG
Sensor,” 2007 IEEE Biomedical Circuits and Systems Conference, Nov. 2007, pp.154-157.
[18] Chia-lin Chang, Chih-wei Chang, Hong-yi Huang, Chen-ming Hsu, Chia-hsuan Huang,
Jin-chern Chiou and Ching-hsing Luo, “A power-efficient bio-potential acquisition device
with DS-MDE sensors for long-term healthcare monitoring applications,” Sensors (Basel,
Switzerland), 2010, Vol.10(5), pp.4777-93.
[19] J. Yoo, L. Yan, S. Lee, H. Kim, B. Kim and Hoi-Jun Yoo, “An Attachable ECG Sensor
Bandage with Planar-Fashionable Circuit Board,” 2009 International Symposium on
Wearable Computers, Sept. 2009, pp.145-146
[20] S.J. Jung, H.S. Shin and
W.Y. Chung, “Highly sensitive driver health condition
monitoring system using nonintrusive active electrodes”, Sensors & Actuators: B. Chemical,
2012, Vol.171-172, pp.691-698
[21] C. Rotariu, P. Bigioi and D. Chambers, “Lightweight PnP ECG sensor for monitoring of
biomedical signals,” Proceedings of the Ninth International Symposium on Consumer
Electronics, 2005, June 2005, pp.140-144
43
H. Ding, H. Sun and Kun-mean Hou, “Abnormal ECG signal detection based on Compressed
Sampling in Wearable ECG sensor,” 2011 International Conference on Wireless
Communications and Signal Processing, Nov. 2011, pp.1-5
[22] Analog Devices, “Single-Lead, Heart Rate Monitor Front End AD8232 Datasheet”,
February 2013
[23] Analog Devices, “AD8232 Evaluation Board Documentation”, November 2012
[24] Atmel, “Atmel 8-bit Microcontroller with 4/8/16/32Kbytes In-System Programmable
Flash”, February 2013
[25] Nordic Semiconductor, “nRF8001 Single-chip Bluetooth low energy solution Product
Specification 1.0”, January 2012
[26] Arduino, July 2013, “Arduino”, retrieved from http://www.arduino.cc/
[27] Hao Ding, Hong Sun, Kun-mean Hou, “Abnormal ECG signal detection based on
Compressed Sampling in Wearable ECG sensor,” 2011 International Conference on Wireless
Communications and Signal Processing, Nov. 2011, pp.1-5
44
List of Tables
Table 4-1 nRF8001 commands and events [25] ....................................................................... 25
Table 5-1 Number of data bytes transmitted by the sensor and Number of data bytes received
by the iPod Touch at different ADC sampling rates in 10 seconds and at 1 meter distance ... 35
Table 5-2 Number of data bytes received by iPod Touch at a 100Hz sampling rate and ........ 36
45
List of Figure
Figure 3-1 Block diagram of AD8232 [22] .............................................................................. 11
Figure 3-2Front-end analog circuit........................................................................................... 12
Figure 3-3 High-pass filter and low-pass filter [23] ................................................................. 13
Figure 3-4 Frequency response of the front end analog circuit ................................................ 14
Figure 3-5 ATmega328P microcontroller ................................................................................ 15
Figure 3-6 nRF8001 circuit ...................................................................................................... 16
Figure 3-7 SPI interface ........................................................................................................... 17
Figure 3-8 Power management circuit ..................................................................................... 18
Figure 3-9 PCB Prototype ........................................................................................................ 19
Figure 3-10 Layout of the flexible substrate prototype ............................................................ 20
Figure 4-1 Arduino Development Environment [26] ............................................................... 21
Figure 4-2 Software development platforms ............................................................................ 22
Figure 4-3 Architecture of ECG monitoring application ......................................................... 22
Figure 4-4 Sending a command over SPI interface [25] .......................................................... 23
Figure 4-5 Flow chart of SPI communication .......................................................................... 24
Figure 4-6 SPI packet format [25]............................................................................................ 25
Figure 4-7 State transitions between four operational modes .................................................. 26
Figure 4-8 Flow chart of ECG monitoring algorithm .............................................................. 27
Figure 4-9 The transmitted ECG data format ........................................................................... 28
Figure 4-10 Flow chart of temperature or battery level monitoring algorithm ........................ 29
Figure 4-11 Flow chart of three major functions: main(), setup() and loop() .......................... 29
Figure 4-12 GATT services by nRFgo Studio ......................................................................... 31
Figure 5-1 In-vivo test environment......................................................................................... 32
Figure 5-2 ECG waveforms ..................................................................................................... 33
Figure 5-3 Data Lost Rate at different ADC sampling rates at 1m distance between the sensor
and iPod Touch......................................................................................................................... 35
Figure 5-4 Data Lost Rate in 10 seconds and at 100 Hz sampling rate ................................... 37
Figure 5-5 The overall current consumed by the ECG system ................................................ 38
46
Appendix A
Schematics
47
Appendix B
B.1 PCB Layout on Top Layer
48
B.2 PCB Layout on Bottom Layer
49
Appendix C Source Code
C.1 Main Loop (ECG.ino)
Static hal_aci_data_t setup_msgs[NB_SETUP_MESSAGES] =
SETUP_MESSAGES_CONTENT;
extern my_project_app_state_t app_state;
void setup() {
Serial.begin(115200);
values_init();
app_state = APP_INIT;
lib_aci_init(services_pipe_type_mapping, NUMBER_OF_PIPES,
setup_msgs, NB_SETUP_MESSAGES);
app_state = APP_SETUP;
on_process_app();
}
void loop() {
read_remote_command();
hal_aci_tl_poll_rdy_line();
}
50
C.2 Hardware Abstraction Layer Code (hal_aci_tl.cpp)
static hal_aci_data_t received_data;
static hal_aci_data_t data_to_send;
static volatile bool spi_transmit_requested;
// SPI Pins
uint8_t reset_pin;
uint8_t reqn_pin;
uint8_t rdyn_pin;
// the interface pins between the AD8232 and the ATmega328P
uint8_t analog_out_pin;
uint8_t ref_out_pin;
uint8_t sdn_pin;
uint8_t lodp_pin;
uint8_t lodn_pin;
void hal_aci_tl_init(void)
{
received_data.buffer[0] = 0;
reset_pin = 5;
reqn_pin = 9;
rdyn_pin = 8;
analog_out_pin = 0xA4;
ref_out_pin = 0xA5;
sdn_pin = 0xA1;
lodp_pin = 0xA2;
lodn_pin = 0xA3;
// initialize the analog outputs of AD8232
// set SDN pin to HIGH for enabling the AD8232
pinMode(A1, OUTPUT);
pin
digitalWrite(A1, HIGH);
pinMode(A2, INPUT);
pin
pinMode(A3, INPUT);
pin
// SDN
// LOD+
// LOD-
// initialize SPI pins
if (reset_pin != -1) {
pinMode(reset_pin, OUTPUT);
digitalWrite(reset_pin, LOW);
//delayMicroseconds(65); // refer to nRF8001 datasheet 7.1.3.1
digitalWrite(reset_pin, HIGH);
51
}
pinMode(reqn_pin, OUTPUT);
pinMode(rdyn_pin, INPUT);
pinMode(SCK, OUTPUT);
pinMode(MOSI, OUTPUT);
pinMode(MISO, INPUT);
pinMode(SS, OUTPUT);
digitalWrite(reqn_pin, HIGH);
digitalWrite(rdyn_pin, HIGH);
digitalWrite(SCK, LOW);
digitalWrite(MOSI, LOW);
digitalWrite(MISO, LOW);
digitalWrite(SS, HIGH);
// SPI mode 0; /16 clock divider
SPI.begin();
SPI.setDataMode(SPI_MODE0);
SPI.setBitOrder(LSBFIRST);
// The clock speed of the Arduino Nano is 16MHz, while the SPI
frequency is defined as 2MHz
SPI.setClockDivider(SPI_CLOCK_DIV8);
spi_transmit_requested = false;
data_to_send.buffer[0] = 0;
}
bool hal_aci_tl_send(hal_aci_data_t *p_aci_cmd)
{
uint8_t length = p_aci_cmd->buffer[0];
if (!spi_transmit_requested)
{
ASSERT(ERROR_CODE_HAL_ACI_TL_OVERFLOW,(p_aci_cmd->buffer[0] <=
HAL_ACI_MAX_LENGTH));
if (length > HAL_ACI_MAX_LENGTH)
{
return(false);
}
{
lib_mem_copy(data_to_send.buffer, p_aci_cmd->buffer, length+1);
spi_transmit_requested = true; // Request transmission
}
digitalWrite(reqn_pin, LOW);
return(true);
52
}
else
{
return(false);
}
}
void hal_aci_tl_poll_rdy_line(void)
{
uint8_t byte_cnt;
uint8_t byte_sent_cnt;
uint8_t max_bytes;
bool is_transmit_finished = false;
uint8_t sIdx;
/*if(1 ==HAL_IO_READ(HAL_IO_RADIO_RDY))*/
if (HIGH == digitalRead(rdyn_pin))
{
return;
}
digitalWrite(reqn_pin, LOW);
// Send length, receive header
byte_sent_cnt = 0;
received_data.status_byte =
SPI.transfer(data_to_send.buffer[byte_sent_cnt++]);
sIdx = 0;
received_data.buffer[0] =
SPI.transfer(data_to_send.buffer[byte_sent_cnt++]);
if (0 == data_to_send.buffer[0])
{
max_bytes = received_data.buffer[0];
}
else
{
// Set the maximum to the biggest size. One command byte is
already sent
max_bytes = (received_data.buffer[0] > (data_to_send.buffer[0] 1))
? received_data.buffer[0] : (data_to_send.buffer[0] - 1);
}
if (max_bytes > HAL_ACI_MAX_LENGTH)
{
max_bytes = HAL_ACI_MAX_LENGTH;
}
53
// Transmit/receive the rest of the packet
for (byte_cnt = 0; byte_cnt < max_bytes; byte_cnt++)
{
received_data.buffer[byte_cnt+1] =
SPI.transfer(data_to_send.buffer[byte_sent_cnt++]);
}
/* Release REQN */
digitalWrite(reqn_pin, HIGH);
ASSERT(ERROR_CODE_HAL_ACI_TL_STATUS_BYTE,(0 !=
received_data.status_byte));
if (spi_transmit_requested)
{
data_to_send.buffer[0] = 0;
spi_transmit_requested = false;
}
/* valid Rx available or transmit finished*/
hal_aci_tl_msg_rcv_hook(&received_data);
}
54
C.3 Application Layer Code (my_application.cpp)
C.3.1 State Transition between Four Modes
void on_process_app(void)
{
switch(app_state)
{
case APP_SLEEP:
app_next_state = APP_STANDBY;
lib_aci_device_wakeup();
// Initialize the counters used for advertising when the ECG
device is bonded and non bonded
if (!is_bonded)
{
bond_adv_counter = 3;
}
else
{
direct_adv_counter = 3;
}
break;
case APP_SETUP:
app_next_state = APP_SETUP;
/* lib_aci_send_setup_msg() returns true when all messages are
sent */
if (lib_aci_send_setup_msg())
{
app_next_state = APP_SETUP_FINISHED;
}
break;
case APP_STANDBY:
if (!is_bonded)
{
lib_aci_bond(APP_ADVERTISING_TIME, APP_RUN_ADV_PERIOD);
}
else
{
lib_aci_connect(APP_ADVERTISING_TIME_CONNECT,
APP_RUN_ADV_INTERVAL);
}
app_next_state = APP_RUN;
break;
55
case APP_RUN:
app_next_state = APP_RUN;
app_state = APP_RUN;
break;
case APP_GOTO_SLEEP:
lib_aci_sleep();
/* nRF8200 will wake on reset */
app_state = APP_SLEEP;
break;
}
}
56
C.3.2 Handle the Smart Phone Command
void read_remote_command()
{
unsigned long current_time = millis();
if (!is_connected)
return;
switch (remote_command)
{
case CMD_SEND_ECG:
read_send_ECG();
break;
case CMD_SEND_BATTERY:
if (!is_get_battery_level) {
get_battery();
} else {
send_battery();
}
break;
case CMD_SEND_TEMPERATURE:
if (!is_get_temperature)
get_temperature();
else
send_temperature();
break;
default:
break;
}
}
57
C.3.3 ECG Monitoring
void read_send_ECG(void)
{
int val = 0;
bool handled = false;
uint8_t vref_v[VREF_NUM];
uint8_t sampling_rate_v[SAMPLING_RATE_NUM];
unsigned long current_sample_time = micros();
if (!is_connected)
return;
if (!is_sending_ecg)
return;
if (!lib_aci_is_pipe_available(ecg_tx_pipe))
return;
if (!lib_aci_is_pipe_available(sampling_rate_pipe))
return;
if (!lib_aci_is_pipe_available(vref_pipe))
return;
if (check_DC_leadoff())
return;
if ((current_sample_time - previous_sample_time) <
ecg_sample_interval)
{
return;
}
else
{
previous_sample_time = current_sample_time;
}
if (!is_send_vref)
{
is_send_vref = true;
vref_v[0] = vref & 0xFF;
vref_v[1] = (vref & 0xFF00) >> 8;
if (IS_QUEUE_EMPTY(&tx_data_queue))
{
// Since the queue is empty, the ECG data can be sent right
away
handled = lib_aci_send_data(vref_pipe, vref_v, VREF_NUM);
}
if (!handled)
{
58
// If queue is not empty or the earlier call to
lib_aci_send_data failed
uint8_t queue_data[VREF_NUM + 1];
queue_data[0] = vref_pipe;
memcpy(&(queue_data[1]), vref_v, VREF_NUM);
handled = lib_queue_put(&tx_data_queue, queue_data, (VREF_NUM
+ 1));
}
if (!handled)
{
// QUEUE ADD ERROR
}
return;
}
if (!is_send_sampling_rate)
{
is_send_sampling_rate = true;
sampling_rate_v[0] = sampling_rate & 0xFF;
sampling_rate_v[1] = (sampling_rate & 0xFF00) >> 8;
if (IS_QUEUE_EMPTY(&tx_data_queue))
{
// Since the queue is empty, the ECG data can be sent right
away
handled = lib_aci_send_data(sampling_rate_pipe,
sampling_rate_v, SAMPLING_RATE_NUM);
}
if (!handled)
{
// If queue is not empty or the earlier call to
lib_aci_send_data failed
uint8_t queue_data[SAMPLING_RATE_NUM+1];
queue_data[0] = sampling_rate_pipe;
memcpy(&(queue_data[1]), sampling_rate_v, SAMPLING_RATE_NUM);
handled = lib_queue_put(&tx_data_queue, queue_data,
(SAMPLING_RATE_NUM + 1));
}
if (!handled)
{
// QUEUE ADD ERROR
}
return;
}
val = analogRead(A4);
if (ecg_counter == 0)
{
ecg_vector[ecg_counter++] = time_step;
59
}
ecg_vector[ecg_counter++] = val & 0xFF;
ecg_vector[ecg_counter++] = (val & 0xFF00) >> 8;
if (ecg_counter == ECG_DATA_NUM)
{
ecg_counter = 0;
time_step++;
if (IS_QUEUE_EMPTY(&tx_data_queue))
{
// Since the queue is empty, the ECG data can be sent right
away
handled = lib_aci_send_data(ecg_tx_pipe, ecg_vector,
ECG_DATA_NUM);
}
if (!handled)
{
// If queue is not empty or the earlier call to
lib_aci_send_data failed
uint8_t queue_data[ECG_DATA_NUM+1];
queue_data[0] = ecg_tx_pipe;
memcpy(&(queue_data[1]), ecg_vector, ECG_DATA_NUM);
handled = lib_queue_put(&tx_data_queue, queue_data,
ECG_DATA_NUM+1);
}
}
}
60
C.3.4 Battery Level Monitoring
void get_battery(void)
{
if (!is_connected)
return;
if (!lib_aci_is_pipe_available(battery_pipe))
return;
// get a battery level from the nRF8001
if (lib_aci_get_battery_level())
is_get_battery_level = true;
}
void send_battery(void)
{
bool handled = false;
uint8_t battery_v[BATTERY_NUM];
if (!is_connected)
return;
if (!lib_aci_is_pipe_available(battery_pipe))
return;
if (!is_return_battery_level)
return;
battery_v[0] = battery_level;
handled = lib_aci_send_data(battery_pipe, battery_v, BATTERY_NUM);
if (handled) {
is_get_battery_level = false;
is_return_battery_level = false;
}
remote_command = CMD_STOP_ECG;
}
61
C.3.5 Temperature Monitoring
void get_temperature(void)
{
if (!is_connected)
return;
if (!lib_aci_is_pipe_available(temperature_pipe))
return;
// get temperature from the nRF8001
if (lib_aci_get_temperature())
is_get_temperature = true;
}
void send_temperature(void)
{
bool handled = false;
uint8_t temperature_v[TEMPERATURE_NUM];
if (!is_connected)
return;
if (!lib_aci_is_pipe_available(temperature_pipe))
return;
if (!is_return_temperature)
return;
temperature_v[0] = temperature;
handled = lib_aci_send_data(temperature_pipe, temperature_v,
TEMPERATURE_NUM);
if (handled) {
is_get_temperature = false;
is_return_temperature = false;
}
remote_command = CMD_STOP_ECG;
}
62
TRITA-ICT-EX-2013:240
www.kth.se
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement