Vous êtes sur la page 1sur 79

25/11/13 e-Health Sensor Platform V2.

0 for Arduino and Raspberry Pi [Biometric / Medical Applications]


www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_medi 1/79
Arduino Waspmote 3D Printer Raspberry Pi Sensors Actuators Wireless DevTools Robotics Accessories On Demand
Starter Kits Shields Wireless Packs Enclosures Prototyping Converters Books Designed by CH
Tweet Like
e-Health Sensor Platform V2.0 for Arduino and
Raspberry Pi [Biometric / Medical Applications]
In August 2013 Cooking Hacks launched the new version of the first biometric shield for Arduino and Raspberry Pi: the e-
Health Sensor Platform V2.0. Thanks to the feedback given by the Community and several projects that have been created
with it, we have improved the e-Health platform with new features such as:
New muscle sensor
New blood pressure sensor
Upgraded glucometer
New Connection possibilities
In this tutorial we will explain how to work with e-Health Sensor Platform V2.0. If you have e-Health V1 you can see how to
use it on this link:
Tutorial: e-Health Sensor Platform V1.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
The e-Health Sensor Shield V2.0 allows Arduino and Raspberry Pi
users to perform biometric and medical applications where body
monitoring is needed by using 10 different sensors: pulse, oxygen
in blood (SPO2), airflow (breathing), body temperature,
electrocardiogram (ECG), glucometer, galvanic skin response
(GSR - sweating), blood pressure (sphygmomanometer), patient
position (accelerometer) and muscle/eletromyography sensor
(EMG).
This information can be used to monitor in real time the state of a
patient or to get sensitive data in order to be subsequently analysed
for medical diagnosis. Biometric information gathered can be
wirelessly sent using any of the 6 connectivity options available: Wi-
Fi, 3G, GPRS, Bluetooth, 802.15.4 and ZigBee depending on the
application.
If real time image diagnosis is needed a camera can be attached to
the 3G module in order to send photos and videos of the patient to
a medical diagnosis center.
Data can be sent to the Cloud in order to perform permanent storage or visualized in real time by sending the data directly to a
laptop or Smartphone. iPhone and Android applications have been designed in order to easily see the patient's information.
Quick FAQ:
What does it mean to count with an open medical monitoring platform?
Cooking Hacks wants to give Community the necessary tools in order to develop new e-Health applications and products.
We want Arduino and Raspberry Pi Community to use this platform as a quick proof of concept and the basis of a new era of
open source medical products.
How do I ensure the privacy of the biometric data sent?
Privacy is one of the key points in this kind of applications. For this reason the platform includes several security levels:
CART
You have no items in your shopping
cart.
COMPARE PRODUCTS
You have no items to compare.
NEWSLETTER
Sign up f or our newsletter
Sign Up for Our Newsletter:
Buy now
60

25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_medi 2/79
Go to Index
In the communication link layer: AES 128 for 802.14.5 / ZigBee and WPA2 for Wifi.
In the application layer: by using the HTTPS (secure) protocol we ensure a point to point security tunnel between each
sensor node and the web server (this is the same method as used in the bank transfers).
e-Health Sensor Shield over Arduino (left) Raspberry Pi (right)
IMPORTANT: The e-Health Sensor Platform has been designed by Cooking Hacks (the open hardware division of
Libelium) in order to help researchers, developers and artists to measure biometric sensor data for experimentation, fun
and test purposes. Cooking Hacks provides a cheap and open alternative compared with the proprietary and price
prohibitive medical market solutions. However, as the platform does not have medical certifications it can not be used to
monitor critical patients who need accurate medical monitoring or those whose conditions must be accurately measured for
an ulterior professional diagnosis.
NOTE: If you are interested in Wireless Sensor Networks (WSN), M2M and the Internet of Things (IoT) projects check our
new open source sensor platform: Waspmote which counts with more than 60 sensors available to use and a low
consumption mode of just 0.07uA to ensure years of battery life. Know more at:
Waspmote Main Page (Libelium)
Waspmote Brief Description (Cooking Hacks)
Get the shields and sensors
Kit
e-Health Sensors Shield
e-Health Sensor Platform Complete Kit
Sensors
Patient Position Sensor (Accelerometer)
Glucometer Sensor
Body Temperature Sensor
Blood Pressure Sensor (Sphygmomanometer) V2.0
Pulse and Oxygen in Blood Sensor (SPO2)
Airflow Sensor (Breathing)
Galvanic Skin Response Sensor (GSR - Sweating)
Electrocardiogram Sensor (ECG)
Electromyography Sensor (EMG)
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_medi 3/79
Go to Index
Go to Index
Article Index
1. Features
Electrical features
2. The shield
e-Health PCB
3. The library
e-Health shield over Arduino
e-Health shield over Raspberry Pi
4. Sensor Platform
Pulse and Oxygen in Blood
Electrocardiogram (ECG)
Airflow: breathing
Body temperature
Blood pressure
Patient position and falls
Galvanic Skin Response (GSR)
Glucometer
Muscle/Electromyography sensor
5. Visualizing the data
LCD
KST: Real-time data viewing and plotting
Serial console
SmartPhone Application
6. Sending the data to the Cloud
Wifi
Bluetooth
Zigbee / 802.15.4
GPRS
3G
Camera for Photo Diagnosis
7. Forum
8. Get the shields and sensors
Kits
Sensors
1. Features
The pack we are going to use in this tutorial is the eHealth Sensor platform from Cooking Hacks. The e-Health Sensor Shield is
fully compatible with Raspberry and new and old Arduino USB versions, Duemilanove and Mega.
8 non-invasive + 1 invasive medical sensors
Storage and use of glucose measurements.
Monitoring ECG signal.
Monitoring EMG signals.
Airflow control of patient.
Body temperature data.
Galvanic skin response measurements.
Body position detection.
Pulse and oxygen functions.
Blood pressure control device.
Multiple data visualization systems.
Compatible with all UART device.
Electrical features:
The e-Health shield can be powered by the PC or by an external power supply. Some of the USB ports on computers are not able
to give all the current the module needs to work, if your module have problems when it work, you can use an external power supply
(12V - 2A) on the Arduino/RasberryPi.
2. The shield
e-Health PCB
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_medi 4/79
Schematics
Download the e-Health Schematics
e-Health shield over Arduino
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_medi 5/79
The shields:
Get Arduino
Get the e-Health sensor shield
Get the e-Health complete kit
e-Health shield over Raspberry Pi
In order to connect the e-Health Sensor Shield to Raspberry Pi an adaptor shield is needed. Click here to know more about the
Raspberry Pi to Arduino Shields Connection board.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_medi 6/79
Go to Index
The shields:
Get Raspberry Pi
Get the Raspberry Pi to Arduino shields connection bridge
Get the e-Health sensor shield
Get the e-Health complete kit
Warnings:
The LCD, the sphygmomanometer and communication modules use the UART port and can't work simultaneously.
The glucometer is now compatible with other UART devices and it has its own connector. But it can not work with the
sphygmomanometer connected.
The EMG sensor and the ECG can't work simultaneously. Use the jumpers integrated in the board to use one or the
other.
To use the EMG sensor, you'll need to have the jumpers in the EMG position. To use the ECG sensor, you'll need to
have the jumpers in the ECG configuration.
3. The library
Note: these examples are written for Arduino 1.0.1. Certain functions may not work in other versions.
The e-health Sensor Platform counts with a C++ library that lets you read easily all the sensors and send the information by using
any of the available radio interfaces. This library offers an simple-to-use open source system.
In order to ensure the same code is compatible in both platforms (Arduino and Raspberry Pi) we use the ArduPi libraries which
allows developers to use the same code. Detailed info can be found here:
Raspberry Pi to Arduino shields connection bridge
ArduPi library
Using the library with Arduino
The eHealth sensor platform includes a high level library functions for a easy manage of the board. Before start using this
functions you should download the files from this link. This zip includes all the files needed in two separated folders, eHealth
and PinChangeInt. The PinChangeInt library is necessary only when you use the pulsioximeter sensor. Copy this folders in the
arduino IDE folder libraries. Don't forget include these libraries in your codes.
Download the e-Health library for Arduino
Libraries are often distributed as a ZIP file or folder. The name of the folder is the name of the library. Inside the folder will be the
.cpp files, .h files and often a keywords.txt file, examples folder, and other files required by the library.
To install the library, first quit the Arduino application. Then uncompress the ZIP file containing the library. For installing eHealth
library , uncompress eHealth.zip. It should contain a folder called eHealth and another called PinChangeInt, with files like
eHealth.cpp and eHealth.h inside. Drag the eHealth and PinChange folders into this folder (your libraries folder). Under Windows,
it will likely be called "My Documents\Arduino\libraries". For Mac users, it will likely be called "Documents/Arduino/libraries". On
Linux, it will be the "libraries" folder in your sketchbook.
The library won't work if you put the .cpp and .h files directly into the libraries folder or if they're nested in an extra folder. Restart the
Arduino application. Make sure the new library appears in the Sketch->Import Library menu item of the software.
That's it! You've installed a library!
Using the library with Raspberry Pi
The e-Health library for Raspberry Pi requires the arduPi library and both libraries should be in the same path.
Download the e-Health Libraries for Raspberry
Creating a program that uses the library is as simple as putting your code in this template where it says "your arduino code here"
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_medi 7/79
Hide Code
//Include eHealth library (it includes arduPi)
#include "eHealth.h"
/*********************************************************
* IF YOUR ARDUINO CODE HAS OTHER FUNCTIONS APART FROM *
* setup() AND loop() YOU MUST DECLARE THEM HERE *
* *******************************************************/
/**************************
* YOUR ARDUINO CODE HERE *
* ************************/
int main (){
setup();
while(1){
loop();
}
return (0);
}
Compilation of the program can be done in two ways:
Compiling separately eHealth and arduPi, and using them for compiling the program in a second step:
g++ -c arduPi.cpp -o arduPi.o
g++ -c eHealth.cpp -o eHealth.o
g++ -lpthread -lrt user-e-health-app.cpp arduPi.o eHealth.o -o user-e-health-app
Compiling everithing in one step:
g++ -lpthread -lrt user-e-health-app.cpp arduPi.cpp eHealth.cpp -o user-e-health-app
Executing your program is as simple as doing:
sudo ./user-e-health-app
General e-Health functions
Pulsioximeter sensor functions:
initPulsioximeter() // It initialize the pulsioximeter sensor.
readPulsioximeter() // It reads a value from pulsioximeter sensor.
getBPM() // Returns the heart beats per minute.
getOxygenSaturation() // Returns the oxygen saturation in blood in percent.
ECG sensor funcion:
getECG() // Returns an analogic value to represent the Electrocardiography.
EMG sensor funcion:
getEMG() // Returns an analogic value to represent the Electromyography.
AirFlow sensor funcions:
getAirFlow() // Returns an analogic value to represent the air flow.
airFlowWave() // Prints air flow wave form in the serial monitor.
Temperature sensor function:
getTemperature() // Returns the corporal temperature.
Blood pressure functions:
initBloodPressureSensor() // It initialize and measure the blood pressure sensor.
getBloodPressureSensor() // Returns the number of data stored in the blood pressure sensor.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_medi 8/79
Go to Index
getSystolicPressure(i) // Returns the value of the systolic pressure number i.
getDiastolicPressure(i) // Returns the value of the diastolic pressure number i.
Body position sensor functions:
initPositionSensor() // It initialize the position sensor.
getBodyPosition() // Returns the body position.
printPosition() // Prints the current body position.
GSR sensor functions:
getSkinConductance() // Returns the value of skin conductance.
getSkinResistance() // Returns the value of skin resistance.
getSkinConductanceVoltage() // Returns the value of skin conductance in voltage.
Glucometer sensor functions:
readGlucometer() // Read the values stored in the glucometer.
GetGlucometerLength() // Returns the number of data stored in the glucometer.
numberToMonth() // Convert month variable from numeric to character.
4. Sensor Platform
Pulse and Oxygen in Blood (SPO2)
SPO2 sensor features
Pulse oximetry a noninvasive method of indicating the arterial oxygen saturation of functional hemoglobin.
Oxygen saturation is defined as the measurement of the amount of oxygen dissolved in blood, based on the detection of
Hemoglobin and Deoxyhemoglobin. Two different light wavelengths are used to measure the actual difference in the absorption
spectra of HbO2 and Hb. The bloodstream is affected by the concentration of HbO2 and Hb, and their absorption coefficients are
measured using two wavelengths 660 nm (red light spectra) and 940 nm (infrared light spectra). Deoxygenated and oxygenated
hemoglobin absorb different wavelengths.
Deoxygenated hemoglobin (Hb) has a higher absorption at 660 nm and oxygenated hemoglobin (HbO2) has a higher absorption
at 940 nm . Then a photo-detector perceives the non-absorbed light from the LEDs to calculate the arterial oxygen saturation.
A pulse oximeter sensor is useful in any setting where a patient's oxygenation is unstable, including intensive care, operating,
recovery, emergency and hospital ward settings, pilots in unpressurized aircraft, for assessment of any patient's oxygenation, and
determining the effectiveness of or need for supplemental oxygen.
Acceptable normal ranges for patients are from 95 to 99 percent, those with a hypoxic drive problem would expect values to be
between 88 to 94 percent, values of 100 percent can indicate carbon monoxide poisoning.
The sensor needs to be connected to the Arduino or Raspberry Pi, and don't use external/internal battery.
Connecting the sensor
Connect the module in the e-Health sensor platform. The sensor have only one way of connection to prevent errors and make the
connection easier.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_medi 9/79
Insert your finger into the sensor and press ON button.
After a few seconds you will get the values in the sensor screen.
Library functions
Initializing
This sensor use interruptions and it is necessary to include a special library when you are going to use it.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 10/79
#include < PinChangeInt.h >
After this include, you should attach the interruptions in your code to get data from th sensor. The sensor will interrupt the process
to refresh the data stored in private variables.
PCintPort::attachInterrupt(6, readPulsioximeter, RISING);
The digital pin 6 of Arduino is the pin where sensor send the interruption and the function readpulsioximeter will be executed.
void readPulsioximeter(){
cont ++;
if (cont == 50) { //Get only one 50 measures to reduce the latency
eHealth.readPulsioximeter();
cont = 0;
}
}
Before start using the SP02 sensor, it must be initialized. Use the next function in setup to configure some basic parameters and
to start the communication between the Arduino/RaspberryPi and sensor.
Reading the sensor
For reading the current value of the sensor, use the next function.
Example:
{
eHealth.readPulsioximeter();
}
This function will store the values of the sensor in private variables.
Getting data
To view data we can get the values of the sensor stored in private variable by using the next functions.
Example:
{
int SPO2 = eHealth.getOxygenSaturation()
int BPM = eHealth.getBPM()
}
Example
Arduino
Upload the next code for seeing data in the serial monitor:
Show Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
* Body Temperature, Electrocardiogram Sensor (ECG), Glucometer, Galvanic Skin
* Response Sensor (GSR - Sweating), Blood Pressure (Sphygmomanometer) and
* Patient Position (Accelerometer)."
*
* In this example we read the values of the pulsioximeter sensor
* and we show this values in the serial monitor
*
* Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
Upload the code to Arduino and watch the Serial monitor.Here is the USB output using the Arduino IDE serial port terminal:
Raspberry Pi
Show Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 11/79
Mobile app
The App shows the information the nodes are sending which contains the sensor data gathered. Smartphone app
GLCD
The GLCD shows the information the nodes are sending which contains the sensor data gathered. GLCD
Get the Pulse and Oxygen in Blood Sensor (SPO2)
Electrocardiogram (ECG)
ECG sensor features
The electrocardiogram (ECG or EKG) is a diagnostic tool that is routinely used to assess the electrical and muscular functions of
the hear.
The Electrocardiogram Sensor (ECG) has grown to be one of the most commonly used medical tests in modern medicine. Its
utility in the diagnosis of a myriad of cardiac pathologies ranging from myocardial ischemia and infarction to syncope and
palpitations has been invaluable to clinicians for decades.
The accuracy of the ECG depends on the condition being tested. A heart problem may not always show up on the ECG. Some
heart conditions never produce any specific ECG changes. ECG leads are attached to the body while the patient lies flat on a bed
or table.
What is measured or can be detected on the ECG (EKG)?
The orientation of the heart (how it is placed) in the chest cavity.
Evidence of increased thickness (hypertrophy) of the heart muscle.
Evidence of damage to the various parts of the heart muscle.
Evidence of acutely impaired blood flow to the heart muscle.
Patterns of abnormal electric activity that may predispose the patient to abnormal cardiac rhythm disturbances.
The underlying rate and rhythm mechanism of the heart.
Schematic representation of normal ECG
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 12/79
Connecting the sensor
Connect the three leads (positive, negative and neutral) in the e-Health board.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 13/79
Connect the ECG lead to the electrodes.
Remove the protective plastic
Place the electrodes as shown below
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 14/79
Library functions
Getting data:
This ECG returns an analogic value in volts (0 5) to represent the ECG wave form.
Example:
{
float ECGvolt = eHealth.getECG();
}
Example
Arduino
Upload the next code for seeing data in the serial monitor:
Show Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
* Body Temperature, Electrocardiogram Sensor (ECG), Glucometer, Galvanic Skin
* Response Sensor (GSR - Sweating), Blood Pressure (Sphygmomanometer) and
* Patient Position (Accelerometer)."
*
* In this example we read the values in volts of ECG sensor and show
* these values in the serial monitor.
*
* Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
Upload the code and watch the Serial monitor. Here is the USB output using the Arduino IDE serial port terminal:
Raspberry Pi
Show Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
* Body Temperature, Electrocardiogram Sensor (ECG), Glucometer, Galvanic Skin
* Response Sensor (GSR - Sweating), Blood Pressure (Sphygmomanometer) and
* Patient Position (Accelerometer)."
*
* In this example we read the values in volts of EMG sensor and show
* these values in the serial monitor.
*
* Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Mobile App
The App shows the information the nodes are sending which contains the sensor data gathered. Smartphone app
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 15/79
GLCD
The GLCD shows the information the nodes are sending which contains the sensor data gathered. GLCD
KST
KST program shows the ECG wave. KST
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 16/79
Get the Electrocardiogram Sensor (ECG)
Airflow: breathing
Airflow sensor features
Anormal respiratory rates and changes in respiratory rate are a broad indicator of major physiological instability, and in many
cases, respiratory rate is one of the earliest indicators of this instability. Therefore, it is critical to monitor respiratory rate as an
indicator of patient status. AirFlow sensor can provide an early warning of hypoxemia and apnea.
The nasal / mouth airflow sensor is a device used to measure the breathing rate in a patient in need of respiratory help or person.
This device consists of a flexible thread which fits behind the ears, and a set of two prongs which are placed in the nostrils.
Breathing is measured by these prongs.
The specifically designed cannula/holder allows the thermocouple sensor to be placed in the optimal position to accurately sense
the oral/nasal thermal airflow changes as well as the nasal temperature air. Comfortable adjustable and easy to install.
Single channel oral or nasal reusable Airflow Sensor. Stay-put prongs position sensor precisely in airflow path.
A normal adult human has a respiratory rate of 1530 breaths per minute.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 17/79
Connecting the sensor
The e-Health AirFlow sensor have two connections (positive and negative)
Connect the red wire with the positive terminal (marked as + in the board) and the black wire with the negative terminal (marked
as - in the board).
After connecting the cables, tighten the screws
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 18/79
Place the sensor as shown in the picture below
Library functions
Getting data
The air flow sensor is connected to the Arduino/RasberryPi by an analog input and returns a value from 0 to 1024. With the next
functions you can get this value directly and print a wave form in the serial monitor.
Example:
{
int airFlow = eHealth.getAirFlow();
eHealth.airFlowWave(air);
}
Example
Arduino
Upload the next code for seeing data in the serial monitor:
Show Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
Upload the code and watch the Serial monitor.Here is the USB output using the Arduino IDE serial port terminal:
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 19/79
Raspberry Pi
Compile this example code:
Show Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
* Body Temperature, Electrocardiogram Sensor (ECG), Glucometer, Galvanic Skin
* Response Sensor (GSR - Sweating), Blood Pressure (Sphygmomanometer) and
* Patient Position (Accelerometer)."
*
* In this example we read the values in volts of EMG sensor and show
* these values in the serial monitor.
*
* Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version 2.0
* Author: Luis Martin & Ahmad Saad & Anartz Nuin
*/
//Include eHealth library
#include "eHealth.h"
void loop() {
int air = eHealth.getAirFlow();
eHealth.airFlowWave(air);
delay(50);
}
int main (){
while(1){
loop();
}
return (0);
Mobile App
The App shows the information the nodes are sending which contains the sensor data gathered. Smartphone app
GLCD
The GLCD shows the information the nodes are sending which contains the sensor data gathered. GLCD
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 20/79
KST
KST program shows the airflow wave. KST
Get the Airflow Sensor (Breathing)
Body temperature
Temperature sensor features
Body temperature depends upon the place in the body at which the measurement is made, and the time of day and level of activity
of the person. Different parts of the body have different temperatures.
The commonly accepted average core body temperature (taken internally) is 37.0C (98.6F). In healthy adults, body temperature
fluctuates about 0.5C (0.9F) throughout the day, with lower temperatures in the morning and higher temperatures in the late
afternoon and evening, as the body's needs and activities change.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 21/79
It is of great medical importance to measure body temperature. The reason is that a number of diseases are accompanied by
characteristic changes in body temperature. Likewise, the course of certain diseases can be monitored by measuring body
temperature, and the efficiency of a treatment initiated can be evaluated by the physician.
Hypothermia <35.0 C (95.0 F)
Normal 36.537.5 C (97.799.5 F)
Fever or Hyperthermia >37.538.3 C (99.5100.9 F)
Hyperpyrexia >40.041.5 C (104106.7 F)
Sensor Calibration
The precision of the Body Temperature Sensor is enough in most applications. But you can improve this precision by a calibration
process.
When using temperature sensor, you are actually measuring a voltage, and relating that to what the operating temperature of the
sensor must be. If you can avoid errors in the voltage measurements, and represent the relationship between voltage and
temperature more accurately, you can get better temperature readings.
Calibration is a process of measuring voltage and resistance real values. In the eHealth.cpp file we can find getTemperature
function. The values [Rc, Ra, Rb, RefTension] are imprecisely defined by default.
If you measure these values with a multimeter and modify the library will obtain greater accuracy.
Place multimeter ends at the extremes of the resistors and measure the resistance value. In this case we would modify
resistance value (Ra=4640 / Rb=819)...
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 22/79
Make the same process between 3V (red cable) and GND (black cable) but with the multimeter in voltage measurement. In this
case we would not change the value.
Connecting the sensor
For taking measures of temperature, connect the sensor in the jack connector using the adapter
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 23/79
Make contact between the metallic part and your skin
Use a piece of adhesive tape to hold the sensor attached to the skin
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 24/79
Library functions
Geting data
The corporal temperature can be taken by a simple function. This function return a float with the last value of temperature
measured by the Arduino/RasberryPi.
Example:
{
float temperature = eHealth.getTemperature();
}
Example
Arduino
Upload the next code for seeing data in the serial monitor:
Show Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
* Body Temperature, Electrocardiogram Sensor (ECG), Glucometer, Galvanic Skin
* Response Sensor (GSR - Sweating), Blood Pressure (Sphygmomanometer) and
* Patient Position (Accelerometer)."
*
* In this example we use the temperature sensor to measure the
* corporal temperature of the body.
*
* Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version 2.0
* Author: Luis Martin & Ahmad Saad
*/
#include <eHealth.h>
Upload the code and watch the Serial monitor. Here is the USB output using the Arduino IDE serial port terminal:
Raspberry Pi
Compile the following example code:
Show Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
* Body Temperature, Electrocardiogram Sensor (ECG), Glucometer, Galvanic Skin
* Response Sensor (GSR - Sweating), Blood Pressure (Sphygmomanometer) and
* Patient Position (Accelerometer)."
Mobile App
The App shows the information the nodes are sending which contains the sensor data gathered. Smartphone app
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 25/79
GLCD
Get the Body Temperature Sensor
Blood pressure
Blood pressure sensor features
Blood pressure is the pressure of the blood in the arteries as it is pumped around the body by the heart. When your heart beats, it
contracts and pushes blood through the arteries to the rest of your body. This force creates pressure on the arteries. Blood
pressure is recorded as two numbersthe systolic pressure (as the heart beats) over the diastolic pressure (as the heart relaxes
between beats).
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 26/79
Monitoring blood pressure at home is important for many people, especially if you have high blood pressure. Blood pressure does
not stay the same all the time. It changes to meet your bodys needs. It is affected by various factors including body position,
breathing or emotional state, exercise and sleep. It is best to measure blood pressure when you are relaxed and sitting or lying
down.
Classification of blood pressure for adults (18 years and older)
Systolic (mm Hg) Diastolic (mm Hg)
Hypotension < 90 < 60
Desired 90119 6079
Prehypertension 120139 8089
Stage 1 Hypertension 140159 9099
Stage 2 Hypertension 160179 100109
Hypertensive Crisis 180 110
High blood pressure (hypertension) can lead to serious problems like heart attack, stroke or kidney disease. High blood pressure
usually does not have any symptoms, so you need to have your blood pressure checked regularly.
SPECIAL FEATURES:
Automatic measurement of systolic, diastolic and pulse with time & date
Large LCD screen with LED backlight
TOUCH PAD KEY
80 measurement results with time & date stored in the device
KEY SPECIFICATIONS
Measurement method:Oscillometric system
Display type Digital LCD 97mm [L] x 87mm [W]
Measuring range: Pressure 0-300 mmHg
Pulse 30~200 p/min
Measuring accuracy: Pressure3 mmHg
Pulse5%
Operating environment: Temperature 10-40
Relative humidity80%
Power source: 4 x AA batteries
Dimension: 150mm [L] x 110mm [W] x 65mm [H]
Weight: About 370g
Cuff size: 520mm [L] x 135mm [W]
Cuff range: 220mm [L] - 320mm [W]
The sensor must be used with an AC/DC power supply (included with the sensor)
Compatible with ehealth V1
The new Blood Pressure Sensor (Sphygmomanometer) is compatible with e-Health Sensor Shield version 1 using an adapter
cable.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 27/79
The connection of this sensor in other e-Health versions is very simple. You must use the GLCD connector and connect the device
as shown in the next picture.
This sensor only runs with the updated e-Health library. So it is necessary to follow the same next steps.
NOTE: The LCD, the sphygmomanometer and communication modules use the UART port and can't work simultaneously.
Connecting the sensor
Before start using the sphygmomanometer we need one measure at least in the memory of the blood pressure sensor. After that
we can get all the information contained in the device.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 28/79
Place the sphygmomanometer on your arm (biceps zone) as shown in the image below. Power the device.
Turn on the sphygmomanometer cuff (press ON button). The sensor will begin to make a measurement. After a few seconds the
result is shown in the sphygmomanometer screen.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 29/79
The blood pressure sensor will take a few moments to calculate the blood sugar reading. It will store the values in the memory.
In order to extract the data from the sphygmomanometer to the Arduino or Raspberry Pi, connect the cable as show in the picture.
NOTE: If you are using this sensor in other e-Health versions you must use an adapter cable.
You should view in the sphygmomanometer screen the message UUU, which indicates the correct connection.
Connect the jack terminal to the e-Health board blood pressure connector and the mini-USB terminal to the sphygmomanometer.
The cable is composed of two adapter cables as shown in the following image.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 30/79
In order to measure correctly, it is important to maintain the arm and the cuff in the correct position.
Do not make abrupt movements or the measure will be not reliable.
Library functions
Getting blood pressure data
Some parameters must be initialized to start using blood pressure sensor (sphygmomanometer). The next function initializes
some variables and reads the sphygmomanometer data.
Example:
{
eHealth.readBloodPressureSensor();
Serial.begin(115200);
}
The amount of data read is accessible with a another public function.
Example of use:
{
uint8_t numberOfData = eHealth.getBloodPressureLength();
Serial.print(F("Number of measures : "));
Serial.println(numberOfData, DEC);
delay(100);
}
The next functions return the values of systolic and diastolic pressure measured by the sphygmomanometer and stored in private
variables of the e-Health class.
Example of use:
{
int systolic = eHealth.getSystolicPressure(1);
int diastolic =eHealth.getDiastolicPressure(1);
}
The number that we give to the function in the variable i is the number of the measurement we want to obtain.
Example
Arduino
Upload the next code for seeing data in the serial monitor:
Show Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
* Body Temperature, Electrocardiogram Sensor (ECG), Glucometer, Galvanic Skin
* Response Sensor (GSR - Sweating), Blood Pressure (Sphygmomanometer) and
* Patient Position (Accelerometer)."
*
Upload the code and watch the Serial monitor.Here is the USB output using the Arduino IDE serial port terminal:
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 31/79
Raspberry Pi
Show Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
* Body Temperature, Electrocardiogram Sensor (ECG), Glucometer, Galvanic Skin
* Response Sensor (GSR - Sweating), Blood Pressure (Sphygmomanometer) and
* Patient Position (Accelerometer)."
*
* In this example we read the values in volts of EMG sensor and show
* these values in the serial monitor.
*
* Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version 2.0
* Author: Luis Martin & Ahmad Saad & Anartz Nuin
*/
//Include eHealth library
#include "eHealth.h"
void setup() {
Get the Blood Pressure Sensor (Sphygmomanometer) v2.0
Patient position and falls
Position sensor features
The Patient Position Sensor (Accelerometer) monitors five different patient positions (standing/sitting, supine, prone, left and
right.)
In many cases, it is necessary to monitor the body positions and movements made because of their relationships to particular
diseases (i.e., sleep apnea and restless legs syndrome). Analyzing movements during sleep also helps in determining sleep
quality and irregular sleeping patterns. The body position sensor could help also to detect fainting or falling of elderly people or
persons with disabilities.
eHealth Body Position Sensor uses a triple axis accelerometer to obtain the patient's position.
Features:
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 32/79
1.95 V to 3.6 V supply voltage
1.6 V to 3.6 V interface voltage
2g/4g/8g dynamically selectable full-scale
This accelerometer is packed with embedded functions with flexible user programmable options, configurable to two interrupt
pins.The accelerometer has user selectable full scales of 2g/4g/8g with high pass filtered data as well as non filtered data
available real-time.
Body positions:
Connecting the sensor
The body position sensor has only one and simple way of connection. Connect the ribbon cable with the body position sensor and
the e-Health board as show in the image below.
Place the tape around the chest and the connector placed down
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 33/79
Library functions
The e-Health library allows a simple programing way. With one simple function we can get the position of the patient and show it
in the serial monitor of the Arduino/RasberryPi or in the GLCD.
Initializing the sensor
Before start using the sensor, we have to initialize some parameters. Use the next function to configure the sensor.
Example:
{
eHealth.initPositionSensor();
}
Getting data
The next functions return the a value that represent the body position stored in private variables of the e-Health class.
Example:
{
uint8_t position = eHealth.getBodyPosition();
}
The position of the pacient
1 == Supine position.
2 == Left lateral decubitus.
3 == Rigth lateral decubitus.
4 == Prone position.
5 == Stand or sit position.
Printing Data
For representing the data in a easy way in the Arduino/RasberryPi serial monitor, e-health library, includes a printing function.
Example:
{
Serial.print("Current position : ");
uint8_t position = eHealth.getBodyPosition();
eHealth.printPosition(position);
}
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 34/79
Example
Arduino
Upload the next code for seeing data in the serial monitor:
Show Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
* Body Temperature, Electrocardiogram Sensor (ECG), Glucometer, Galvanic Skin
* Response Sensor (GSR - Sweating), Blood Pressure (Sphygmomanometer) and
* Patient Position (Accelerometer)."
*
* In this example with the body position sensor we measure
* the current body position of the patient and show it in the serial
* monitor.
*
* Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/> .
*
* Version 0.1
* Author: Ahmad Saad & Luis Martin
*/
#include <eHealth.h>
void setup() {
Serial.begin(115200);
eHealth.initPositionSensor();
}
void loop() {
Serial.print("Current position : ");
uint8_t position = eHealth.getBodyPosition();
eHealth.printPosition(position);
Serial.print("\n");
delay(1000); // wait for a second.
}
Upload the code and watch the Serial monitor.Here is the USB output using the Arduino IDE serial port terminal:
Raspberry Pi
Show Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
* Body Temperature, Electrocardiogram Sensor (ECG), Glucometer, Galvanic Skin
* Response Sensor (GSR - Sweating), Blood Pressure (Sphygmomanometer) and
* Patient Position (Accelerometer)."
*
* In this example we read the values in volts of EMG sensor and show
* these values in the serial monitor.
*
* Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version 2.0
* Author: Luis Martin & Ahmad Saad & Anartz Nuin
*/
//Include eHealth library
#include "eHealth.h"
void setup(){
eHealth.initPositionSensor();
}
void loop(){
printf("Current position : \n");
uint8_t position = eHealth.getBodyPosition();
eHealth.printPosition(position);
printf("\n");
delay(3000);
Mobile App
The App shows the information the nodes are sending which contains the sensor data gathered. Smartphone app
GLCD
The GLCD shows the information the nodes are sending which contains the sensor data gathered. GLCD
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 35/79
Get the Patient Position Sensor (Accelerometer)
Galvanic Skin Response (GSR)
GSR sensor features
Skin conductance, also known as galvanic skin response (GSR) is a method of measuring the electrical conductance of the skin,
which varies with its moisture level. This is of interest because the sweat glands are controlled by the sympathetic nervous
system, so moments of strong emotion, change the electrical resistance of the skin. Skin conductance is used as an indication of
psychological or physiological arousal, The Galvanic Skin Response Sensor (GSR - Sweating) measures the electrical
conductance between 2 points, and is essentially a type of ohmmeter.
In skin conductance response method, conductivity of skin is measured at fingers of the palm. The principle or theory behind
functioning of galvanic response sensor is to measure electrical skin resistance based on sweat produced by the body. When
high level of sweating takes place, the electrical skin resistance drops down. A dryer skin records much higher resistance. The
skin conductance response sensor measures the psycho galvanic reflex of the body. Emotions such as excitement, stress, shock,
etc. can result in the fluctuation of skin conductivity. Skin conductance measurement is one component of polygraph devices and
is used in scientific research of emotional or physiological arousal.
Sensor Calibration
The precision of the sensor is enough in most applications. But you can improve this precision by a calibration process.
When using temperature sensor, you are actually measuring a voltage, and relating that to what the operating temperature of the
sensor must be. If you can avoid errors in the voltage measurements, and represent the relationship between voltage and
temperature more accurately, you can get better temperature readings.
Calibration is a process of measuring real voltage values. In the eHealth.cpp file we can find getSkinConductance and
getSkinResistance functions. The value 0.5 is imprecisely defined by default.
If you measure this voltage value with a multimeter and modify the library will obtain greater accuracy.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 36/79
Place multimeter ends between 0.5V (Red cable) and GND (Black cable). In this case we would modify 0.5 to 0.498.
Connecting the sensor
Connect the to wires in the GSR contacts. The contacts have not polarization.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 37/79
The galvanic skin sensor has two contacts and it works like a ohmmeter measuring the resistance of the materials. Place your
fingers in the metallic contacts and tighten the velcro as shown in the image below.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 38/79
Library functions
Getting data
With this simple functions we can read the value of the sensor. The library returns the value of the skin resistance and the skin
conductance.
Example:
{
float conductance = eHealth.getSkinConductance();
float resistance = eHealth.getSkinResistance();
float conductanceVol = eHealth.getSkinConductanceVoltage();
}
Example
Upload the next code for seeing data in the serial monitor:
Show Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
* Body Temperature, Electrocardiogram Sensor (ECG), Glucometer, Galvanic Skin
* Response Sensor (GSR - Sweating), Blood Pressure (Sphygmomanometer) and
* Patient Position (Accelerometer)."
*
* In this example we use the skin sensor to measure some
* parameters like the skin resistance and coductance.
*
* Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/> .
*
* Version 2.0
* Author: Luis Martin & Ahmad Saad
*/
#include <eHealth.h>
Upload the code to Arduino and watch the Serial monitor.
Here is the USB output using the Arduino IDE serial port terminal:
Raspberry Pi
Compile the following code example:
Show Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
Mobile App
The App shows the information the nodes are sending which contains the sensor data gathered. Smartphone app
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 39/79
GLCD
The GLCD shows the information the nodes are sending which contains the sensor data gathered. GLCD
KST
KST program shows the GSR wave. KST
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 40/79
Get the Galvanic Skin Response Sensor (GSR - Sweating)
Glucometer
Glucometer sensor features
Glucometer is a medical device for determining the approximate concentration of glucose in the blood. A small drop of blood,
obtained by pricking the skin with a lancet, is placed on a disposable test strip that the meter reads and uses to calculate the
blood glucose level. The meter then displays the level in mg/dl or mmol/l.
Despite widely variable intervals between meals or the occasional consumption of meals with a substantial carbohydrate load,
human blood glucose levels tend to remain within the normal range. However, shortly after eating, the blood glucose level may
rise, in non-diabetics, temporarily up to 7.8 mmol/L (140 mg/dL) or a bit more.
Connecting the sensor
Before start using the glucometer we need one measure at least in the memory of the glucometer. After that we can get all the
information contained in the glucometer( date, glucose value).
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 41/79
Turn on the glucometer and place a test strip in the machine when the machine is ready. Watch the indicator for placing the blood
to the strip.
Clean the end of your index finger with rubbing alcohol before pricking it with an sterile needle or lancet.
NOTE: The needles or lancets are not provided.
Pierce your finger tip on the soft, fleshy pad and obtain a drop of blood. The type of drop of blood is determined by the type of strip
you are using
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 42/79
Place the drop of blood on or at the side of the strip.
The glucometer will take a few moments to calculate the blood sugar reading.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 43/79
The glucometer will store the value in the memory.
In order to extract the data from the glucometer to the Arduino or Raspberry Pi, connect the cable as show in the picture.
You should view in the glucometer screen the message P-C, that indicates the correct connection.
Library functions
Getting data
With a simple function we can read all the measures stored in the glucometer and show them in the terminal. The function must
be used before the intilizazion of the serial monitor.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 44/79
Example of use:
{
eHealth.readGlucometer();
Serial.begin(115200);
}
The amount of data read is accessible with a another public function.
Example of use:
{
uint8_t numberOfData eHealthClass.getGlucometerLength()
}
The maximum number of measures is 32. The vector where data is a public variable of the e-Health class.
Example of use:
{
Serial.print(F("Glucose value : "));
Serial.print(eHealth.glucoseDataVector[i].glucose);
Serial.println(F(" mg/dL"));
}
Example
Arduino
Upload the next code for seeing data in the serial monitor:
Show Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
* Body Temperature, Electrocardiogram Sensor (ECG), Glucometer, Galvanic Skin
* Response Sensor (GSR - Sweating), Blood Pressure (Sphygmomanometer) and
* Patient Position (Accelerometer)."
*
* In this example we are going to get data stored in the glucometer
* memory and show the result in the serial monitor.
*
* Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/> .
*
* Version 2.0
* Author: Ahmad Saad & Luis Martin
*/
#include <eHealth.h>
void setup() {
eHealth.readGlucometer();
Serial.begin(115200);
delay(100);
}
void loop() {
Upload the code and watch the Serial monitor.Here is the USB output using the Arduino IDE serial port terminal:
Raspberry Pi
Compile the following code:
Show Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
* Body Temperature, Electrocardiogram Sensor (ECG), Glucometer, Galvanic Skin
* Response Sensor (GSR - Sweating), Blood Pressure (Sphygmomanometer) and
* Patient Position (Accelerometer)."
*
* In this example we read the values in volts of EMG sensor and show
* these values in the serial monitor.
*
* Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Get the Glucometer Sensor
Electromyogram (EMG)
EMG sensor features
An electromyogram (EMG) measures the electrical activity of muscles at rest and during contraction.
Electromyography (EMG) is a technique for evaluating and recording the electrical activity produced by skeletal muscles. EMG is
performed using an instrument called an electromyograph, to produce a record called an electromyogram. An electromyograph
detects the electrical potential generated by muscle cells when these cells are electrically or neurologically activated. The signals
can be analyzed to detect medical abnormalities, activation level, recruitment order or to analyze the biomechanics of human or
animal movement.
EMG signals are used in many clinical and biomedical applications. EMG is used as a diagnostics tool for identifying
neuromuscular diseases, assessing low-back pain, kinesiology, and disorders of motor control. EMG signals are also used as a
control signal for prosthetic devices such as prosthetic hands, arms, and lower limbs.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 45/79
This sensor will measure the filtered and rectified electrical activity of a muscle, depending the amount of activity in the selected
muscle.
Features:
Adjustable gain
Small Form Factor
Full integrated
Use your muscles to control any type of actuator (motors, servos, lights ...). Interact with the environment with your own muscles.
This sensor comes with everything you need to start sensing muscle activity with your Arduino or Raspberry Pi.
Connecting the sensor
Connect the three leads (MID, END and GND) in the e-Health board.
Connect the EMG lead to the electrodes.
Adjustable Gain: You can adjust the EMG gain using the centered potenciometer in the top layer.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 46/79
Remove the protective plastic
This sensor use disposable pre-gelled electrodes.
These high quality disposable electrodes are to be used to measure EEG, ECG and EMG. They are to be used once and are very
handy because of integrated gel. They adhere very well to the skin and are clean to use.
The H124SG has a unique, patented pre-gelled adhesive side with non-irritating gel, especially developed to prevent allergic
reactions. These foam electrode is latex free and therefore suitable for every skin type.
The snap-on connector can easily be pushed on or removed from the electrode lead.
Place the electrodes as shown below.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 47/79
Library functions
Getting data
This EMG returns an analogic value in volts (read 0 1023 by the ADC) to represent the EMG wave form.
Example:
{
float EMG = eHealth.getEMG();
}
Example
Arduino
Upload the next code for seeing data in the serial monitor:
Show Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
Upload the code and watch the Serial monitor. Here is the USB output using the Arduino IDE serial port terminal:
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 48/79
Go to Index
Raspberry Pi
Show Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
* Body Temperature, Electrocardiogram Sensor (ECG), Glucometer, Galvanic Skin
* Response Sensor (GSR - Sweating), Blood Pressure (Sphygmomanometer) and
* Patient Position (Accelerometer)."
*
* In this example we read the values in volts of EMG sensor and show
* these values in the serial monitor.
*
* Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version 2.0
* Author: Luis Martin & Ahmad Saad & Anartz Nuin
*/
//Include eHealth library
#include "eHealth.h"
// The setup routine runs once when you press reset:
void setup() {
Serial.begin(115200);
}
// The loop routine runs over and over again forever:
void loop() {
KST
KST program shows the EMG wave. KST
Get the Electrocardiogram Sensor (EMG)
5. Visualizing the data
GLCD
The e-Health library includes functions to manage a graphic LCD for visualizing data. The Serial Graphic LCD backpack is
soldered to the 128x64 pixel Graphic LCD and provides the user a simple serial interface.
Features
Connecting the GLCD
You need to connect the device with the signals in the correct position. The red wire that powers the module shows how to connect
it.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 49/79
The sensor measures are distributed in three screens that change by pressing the button.
In the first screen we can see some values like temperature, pulse or oxygen.
In the second screen is used for presenting the air flow wave.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 50/79
When no respiration is detected, the screen will advise of a risq of apnea.
The last screen draws the ECG wave.
After the third screen, if you push the button again you will return to the first screen.
GLCD Library
The eHealth library includes all the necessary functions to manage the LCD and show in real time the data sensor measures. In
order to use this functions, before all, you should include the corresponding library.
#include < eHealthDisplay.h >
Library functions:
Initializing the LCD
Use the init function in the setup before start using the LCD.
Example:
{
eHealthDisplay.init();
}
Values Screen
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 51/79
In this screen you can see some numerical parameters like pulse, oxygen , temperature, amd a representation of the current body
position.
Initializing
This screen must be initialized with the next function:
Example:
{
eHealthDisplay.initValuesScreen();
}
Getting data
To refresh the values in the LCD execute the next function.
Example:
{
eHealthDisplay.printValuesScreen();
}
AirFlow screen
In this screen we could see the air flow (breathing) wave and the number of breathings per minute. This screen includes an apnea
adviser when no breathing is detected.
Initializing
This screen must be initialized with the next function:
Example:
{
eHealthDisplay.initAirFlowScreen();
}
Getting data
To refresh the values in the LCD execute the next function.
Example:
{
eHealthDisplay.printAirFlowScreen();
}
ECGScreen
This screen draws the electrocardiogram wave and measures the heart beat rate.
Initializing
This screen must be initialized with the next function:
Example:
{
eHealthDisplay.initECGScreen();
}
Getting data
To refresh the values in the LCD execute the next function.
Example:
{
eHealthDisplay.printECGScreen();
}
The push button
The eHealth board includes an integrated push button to change between the screen or it can be used like a general purpouse
button for any application. The push button is routed to the digital pin 4.
Example:
Arduino
Upload the next code for seeing data in the GLCD:
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 52/79
Show Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
* Body Temperature, Electrocardiogram Sensor (ECG), Glucometer, Galvanic Skin
* Response Sensor (GSR - Sweating), Blood Pressure (Sphygmomanometer) and
* Patient Position (Accelerometer)."
*
* In this example we can view all data measures in the LCD, choosing
* between 3 screens by a push button integrated in the eHealth board.
*
* Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version 2.0
* Author: Ahmad Saad & Luis Martin
*/
#include <PinChangeInt.h>
#include <eHealthDisplay.h>
#include <eHealth.h>
#define pushButton 4
uint8_t screenNumber = 1;
uint8_t buttonState;
uint8_t cont = 0;
void setup() {
Serial.begin(115200);
delay(100);
//Configure and initializes the LCD.
eHealthDisplay.init();
delay(100);
}
void loop() {
//Screen number one with the numerical sensor values and body position
//=========================================================================
eHealthDisplay.initValuesScreen();
delay(100);
//Attach the inttruptions for using the pulsioximeter
PCintPort::attachInterrupt(6, readPulsioximeter, RISING);
while(screenNumber == 1) {
//It prints data sensor measures in the LCD.
buttonState = digitalRead(pushButton);
delay(10);
if(buttonState == 1) {
screenNumber++;
}
eHealthDisplay.printValuesScreen();
}
The GLCD shows the information the nodes are sending which contains the sensor data gathered.
KST: Real-time data viewing and plotting
KST is the fastest real-time large-dataset viewing and plotting tool available (you may be interested in some benchmarks) and has
built-in data analysis functionality. It is very user-friendly and contains many powerful built-in features and is expandable with
plugins and extensions.
KST is licensed under the GPL, and is as such freely available for anyone. What's more, as of 2.0.x it is available on all of the
following platforms: Microsoft Windows, Linux, Mac OSX.
Before all, you have to install the KST program in your PC. You can downloaded the program from KST web page:
http://kst-plot.kde.org/
We are going to use KST for representing the ECG wave, airFlow and galvanic skin response.
Example code
This example is for Linux OS. It will represent different waves and data measured by e-Health sensor platform.
You can find more information about how to use KST on this video tutorial.
To begin working with our real-time data must first load the appropriate code in the Arduino.
As we will work with Linux we will use the console to save data to a file (.txt).
Plug in the device, and execute
stty -F /dev/ttyACM0 cs8 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon
-iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts
in console "A".
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 53/79
With this command we will configure the port ttyACM0.
Next, we use the command on the same console to create the text file where data will be stored.
tail -f /dev/ttyACM0 > Desktop/test.txt
The Arduino KST sample programs are ready to send data continuously when it receives a "C" and stop sending when it receive
an "F". These data will be sent by console "B" with commands:
echo 'C' > /dev/ttyACM0
echo 'F' > /dev/ttyACM0
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 54/79
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 55/79
1) In pop-up window select the directory where the .txt
previously created and press the Configure button.
2) The next step, is to configure the data source.
3) Select the measurement data. The data is
field/column 2.

Basic configuration
Now with the file created and updated with data received, we have to open the program KST.
To configure KST for each example, we will need to set common parameters.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 56/79

The final step is different depending on each example.
ECG example in KST
In this example we configure the KST to show a defined period of x time (x=300). We are interested only in the most current values
of the ECG.
The Arduino code used in this program is presented next:
Show Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
* Body Temperature, Electrocardiogram Sensor (ECG), Glucometer, Galvanic Skin
* Response Sensor (GSR - Sweating), Blood Pressure (Sphygmomanometer) and
EMG example in KST
In this example we configure the KST to show a defined period of x time (x=300). We are interested only in the most current values
of the EMG.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 57/79
The Arduino code used in this program is presented next:
Show Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
* Body Temperature, Electrocardiogram Sensor (ECG), Glucometer, Galvanic Skin
* Response Sensor (GSR - Sweating), Blood Pressure (Sphygmomanometer) and
* Patient Position (Accelerometer)."
*
* In this example we read the value of the EMG sensor and print the
* ECG wave form using KST.
*
* Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version 2.0
* Author: Luis Martin & Ahmad Saad
*/
#include <eHealth.h>
extern volatile unsigned long timer0_overflow_count;
float fanalog0;
int analog0;
unsigned long time;
byte serialByte;
void setup() {
Serial.begin(9600);
Serial.println("Starting...");
}
void loop() {
while (Serial.available()>0){
serialByte=Serial.read();
if (serialByte=='C'){
while(1){
analog0=eHealth.getEMG();
// Use the timer0 => 1 tick every 4 us
time=(timer0_overflow_count << 8) + TCNT0;
// Microseconds conversion.
time=(time*4);
Galvanic Skin Response example in KST
In the Galvanic Skin Response example we are interested in all the data from the start of measurement. We will configure the KST
to show a wave with all data.
Show Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
* Body Temperature, Electrocardiogram Sensor (ECG), Glucometer, Galvanic Skin
* Response Sensor (GSR - Sweating), Blood Pressure (Sphygmomanometer) and
* Patient Position (Accelerometer)."
*
* In this example we read the value of the GSR sensor
* and print the GSR wave form in the KST .
*
* Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version 2.0
* Author: Luis Martin & Ahmad Saad
*/
#include <eHealth.h>
extern volatile unsigned long timer0_overflow_count;
float fanalog0;
int analog0;
unsigned long time;
byte serialByte;
void setup() {
Serial.begin(9600);
Serial.println("Starting...");
}
void loop() {
while (Serial.available()>0){
serialByte=Serial.read();
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 58/79
AirFlow example in KST
We can configure the program according to the data we want to sample.
Serial Console
All data can be visualized in the serial monitor of Arduino/RasberryPi by using the next serial console program.
Load the example eHealth_SerialMenu program and open the serial monitor of Arduino IDE.
In the main menu we can find all e-Health sensors. By sending a command to the serial port we can select one of them.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 59/79
To view the sensor measures, send the corresponding command and press enter key.
You can return to the main menu by sending the command B.
NOTE:The measurement of glucose has not been implemented in this example because both processes use UART
communication and can cause malfunction
The Arduino code used in this program is presented next:
Hide Code
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 60/79
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
* Body Temperature, Electrocardiogram Sensor (ECG), Glucometer, Galvanic Skin
* Response Sensor (GSR - Sweating), Blood Pressure (Sphygmomanometer) and
* Patient Position (Accelerometer)."
*
* In this example we have used the serial monitor like a programed
* console where we can choose the sensor we want to view. *
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version 2.0
* Author: Ahmad Saad & Luis Martn
*/
#include <eHealth.h>
#include <PinChangeInt.h>
char serialByte;
uint8_t state = 0;
uint8_t cont = 0;
void setup()
{
eHealth.readGlucometer();
Serial.begin(115200);
initScreen();
delay(100);
}

void loop()
{
state = 0;

while (Serial.available()>0){
serialByte=Serial.read();

if ((serialByte=='A') || (serialByte == 'a')){ //Airflow sensor
airFlowMenu();
airFlowBucle();
} else if ((serialByte=='S') || (serialByte == 's')){
skinSensorMenu();
skinSensorBucle();

} else if ((serialByte=='E') || (serialByte == 'e')){
ECGMenu();
ECGBucle();

} else if ((serialByte=='P') || (serialByte == 'p')){
pulsioximeterMenu();
pulsioximeterBucle();

} else if ((serialByte=='B') || (serialByte == 'b')){
bodyPositionMenu();
bodyPositionBucle();

} else if ((serialByte=='T') || (serialByte == 't')){
temperatureMenu();
temperatureBucle();

25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 61/79
} else if ((serialByte=='N') || (serialByte == 'n')){
GlucometerMenu();
GlucometerBucle();
}
}
}

//=================================================================================================================
//=================================================================================================================
void initScreen(void)
{
printLogoEhealth();
delay(100);
mainMenu();
}
//=================================================================================================================
//=================================================================================================================
void mainMenu(void)
{
lineFeed(); Serial.print(F(" --------> EHEALTH MENU OPTIONS <--------")); lineFeed(); lineFeed();

initialSpace(); Serial.print(F("A : AirFlow sensor options")); lineFeed();
initialSpace(); Serial.print(F("S : Skin sensor options")); lineFeed();
initialSpace(); Serial.print(F("E : ECG sensor options")); lineFeed();
initialSpace(); Serial.print(F("P : Pulsioximeter sensor options")); lineFeed();
initialSpace(); Serial.print(F("B : Body position sensor options")); lineFeed();
initialSpace(); Serial.print(F("T : Temperature sensor options")); lineFeed();
initialSpace(); Serial.print(F("N : Glucometer sensor options"));lineFeed();
}
//=================================================================================================================
//=================================================================================================================
void airFlowMenu(void)
{
lineFeed(); Serial.print(F("--------> AIRFLOW MENU OPTIONS <--------")); lineFeed(); lineFeed();
initialSpace(); Serial.print(F("W : Wave form")); lineFeed();
initialSpace(); Serial.print(F("V : Analogic value")); lineFeed();
initialSpace(); Serial.print(F("B : BACK MAIN MENU")); lineFeed();
}
//=================================================================================================================
//=================================================================================================================
void airFlowBucle(void) {
while (state == 0) {
while (Serial.available()>0){
serialByte=Serial.read();
if ((serialByte=='W') || (serialByte == 'w')){ //Airflow sensor
while(1){
serialByte=Serial.read();
eHealth.airFlowWave(eHealth.getAirFlow());

if ((serialByte== 'B') || (serialByte == 'b')) {
airFlowMenu();
break;
}
}
} else if ((serialByte=='V') || (serialByte == 'v')){
while(1){
serialByte=Serial.read();
Serial.print(F(" Airflow analogic value : "));
Serial.println(eHealth.getAirFlow());
delay(20);
if ((serialByte== 'B') || (serialByte == 'b')) {
airFlowMenu();
break;
}
}
} else if ((serialByte=='B') || (serialByte == 'b')){
state = 1;
}
}
}
mainMenu();
}
//=================================================================================================================
//=================================================================================================================
void skinSensorMenu(void)
{
lineFeed(); Serial.print(F("--------> SKIN SENSOR MENU OPTIONS <--------")); lineFeed(); lineFeed();
outputMenu();
}
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 62/79
//=================================================================================================================
//=================================================================================================================
void skinSensorBucle(void) {
while (state == 0) {
while (Serial.available()>0){
serialByte=Serial.read();
if ((serialByte=='S') || (serialByte == 's')){
while(1){

lineFeed();

serialByte=Serial.read();
float conductance = eHealth.getSkinConductance();
long resistance = eHealth.getSkinResistance();
float conductanceVoltage = eHealth.getSkinConductanceVoltage();
if (conductance == -1) {
Serial.println(" No patient connection");
} else {

Serial.print(F(" Skin conductance value : "));
Serial.println(conductance);

Serial.print(F(" Skin resistance value : "));
Serial.println(resistance);

Serial.print(F(" Skin conductance value in volts: "));
Serial.println(conductanceVoltage);

delay(500);
}

if ((serialByte== 'B') || (serialByte == 'b')) {
skinSensorMenu();
break;
}
}

} else if ((serialByte=='B') || (serialByte == 'b')){
state = 1;
}
}
}
mainMenu();
}
//=================================================================================================================
//=================================================================================================================
void ECGMenu(void) {
lineFeed(); Serial.print(F("--------> ECG MENU OPTIONS <--------")); lineFeed(); lineFeed();
outputMenu();
}
//=================================================================================================================
//=================================================================================================================
void ECGBucle(void) {
while (state == 0) {
while (Serial.available()>0){
serialByte=Serial.read();
if ((serialByte=='S') || (serialByte == 's')){
while(1){

lineFeed();
serialByte=Serial.read();
delay(500);

if ((serialByte== 'B') || (serialByte == 'b')) {
ECGMenu();
break;
}
}
} else if ((serialByte=='B') || (serialByte == 'b')){
state = 1;
}
}
}
mainMenu();
}
//=================================================================================================================
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 63/79
//=================================================================================================================
void pulsioximeterMenu(void)
{
lineFeed(); Serial.print(F("--------> PULSIOXIMETER MENU OPTIONS <--------")); lineFeed(); lineFeed();
outputMenu();
}
//=================================================================================================================
//=================================================================================================================
void pulsioximeterBucle(void)
{
//Attach the interruptions for using the pulsioximeter.
PCintPort::attachInterrupt(6, readPulsioximeter, RISING);
eHealth.initPulsioximeter();
while (state == 0) {
while (Serial.available()>0){
serialByte=Serial.read();
if ((serialByte=='S') || (serialByte == 's')){
while(1){

//eHealth.readPulsioximeter();
lineFeed();
serialByte=Serial.read();
Serial.print("PRbpm : ");
Serial.print(eHealth.getOxygenSaturation());
Serial.print(" % SPo2 : ");
Serial.print(eHealth.getBPM());

Serial.print("\n");
delay(500);

if ((serialByte== 'B') || (serialByte == 'b')) {
pulsioximeterMenu();
break;
}
}
} else if ((serialByte=='B') || (serialByte == 'b')){
state = 1;
}
}
}
mainMenu();

PCintPort::detachInterrupt(6);
}
//=================================================================================================================
//=================================================================================================================
void bodyPositionMenu(void)
{
lineFeed(); Serial.print(F("--------> BODY POSTITIONMENU OPTIONS <--------")); lineFeed(); lineFeed();
outputMenu();
}
//=================================================================================================================
//=================================================================================================================
void bodyPositionBucle(void)
{
while (state == 0) {
while (Serial.available()>0){
eHealth.initPositionSensor();
serialByte=Serial.read();
if ((serialByte=='S') || (serialByte == 's')){
while(1){

lineFeed();
serialByte=Serial.read();

Serial.print("Current position : ");
uint8_t position = eHealth.getBodyPosition();
eHealth.printPosition(position);
delay(100);

if ((serialByte== 'B') || (serialByte == 'b')) {
bodyPositionMenu();
break;
}
}
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 64/79
} else if ((serialByte=='B') || (serialByte == 'b')){
state = 1;
}
}
}
mainMenu();
}
//=================================================================================================================
//=================================================================================================================
void temperatureMenu(void)
{
lineFeed(); Serial.print(F("--------> TEMPERATURE MENU OPTIONS <--------")); lineFeed(); lineFeed();
outputMenu();
}
//=================================================================================================================
//=================================================================================================================
void temperatureBucle(void)
{
while (state == 0) {
while (Serial.available()>0){
serialByte=Serial.read();
if ((serialByte=='S') || (serialByte == 's')){
while(1){

lineFeed();
serialByte=Serial.read();

float temperature = eHealth.getTemperature();
Serial.print("Temperature (C): ");
Serial.println(temperature, 2);

delay(1000);

if ((serialByte== 'B') || (serialByte == 'b')) {
temperatureMenu();
break;
}
}
} else if ((serialByte=='B') || (serialByte == 'b')){
state = 1;
}
}
}
mainMenu();
}
//=================================================================================================================
//=================================================================================================================
void GlucometerMenu(void)
{
lineFeed(); Serial.print(F("--------> GLUCOMETER MENU OPTIONS <--------")); lineFeed(); lineFeed();
outputMenu();
}
//=================================================================================================================
//=================================================================================================================
void GlucometerBucle()
{
while (state == 0) {
while (Serial.available()>0){
serialByte=Serial.read();
if ((serialByte=='S') || (serialByte == 's')){
while(1){

lineFeed();
serialByte=Serial.read();
uint8_t numberOfData = eHealth.getGlucometerLength();
Serial.print(F("Number of measures : "));
Serial.println(numberOfData, DEC);
delay(100);
for (int i = 0; i<numberOfData; i++) {
// The protocol sends data in this order
Serial.println(F("=========================================="));
Serial.print(F("Measure number "));
Serial.println(i + 1);
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 65/79
Serial.print(F("Date -> "));
Serial.print(eHealth.glucoseDataVector[i].day);
Serial.print(F(" of "));
Serial.print(eHealth.numberToMonth(eHealth.glucoseDataVector[i].month));
Serial.print(F(" of "));
Serial.print(2000 + eHealth.glucoseDataVector[i].year);
Serial.print(F(" at "));
if (eHealth.glucoseDataVector[i].hour < 10) {
Serial.print(0); // Only for best representation.
}
Serial.print(eHealth.glucoseDataVector[i].hour);
Serial.print(F(":"));
if (eHealth.glucoseDataVector[i].minutes < 10) {
Serial.print(0);// Only for best representation.
}
Serial.print(eHealth.glucoseDataVector[i].minutes);
if (eHealth.glucoseDataVector[i].meridian == 0xBB)
Serial.println(F(" pm"));
else if (eHealth.glucoseDataVector[i].meridian == 0xAA)
Serial.println(F(" am"));
Serial.print(F("Glucose value : "));
Serial.print(eHealth.glucoseDataVector[i].glucose);
Serial.println(F(" mg/dL"));
}
delay(1000);

if ((serialByte== 'B') || (serialByte == 'b')) {
GlucometerMenu();
break;
}
}
} else if ((serialByte=='B') || (serialByte == 'b')){
state = 1;
}
}
}
mainMenu();
}

//=================================================================================================================
//=================================================================================================================
void outputMenu(void) {
initialSpace(); Serial.print(F("S : Serial output value")); lineFeed();
initialSpace(); Serial.print(F("B : BACK MAIN MENU")); lineFeed();
}
//=================================================================================================================
//=================================================================================================================
void printLogoEhealth(void)
{
starLine();
starPrint(); blank(); HLeterOne(); blank(); blank(); blank(); tLeterOne(); hLeterOne(); starPrint(); lineFeed();
starPrint(); eLeterTwo(); HLeterTwo(); eLeterTwo(); aLeterTwo(); lLeterTwo(); tLeterTwo(); hLeterTwo(); starPrint(); lineFeed();
starPrint(); eLeterThree(); HLeterThree(); eLeterThree(); aLeterThree(); lLeterThree(); tLeterThree(); hLeterThree(); starPrint(); lineFeed();
starPrint(); eLeterFour(); HLeterFour(); eLeterFour(); aLeterFour(); lLeterFour(); tLeterFour(); hLeterFour(); starPrint(); lineFeed();
starPrint(); eLeterFive(); HLeterFive(); eLeterFive(); aLeterFive(); lLeterFive(); tLeterFive(); hLeterFive(); starPrint(); lineFeed();
starPrint(); eLeterSix(); HLeterSix(); eLeterSix(); aLeterSix(); lLeterSix(); tLeterSix(); hLeterSix(); starPrint(); lineFeed();
starLine();
}
//=================================================================================================================
//=================================================================================================================
void eLeterTwo(void) { Serial.print(F(" _____ ")); }
void eLeterThree(void) { Serial.print(F("| __ | ")); }
void eLeterFour(void) { Serial.print(F("| ___| ")); }
void eLeterFive(void) { Serial.print(F("| |___ ")); }
void eLeterSix(void) { Serial.print(F("|_____| ")); }

void HLeterOne(void) { Serial.print(F(" _ _ ")); }
void HLeterTwo(void) { Serial.print(F("| | | | ")); }
void HLeterThree(void) { Serial.print(F("| |__| | ")); }
void HLeterFour(void) { Serial.print(F("| __ | ")); }
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 66/79
void HLeterFive(void) { Serial.print(F("| | | | ")); }
void HLeterSix(void) { Serial.print(F("|_| |_| ")); }

void aLeterTwo(void) { Serial.print(F(" ______ ")); }
void aLeterThree(void) { Serial.print(F("| | ")); }
void aLeterFour(void) { Serial.print(F("| {} | ")); }
void aLeterFive(void) { Serial.print(F("| __ | ")); }
void aLeterSix(void) { Serial.print(F("|_| |_| ")); }

void lLeterTwo(void) { Serial.print(F(" _ ")); }
void lLeterThree(void) { Serial.print(F("| | ")); }
void lLeterFour(void) { Serial.print(F("| | ")); }
void lLeterFive(void) { Serial.print(F("| |____ ")); }
void lLeterSix(void) { Serial.print(F("|______|")); }

void tLeterOne(void) { Serial.print(F(" _ "));}
void tLeterTwo(void) { Serial.print(F(" _| |__ ")); }
void tLeterThree(void) { Serial.print(F("(_ __) ")); }
void tLeterFour(void) { Serial.print(F(" | | ")); }
void tLeterFive(void) { Serial.print(F(" | |__ ")); }
void tLeterSix(void) { Serial.print(F(" |____) ")); }

void hLeterOne(void) { Serial.print(F(" _ "));}
void hLeterTwo(void) { Serial.print(F("| | ")); }
void hLeterThree(void) { Serial.print(F("| |___ ")); }
void hLeterFour(void) { Serial.print(F("| _ | ")); }
void hLeterFive(void) { Serial.print(F("| | | | ")); }
void hLeterSix(void) { Serial.print(F("|_| |_| ")); }
//=================================================================================================================
//=================================================================================================================

void blank(void) { Serial.print(F(" "));}
//=================================================================================================================
//=================================================================================================================
void initialSpace(void)
{
Serial.print(F(" "));
}
//=================================================================================================================
//=================================================================================================================
void starPrint(void)
{
Serial.print(F("* "));
}
//=================================================================================================================
//=================================================================================================================
void lineFeed(void)
{
Serial.print(F("\n"));
}
//=================================================================================================================
//=================================================================================================================
void starLine(void)
{
for (int i = 0; i< 63; i++)
{
Serial.print(F("*"));
}
lineFeed();
}
//=================================================================================================================
//=================================================================================================================
int freeRam () {
extern int __heap_start, *__brkval;
int v;
return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}
//=================================================================================================================
//=================================================================================================================
//Include always this code for using the pulsioximeter sensor
//=========================================================================
void readPulsioximeter(){

25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 67/79
cont ++;

if (cont == 30) { //Get only one of 30 measures to reduce the latency
eHealth.readPulsioximeter();
cont = 0;
}
}
SmartPhone Application
The wifi module may perform direct communications with iPhone and Android devices without the need of an intermediate router
by creating an Adhoc network between them.
We have developed the application e-Health Sensor Plattform, for both iPhone and Android platforms. The application may be also
downloaded from the official App markets or from the Libelium website for free: http://www.cooking-hacks.com/apps
Official app markets URLs:

Connecting to an iPhone
Installation:
a) Download the application from App Store:
b) Download the application (e-Health.ipa) from the Libelium website: http://www.libelium.com/apps
Then double click on the icon, or right click and open with iTunes.
Inside iTunes, on the left panel, click on DEVICES->Your Device.
Select on the top Apps, and select Sync Apps. Drag into the desired screen e-Health app.
Once installed, the app appears in your iPhone/iPod screen.
iPhone app tutorial
The use of the app is very simple, first you have to connect to one of the Arduino nodes selecting it in Settings->Wi-Fi, and then
launch the application.
To connect to the network created by the wifi module of Arduino: Go to Settings->Wi-Fi and select iPHONE_ADHOC.

Once connected, you can launch the App.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 68/79

The App shows the information the nodes are sending which contains the sensor data gathered.
The first tab Charts shows:
The Current data tab, shows data that is in continuous change:

The Tests tab shows the information about:
Finally, in the Movement tab shows the position of the body.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 69/79

NOTE:The measurement of glucose and blood pressure data has not been implemented in this example because both
processes use UART communication and can cause malfunction
Example
Arduino
The Arduino code used in this program is presented next:
Hide Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
* Body Temperature, Electrocardiogram Sensor (ECG), Glucometer, Galvanic Skin
* Response Sensor (GSR - Sweating), Blood Pressure (Sphygmomanometer) and
* Patient Position (Accelerometer)."
*
* Explanation: This example shows the way to communicate with
* the Arduino Wifi Demo iPhone app.
*
* Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Version 0.1
* Author: Luis Martin & Ahmad Saad
*/

#include < PinChangeInt.h >
#include < eHealth.h >
char recv[256];
float parameter = 0.098;
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 70/79
uint8_t cont = 0;
void setup(){
//eHealth.readGlucometer();
Serial.begin(9600);
eHealth.initPulsioximeter();
eHealth.initPositionSensor();
}
void loop(){
Serial.print("$$$");
check();
// 1. Configure the transport protocol (UDP, TCP, FTP, HTTP...)
Serial.print("set i p 3\r"); check();
// 2. Configure the way the modules will resolve the IP address.
Serial.print("set i d 2\r"); check();
// 3. Configure how to connect the AP.
Serial.print("set w a 6\r"); check();
// 3.1 Sets the name of the ADhoc network.
Serial.print("set w s iPHONE_ADHOC\r"); check();
// 3.2 Sets the channel of the ADhoc network
Serial.print("set w c 6\r"); check();
Serial.print("set w j 4\r"); check();
Serial.print("save\r"); check();
Serial.print("exit\r"); check();
Serial.print("$$$"); check();
// Configures UDP host and ports.
Serial.print("set i h 255.255.255.255\r"); check();
Serial.print("set i r 12345\r"); check();
Serial.print("set i l 2000\r"); check();
// Checks if everything is Ok, even if It's correctly connected.
// Exits from command mode, and then the UDP messages
// can be sent and received.
Serial.print("exit\r");
check();
//Attach the inttruptions for using the pulsioximeter.
PCintPort::attachInterrupt(6, readPulsioximeter, RISING);
delay(1000);
while(1){
eHealth.initBloodPressureSensor(0.1);
//1. Read from eHealth.
int airFlow = eHealth.getAirFlow();
float temperature = eHealth.getTemperature();
float conductance = eHealth.getSkinConductance();
float resistance = eHealth.getSkinResistance();
float conductanceVol = eHealth.getSkinConductanceVoltage();
int BPM = eHealth.getBPM();
int SPO2 = eHealth.getOxygenSaturation();
uint8_t pos = eHealth.getBodyPosition();
int syst = eHealth.getSystolicPressure();
int diast = eHealth.getDiastolicPressure();
float ECG = eHealth.getECG();
//uint8_t glucose = eHealth.glucoseDataVector[0].glucose;
// 2. Send data to the Android smartphone
Serial.print(int(airFlow)); Serial.print("#");
Serial.print(ECG); Serial.print("#");
Serial.print(temperature); Serial.print("#");
Serial.print(int(BPM)); Serial.print("#");
Serial.print(int(SPO2)); Serial.print("#");
Serial.print(conductance); Serial.print("#");
Serial.print(int(resistance)); Serial.print("#");
Serial.print(int(airFlow)); Serial.print("#");
Serial.print(syst); Serial.print("#");
Serial.print(diast); Serial.print("#");
Serial.print(int(0)); Serial.print("#");
Serial.print(int(pos)); Serial.print("#");
Serial.print("\n");
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 71/79

// Reduce this delay for more data rate
delay(100);
}
}
//=========================================================================
void check(){
cont=0;
delay(500);
while (Serial.available()>0)
{
recv[cont]=Serial.read();
delay(10);
cont++;
}
recv[cont]='\0';
Serial.println(recv);
Serial.flush();
delay(100);
}
//Include always this code when using the pulsioximeter sensor
//=========================================================================
void readPulsioximeter(){
cont ++;
if (cont == 50) { //Get only one 50 measures to reduce the latency
eHealth.readPulsioximeter();
cont = 0;
}
}
Connecting to an Android
Installation:
a) Download the application from Android Market:
b) Download the application () from Libelium website: http://www.libelium.com/apps
Once installed, the app appears in your device screen.
Android app tutorial
The use of the app is very simple, first you have to create an AP from your Android device and then set Waspmote to connect to it.
To create the AP from the Android device:
Go to Settings->Tethering & Portable Hotspot or Settings->Wifi-> My Wifi Zone (depending of the version of mobile).
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 72/79
Then configure the WLAN hotspot (name= ANDROID, Security= None).
Finally, enable Portable WLAN hotspot (or My Wifi Zone), and Arduino will connect to the Android device. Once connected, you can
launch the e-Health App.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 73/79

The App shows the information the nodes are sending which contains the sensor data gathered.
The first tab Charts shows:
The Current data tab, shows data that is in continuous change:
The Tests tab shows the information about:
Finally, in the Movement tab shows the position of the body.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 74/79
Go to Index
NOTE: The measurement of glucose has not been implemented in this example because both processes use UART
communication and can cause malfunction
Example
Arduino
The Arduino code used in this program is presented next:
Show Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
* Body Temperature, Electrocardiogram Sensor (ECG), Glucometer, Galvanic Skin
* Response Sensor (GSR - Sweating), Blood Pressure (Sphygmomanometer) and
* Patient Position (Accelerometer)."
*
* Explanation: This example shows the way to communicate with
* the Arduino Wifi Demo Android app.
*
* Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Version 0.1
* Author: Luis Martin & Ahmad Saad
*/


#include < PinChangeInt.h >
#include < eHealth.h >
6. Sending the data to the Cloud.
Telemedicine is the use of telecommunication and information technologies in order to provide clinical health care at a distance. It
helps eliminate distance barriers and can improve access to medical services that would often not be consistently available in
distant rural communities. It is also used to save lives in critical care and emergency situations.
Although there were distant precursors to telemedicine, it is essentially a product of 20th century telecommunication and
information technologies. These technologies permit communications between patient and medical staff with both convenience
and fidelity, as well as the transmission of medical, imaging and health informatics data from one site to another.
eHealth Sensor platform allows to share medical data with the cloud, and perform real-time diagnosis. Thanks to many
communications modules can send data over several transmission protocols
Wifi
We will use the wifi module Roving RN-171. This module fits in the XBee socket of our Communication Shield and allows to
connect your Arduino/RasberryPi shield to a WiFi network.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 75/79
Example code
Wifi examples shows the way to communicate with the Arduino Wifi Demo Android and iPhone app.
Refer to Wifi tutorials (Arduino) (Raspberry) for more information.
Bluetooth
Bluetooth Modules for Arduino/Raspberry are able to be plugged into the XBee Shield and get a serial communication between the
computer and an Arduino/RasberryPi board through Bluetooth protocol.
Bluetooth module PRO for Arduino supports Serial Port Profile (SPP) to exchange data with other devices. This profile allows to
create connections to another device using the same profile (p2p connection). It sends data to the specified device. This device is
the one which the connection has been created to.
Refer to Bluetooth tutorials (Arduino) (Raspberry) for more information.
Zigbee / 802.15.4
The Arduino Xbee shield allows your Arduino/RasberryPi board to communicate wirelessly using Zigbee.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 76/79
Example code
This example shows the way to communicate with the Arduino using Zigbee protocol. Upload the next code:
Show Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
* Body Temperature, Electrocardiogram Sensor (ECG), Glucometer, Galvanic Skin
* Response Sensor (GSR - Sweating), Blood Pressure (Sphygmomanometer) and
* Patient Position (Accelerometer)."
*
* Explanation: This example shows the way to communicate with
* the Arduino using ZigBee protocol.
*
* Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version 2.0
* Author: Luis Martin & Ahmad Saad
*/


#include <PinChangeInt.h>
#include <eHealth.h>
char recv[128];
uint8_t cont = 0;
// Note : The Xbee modules must be configured previously.
// See the next link http://www.cooking-hacks.com/index.php/documentation/tutorials/arduino-xbee-shield
void setup()
{
NOTE: The Xbee modules must be configured previously. See the next link: Arduino XBee Shield Tutorial
Refer to XBee tutorials (Arduino) (Raspberry) for more information.
GPRS
GPRS Quadband Module for Arduino/Raspberry (SIM900) offers GPRS connection to your Arduino/RasberryPi board. You can
send your data by SMS or do missed calls from your Arduino to mobile devices... or to another Arduino/RasberryPi connected to
this module.
Example code
This example shows the way to send a text message with the corporal temperature using the GPRS module. Upload the next
code:
Show Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
* Body Temperature, Electrocardiogram Sensor (ECG), Glucometer, Galvanic Skin
* Response Sensor (GSR - Sweating), Blood Pressure (Sphygmomanometer) and
Refer to GPRS tutorials (Arduino) (Raspberry) for more information.
3G
The new 3G shield for Arduino/Raspberry enables the connectivity to high speed WCDMA and HSPA cellular networks in order to
make possible the creation of the next level of worldwide interactivity projects inside the new "Internet of Things" era.
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 77/79
Example code
This example how to send data using 3G shield and making a connection to a server. Upload the next code:
Show Code
/*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
* Body Temperature, Electrocardiogram Sensor (ECG), Glucometer, Galvanic Skin
* Response Sensor (GSR - Sweating), Blood Pressure (Sphygmomanometer) and
* Patient Position (Accelerometer)."
*
* Explanation: This example how to send data using 3G shield and
* making a connection to a server.
*
* Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version 2.0
* Author: Ahmad Saad & Luis Martin
*/
// For more information about the 3G shield please see our tutorial
// in cooking-hacks web site. http://www.cooking-hacks.com
#include <eHealth.h>
char data[512];
char tosend[128];
int led = 13;
int onModulePin = 2; // the pin to switch on the module (without press on button)
int x = 0;
char name[20];
char server[ ]="192.198.1.1"; //Your server IP address
char port[ ]="5555"; // Your port.
void switchModule(){
digitalWrite(onModulePin,HIGH);
delay(2000);
digitalWrite(onModulePin,LOW);
NOTE: If you want to use the 3G module with the e-Health platform you must wire the ON 3G pin (digital 2) to an available
digital pin in Arduino and power the e-Health board with a wire between Arduino and the shield (3V3).
Camera for Photo Diagnosis
This module allows to connect a camera for video recording and taking photos. Once saved the video or image file can be sent to
an FTP or FTPS as you'll see later. Images with 3G Module tutorial.
Camera for the 3G shield
Insert the camera with metallic contacts facing up
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 78/79
Go to Index
Go to Index
Tweet Like
Example Code
Take photos is very easy. Upload the next code.
Show Code
/*
* Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Version 0.1
* Author: Alejandro Gllego
*/
int led = 13;
int onModulePin = 2; // the pin to switch on the module (without press on button)
int x = 0;
char name[20];
void switchModule(){
digitalWrite(onModulePin,HIGH);
delay(2000);
digitalWrite(onModulePin,LOW);
}
void setup(){
Serial.begin(115200); // UART baud rate
delay(2000);
pinMode(led, OUTPUT);
pinMode(onModulePin, OUTPUT);
switchModule(); // switches the module ON
for (int i=0;i < 5;i++){
delay(5000);
}
Example picture 1: (Snake bite telemedicine simulation)
Example picture 2: (Patient photo)
Snake bites occur when a snake bites the skin. They are medical emergencies if the snake is poisonous.
Sending images via 3g is a simple and rapid method for medical consultation
Refer to 3G tutorials (Arduino) (Raspberry) for more information.
7. Forum.
There is a forum available in which you can get support for e-Health platform.
8. Get the shields and sensors.
Kit
e-Health Sensors Shield
e-Health Sensor Platform Complete Kit
Sensors
Patient Position Sensor (Accelerometer)
Glucometer Sensor
Body Temperature Sensor
Blood Pressure Sensor (Sphygmomanometer) V2.0
Pulse and Oxygen in Blood Sensor (SPO2)
Airflow Sensor (Breathing)
Galvanic Skin Response Sensor (GSR - Sweating)
Electrocardiogram Sensor (ECG)
Electromyography Sensor (EMG)
60
25/11/13 e-Health Sensor Platform V2.0 for Arduino and Raspberry Pi [Biometric / Medical Applications]
www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical?utm_source=banner_ehealth&utm_me 79/79

<< Back to "Documentation Index"

Vous aimerez peut-être aussi