- All orders placed from 12/30/2014 at 9PM (CET) onwards will be billed dated 2015 -
libelium
  • rss
  • flickr
  • instagram
  • twitter
  • facebook
  • youtube

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:

    • 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_application_example

e-Health Sensor Shield over Arduino (left) Raspberry Pi (right)

e-Health_all_elements

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 70 sensors available to use and a low consumption mode of just 0.7uA to ensure years of battery life. Know more at:

Get the shields and sensors

Kit

Sensors

Article Index

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

e-Health front e-Health front

Schematics

Download the e-Health Schematics

e-Health shield over Arduino

arduino_e_health
e-Health shield over Arduino

The shields:

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.

raspberry_e_heatlh
e-Health raspberry pi

The shields:

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:

Using the library with Arduino

The eHealth sensor platform includes a high level library functions for a easy manage of the board. 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 (important: V2.3 July 2014, only for eHealth kit with SPO2 model B [Yellow Sticker] )

You must download the library depending on the date of purchase.

Download the e-Health library for Arduino (important: V2.2 Juny 2014 version, SPO2 function modified)

Download the e-Health library for Arduino (important: V2.1 January 2014 version, with special function for SPO2 sensor)

Download the e-Health library for Arduino (important: V2.0 2013 version)

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 (important: V2.3 July 2014, only for eHealth kit with SPO2 model B [Yellow Sticker] )

You must download the library depending on the date of purchase.

Download the e-Health Libraries for Raspberry (important: V2.0 2013 version)

Creating a program that uses the library is as simple as putting your code in this template where it says "your arduino code here"

//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.
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.

pulsometro

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.

ehealth_y_pulsometro

Insert your finger into the sensor and press ON button.

pulsometro_dedo

After a few seconds you will get the values in the sensor screen.

pulsometro
Library functions

Initializing

This sensor use interruptions and it is necessary to include a special library when you are going to use it.

#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:

/*
 *  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
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *  Version 2.0
 *  Author: Ahmad Saad & Luis Martin
 */


#include <PinChangeInt.h>
#include <eHealth.h>

int cont = 0;

void setup() {
  Serial.begin(115200);  
  eHealth.initPulsioximeter();

  //Attach the inttruptions for using the pulsioximeter.   
  PCintPort::attachInterrupt(6, readPulsioximeter, RISING);
}

void loop() {

  Serial.print("PRbpm : "); 
  Serial.print(eHealth.getBPM());

  Serial.print("    %SPo2 : ");
  Serial.print(eHealth.getOxygenSaturation());

  Serial.print("\n");  
  Serial.println("============================="); 
  delay(500);
}


//Include always this code when using the pulsioximeter sensor
//=========================================================================
void readPulsioximeter(){  

  cont ++;

  if (cont == 50) { //Get only of one 50 measures to reduce the latency
    eHealth.readPulsioximeter();  
    cont = 0;
  }
}

Upload the code to Arduino and watch the Serial monitor.Here is the USB output using the Arduino IDE serial port terminal:

pulsioximetro_arduino

Raspberry Pi

/*
 *  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"

int cont = 0;

void readPulsioximeter();

void setup() { 

	eHealth.initPulsioximeter();
	//Attach the inttruptions for using the pulsioximeter.
	attachInterrupt(6, readPulsioximeter, RISING);
    
}

void loop() { 

  printf("PRbpm : %d",eHealth.getBPM()); 

  printf("    %%SPo2 : %d\n", eHealth.getOxygenSaturation());

  printf("=============================");
  
  digitalWrite(2,HIGH);
  
  delay(500);
  
}

void readPulsioximeter(){  

  cont ++;
  if (cont == 500) { //Get only of one 50 measures to reduce the latency
    eHealth.readPulsioximeter();  
    cont = 0;
  }
}

int main (){
	setup();
	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

iphone_app

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

sinus_rhythmlabels
Connecting the sensor

Connect the three leads (positive, negative and neutral) in the e-Health board.

parches ehealth parches ehealth

Connect the ECG lead to the electrodes.

Remove the protective plastic

Place the electrodes as shown below

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:

/*
 *  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.
 *
 *  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>

// 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() {

  float ECG = eHealth.getECG();

  Serial.print("ECG value :  ");
  Serial.print(ECG, 2); 
  Serial.print(" V"); 
  Serial.println(""); 

  delay(1);	// wait for a millisecond
}

Upload the code and watch the Serial monitor. Here is the USB output using the Arduino IDE serial port terminal:

Raspberry Pi

/*
 *  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 loop routine runs over and over again forever:
void loop() {

  float ECG = eHealth.getECG();

  printf("ECG value :  %f V\n",ECG);
  delay(1000);
}

int main (){
	//setup();
	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

pantalla5

KST

KST program shows the ECG wave. KST

ecg_measure

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 15–30 breaths per minute.

air_glow
Connecting the sensor

The e-Health AirFlow sensor have two connections (positive and negative)

e-Health_button2-01

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).

e_health_canula_conectando

After connecting the cables, tighten the screws

canula+e_health

Place the sensor as shown in the picture below

montaje_luis_canula_airflow
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:

/*
 *  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 air flow sensor 
 *  and print the air Flow wave form 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 
 */


#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() {

  int air = eHealth.getAirFlow();   
  eHealth.airFlowWave(air);  
}

Upload the code and watch the Serial monitor.Here is the USB output using the Arduino IDE serial port terminal:

Raspberry Pi

Compile this example 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

breathing_measure

KST

KST program shows the airflow wave. KST

breathing_measure

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.0°C (98.6°F). In healthy adults, body temperature fluctuates about 0.5°C (0.9°F) 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.

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.5–37.5 °C (97.7–99.5 °F)
Fever or Hyperthermia >37.5–38.3 °C (99.5–100.9 °F)
Hyperpyrexia >40.0–41.5 °C (104–106.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.

e-Health_button3-01

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)...

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

Make contact between the metallic part and your skin

Use a piece of adhesive tape to hold the sensor attached to the skin

tmp
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:

/*
 *  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>

// 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() {
  float temperature = eHealth.getTemperature();

  Serial.print("Temperature (ºC): ");       
  Serial.print(temperature, 2);  
  Serial.println(""); 

  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:

Ejemplo_Temperatura_

Raspberry Pi

Compile the following example 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() { 
	float temperature = eHealth.getTemperature();   
	printf("Temperature : %f \n", temperature);
	delay(2000);
}

int main (){
	//setup();
	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

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 numbers—the systolic pressure (as the heart beats) over the diastolic pressure (as the heart relaxes between beats).

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 body’s 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 90–119 60–79
Prehypertension 120–139 80–89
Stage 1 Hypertension 140–159 90–99
Stage 2 Hypertension 160–179 100–109
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: Pressure≤±3 mmHg
  • Pulse≤5%
  • Operating environment: Temperature 10-40℃
  • Relative humidity≤80%
  • 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.

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.

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.

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.

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

NOTE: You can modify the library in order to read more data. With some sketches, the buffer of the UART may be small, to increase the length of the buffer you need to change these lines in the file HardwareSerial.cpp (/arduino-1.0.X/hardware/arduino/cores/arduino):

#if (RAMEND < 1000) 
	#define SERIAL_BUFFER_SIZE 32 
	#else 
	#define SERIAL_BUFFER_SIZE 256 
	#endif

by

#if (RAMEND < 1000) 
	#define SERIAL_BUFFER_SIZE 256 
	#else 
	#define SERIAL_BUFFER_SIZE 256 
	#endif

You can increase the serial buffer size from 64 to 256 or 512 bytes in the Arduino.app package to have more buffer to receive the data from the BP meter.

But the serial buffer in Arduino is limited. In order to obtain more measures you could work with RaspberryPi.

Another option would be to try to store the measurement data on a SD, without showing on screen.

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:

/*
 *  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 blood pressure sensor 
 *  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.readBloodPressureSensor();
  Serial.begin(115200);
  delay(100);    
}

void loop() { 

  uint8_t numberOfData = eHealth.getBloodPressureLength();   
  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);

    Serial.print(F("Date -> ")); 
    Serial.print(eHealth.bloodPressureDataVector[i].day); 
    Serial.print(F(" of ")); 
    Serial.print(eHealth.numberToMonth(eHealth.bloodPressureDataVector[i].month));
    Serial.print(F(" of "));
    Serial.print(2000 + eHealth.bloodPressureDataVector[i].year);    
    Serial.print(F(" at "));

    if (eHealth.bloodPressureDataVector[i].hour < 10) {
      Serial.print(0); // Only for best representation.
    }

    Serial.print(eHealth.bloodPressureDataVector[i].hour);
    Serial.print(F(":"));

    if (eHealth.bloodPressureDataVector[i].minutes < 10) {
      Serial.print(0);// Only for best representation.
    }
    Serial.println(eHealth.bloodPressureDataVector[i].minutes);

    Serial.print(F("Systolic value : ")); 
    Serial.print(30+eHealth.bloodPressureDataVector[i].systolic);
    Serial.println(F(" mmHg"));
    
    Serial.print(F("Diastolic value : ")); 
    Serial.print(eHealth.bloodPressureDataVector[i].diastolic);
    Serial.println(F(" mmHg"));
    
    Serial.print(F("Pulse value : ")); 
    Serial.print(eHealth.bloodPressureDataVector[i].pulse);
    Serial.println(F(" bpm"));
  }

  delay(20000);
}

Upload the code and watch the Serial monitor.Here is the USB output using the Arduino IDE serial port terminal:

Raspberry Pi

/*
 *  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.readBloodPressureSensor();
  delay(100);    
}

void loop() {

  uint8_t numberOfData = eHealth.getBloodPressureLength();   
  printf("Number of measures : ");    
  printf("%d\n",numberOfData);   
  delay(100);


  for (int i = 0; i<numberOfData; i++) { 
    // The protocol sends data in this order 
    printf("==========================================");

    printf("Measure number ");
    printf("%d\n",i + 1);

    printf("Date -> "); 
    printf("%d",eHealth.bloodPressureDataVector[i].day);
    printf(" of "); 
    printf("%d",eHealth.numberToMonth(eHealth.bloodPressureDataVector[i].month));
    printf(" of ");
    printf("%d",2000 + eHealth.bloodPressureDataVector[i].year);    
    printf(" at ");

    if (eHealth.bloodPressureDataVector[i].hour < 10) {
      printf("%d",0); // Only for best representation.
    }

    printf("%d",eHealth.bloodPressureDataVector[i].hour);
    printf(":");

    if (eHealth.bloodPressureDataVector[i].minutes < 10) {
      printf("%d",0);// Only for best representation.
    }
    printf("%d\n",eHealth.bloodPressureDataVector[i].minutes);

    printf("Systolic value : "); 
    printf("%d\n",30+eHealth.bloodPressureDataVector[i].systolic);
    printf(" mmHg\n");
    
    printf("Diastolic value : "); 
    printf("%d",eHealth.bloodPressureDataVector[i].diastolic);
    printf(" mmHg\n");
    
    printf("Pulse value : "); 
    printf("%d",eHealth.bloodPressureDataVector[i].pulse);
    printf(" bpm\n");
  }

  delay(20000);
}

int main (){
        setup();
	while(1){
		loop();
	}
	return (0);
}

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.

pulsometro_pecho_presentacion

eHealth Body Position Sensor uses a triple axis accelerometer to obtain the patient's position.

Features:

  • 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.

elementos_pulsometro
e_health+pulsometro_pecho

Place the tape around the chest and the connector placed down

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);  
}
Example

Arduino

Upload the next code for seeing data in the serial monitor:

/*
 *  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:

Ejemplo_BodyPosition_

Raspberry Pi

/*
 *  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);
}

int main (){
	setup();
	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

GLCD

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.

velcro gsr

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.

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.

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.

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:

/*
 *  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> 

// 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() {

  float conductance = eHealth.getSkinConductance();
  float resistance = eHealth.getSkinResistance();
  float conductanceVol = eHealth.getSkinConductanceVoltage();

  Serial.print("Conductance : ");       
  Serial.print(conductance, 2);  
  Serial.println("");         

  Serial.print("Resistance : ");       
  Serial.print(resistance, 2);  
  Serial.println("");    

  Serial.print("Conductance Voltage : ");       
  Serial.print(conductanceVol, 4);  
  Serial.println("");

  Serial.print("\n");

  // wait for a second  
  delay(1000);            
}

Upload the code to Arduino and watch the Serial monitor.

Here is the USB output using the Arduino IDE serial port terminal:

Ejemplo_GSR_

Raspberry Pi

Compile the following code example:

/*
 *  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() { 
	
  float conductance = eHealth.getSkinConductance();
  float resistance = eHealth.getSkinResistance();
  float conductanceVol = eHealth.getSkinConductanceVoltage();

  printf("Conductance : %f \n", conductance);    
  printf("Resistance : %f \n", resistance);  
  printf("Conductance Voltage : %f \n", conductanceVol);       

  printf("\n");

  // wait for a second  
  delay(1000);   
}

int main (){
	//setup();
	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

GLCD

KST

KST program shows the GSR wave. KST

Pantallazo-2
Pantallazo2

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.

Glucometer configuration

For configuring the date time, open the batery compartment and press the black button. It's simple to set the parameters of our glucometer.

Did you see a small button near the battery (backside)? You can set the time and mg/dl by it. When glucometer is off, plz press once short time of the backside button to open it, then you can see the screen of year month date and time, short press the front button is to increase the data (long pressing will increase the data fast), short pree the backside botton is to switch the year to month/date or time or glucose units. To save the settings, plz short press the backside button several times until you see the big OFF on screen, then plz do nothing just wait it auto off.

To change the glucose units, when you see the time screen, just keeping short presses for several times untill you see only mmol/l is flashing, then press the front big button in long time (about 3 secs), you will see the mmol/l becomes to mg/dl. Now plz press the back small button twice short times to save it. You can see big OFF on screen, then plz do nothing just wait it auto off. Now you finished the settings of mg/dl. Setting other parameters is similar.

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).

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

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.

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.

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:

/*
 *  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() { 

  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);

    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(20000);
}

Upload the code and watch the Serial monitor.Here is the USB output using the Arduino IDE serial port terminal:

Ejemplo_glucometro_

Raspberry Pi

Compile the following 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.readGlucometer();
  delay(100);    
}

void loop() { 

  uint8_t numberOfData = eHealth.getGlucometerLength();   
  printf("Number of measures : %d",numberOfData);       
  delay(100);


  for (int i = 0; i< numberOfData; i++) { 
    // The protocol sends data in this order 
    printf("\n==========================================\n");

    printf("Measure number %d\n",i+1);

    printf("Date -> %d",eHealth.glucoseDataVector[i].day); 
    printf(" of "); 
    printf("%s",eHealth.numberToMonth(eHealth.glucoseDataVector[i].month));
    printf(" of ");
    printf("%d",2000 + eHealth.glucoseDataVector[i].year);    
    printf(" at ");

    if (eHealth.glucoseDataVector[i].hour < 10) {
      printf("0"); // Only for best representation.
    }

    printf("%d",eHealth.glucoseDataVector[i].hour);
    printf(":");

    if (eHealth.glucoseDataVector[i].minutes < 10) {
      printf("0");// Only for best representation.
    }
    printf("%d",eHealth.glucoseDataVector[i].minutes);

    if (eHealth.glucoseDataVector[i].meridian == 0xBB)
      printf(" pm");
    else if (eHealth.glucoseDataVector[i].meridian == 0xAA)
      printf(" am"); 

    printf("\nGlucose value : %d mg/dL",eHealth.glucoseDataVector[i].glucose); 
  }
  delay(20000);
}

int main (){
	setup();
	while(1){
		loop();
	}
	return (0);
}

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.

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.

NOTE: The current EMG sensor has been designed by Advancer Technologies under a CC BY-NC-SA 3.0 license

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.

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.

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:

/*
 *  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
 */

#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() {

  int EMG = eHealth.getEMG();

  Serial.print("EMG value :  ");
  Serial.print(EMG);  
  Serial.println(""); 

  delay(100);	// wait for a millisecond
}

Upload the code and watch the Serial monitor. Here is the USB output using the Arduino IDE serial port terminal:

Raspberry Pi

/*
 *  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() {

  int EMG = eHealth.getEMG();

  printf("EMG value :  ");
  printf("%d\n",EMG);  

  delay(100);	// wait for a millisecond
}

int main(){
	setup();
	while(1) loop();
	return 0;
}

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.

pantalla2

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.

pantalla4

When no respiration is detected, the screen will advise of a risq of apnea.

pantalla3

The last screen draws the ECG wave.

pantalla5

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

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:

/*
 *  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();
  }

  PCintPort::detachInterrupt(6);


  //Screen number two wich represent the air flow wave 
  //=========================================================================

  eHealthDisplay.initAirFlowScreen();	

  while( screenNumber == 2) {
    buttonState = digitalRead(pushButton);    
    delay(10);

    if(buttonState==1){
      screenNumber++;
    }

    eHealthDisplay.printAirFlowScreen();      
  }

  //Screen number three wich represent the ECG wave 
  //=========================================================================

  eHealthDisplay.initECGScreen();	

  while( screenNumber == 3) {
    buttonState = digitalRead(pushButton);    
    delay(10);

    if(buttonState==1){
      screenNumber++;
    }

    eHealthDisplay.printECGScreen();
  }

  screenNumber = 1;
  delay(10);  
}

//Include always this function for using the pulsioximeter sensor
//=========================================================================
void readPulsioximeter() {  

  cont ++;

  if (cont == 50) {
    //Get only one of 50 measures to reduce the latency
    eHealth.readPulsioximeter();  
    cont = 0;
  }
}

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.

3-pics

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".

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
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.

1) In pop-up window select the directory where the .txt previously created and press the Configure button.
Pantallazo_
2) The next step, is to configure the data source.
Pantallazo-1_
3) Select the measurement data. The data is field/column 2.
Pantallazo_
 
Pantallazo-1_
 

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.

Pantallazo-5_ Pantallazo-6_
ecg_measure

The Arduino code used in this program is presented next:

/*
 *  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 ECG 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){
        fanalog0=eHealth.getECG();  
        // Use the timer0 => 1 tick every 4 us
        time=(timer0_overflow_count << 8) + TCNT0;        
        // Microseconds conversion.
        time=(time*4);   
        //Print in a file for simulation
        Serial.print(time);
        Serial.print(";");
        Serial.println(fanalog0,5);

        if (Serial.available()>0){
          serialByte=Serial.read();
          if (serialByte=='F')  break;
        }
      }
    }
  }
}
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.

The Arduino code used in this program is presented next:

/*
 *  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);   
        //Print in a file for simulation
        Serial.print(time);
        Serial.print(";");
        Serial.println(analog0);

        if (Serial.available()>0){
          serialByte=Serial.read();
          if (serialByte=='F')  break;
        }
      }
    }
  }
}
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.

/*
 *  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();

    if (serialByte=='C'){        
      while(1){        
        fanalog0=eHealth.getSkinConductance();  
        // Use the timer0 => 1 tick every 4 us
        time=(timer0_overflow_count << 8) + TCNT0;
        // Microseconds conversion.
        time=time*4;
        //Print in a file for simulation
        Serial.print(time);
        Serial.print(";");
        Serial.println(fanalog0,5);
        if (Serial.available()>0){
          serialByte=Serial.read();
          if (serialByte=='F')  break;
        }
      }
    }
  }
}
Pantallazo-4_ Pantallazo-6_
Pantallazo-2
Pantallazo2
AirFlow example in KST

We can configure the program according to the data we want to sample.

Pantallazo2

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.

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:

/*
 *  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 Martín 
 */


#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();
            
          } 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();      
    } 
//=================================================================================================================
//=================================================================================================================    
    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(); 
    }  
//=================================================================================================================
//=================================================================================================================    
    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;   
                    }               
                  }                    
                } 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);

    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("|  __  | ")); }  
    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(){  
  
  cont ++;
 
  if (cont == 30) { //Get only one of 30 measures to reduce the latency
    eHealth.readPulsioximeter();  
    cont = 0;
  }
}

SmartPhone Application

ehealth_icon_op3

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 URL’s:

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.

     

    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.

    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:

    /*
     *  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 <http://www.gnu.org/licenses/>.
     *
     *  Version 0.1
     *  Author: Luis Martin & Ahmad Saad 
     */
     
    
    #include < PinChangeInt.h >
    #include < eHealth.h >
    
    char recv[256];
    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){     
    
        //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(1);
        //int diast = eHealth.getDiastolicPressure(1);         
        float ECG = eHealth.getECG();
        int EMG = eHealth.getEMG();
        EMG = map (EMG, 200,300,0,100);  // Use this function to adapt your muscle level to 0-100%
        //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(0);                    Serial.print("#");  //Systolic is not implemented
        Serial.print(0);                    Serial.print("#");  //Diastolic is not implemented 
        Serial.print(int(0));               Serial.print("#");  //Glucose is not implemented
        Serial.print(int(pos));             Serial.print("#");
        Serial.print(int(EMG)); Serial.print("#");      
        Serial.print("\n");    
        
        // 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 of  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).

    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.

     

    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.

    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:

    /*
     *  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 <http://www.gnu.org/licenses/>.
     *  Version 0.1
     *  Author: Luis Martin & Ahmad Saad 
     */
     
     
    #include < PinChangeInt.h >
    #include < eHealth.h > 
    
    char recv[128];
    uint8_t cont = 0;
    
    
    void setup()
    { 
      Serial.begin(9600);
      
      eHealth.initPulsioximeter();
      eHealth.initPositionSensor(); 
      
      
      //Attach the inttruptions for using the pulsioximeter.   
      PCintPort::attachInterrupt(6, readPulsioximeter, RISING);
      delay(1000);
      
    }
    
    void loop()
    {
      //while (Serial.available()>0) {}
      // Enters in command mode    
        Serial.print("$$$"); check();  
      // Sets DHCP and TCP protocol
        Serial.print("set ip dhcp 1\r"); check();
        Serial.print("set ip protocol 1\r"); check();
      // Configures the way to join the network AP
        Serial.print("set wlan join 0\r"); check();
        Serial.print("join ANDROID\r"); check();
      
        Serial.print("set i h 255.255.255.255\r"); delay(1000);
        
        Serial.print("set i r 12345\r"); check();
        Serial.print("set i l 2000\r"); check();
        Serial.print("exit\r"); check();
    
        while(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(1);
           //int diast = eHealth.getDiastolicPressure(1);     
           float ECG = eHealth.getECG();
           int EMG = eHealth.getEMG();
           EMG = map (EMG, 200,300,0,100);  // Use this function to adapt your muscle level to 0-100%
           //uint8_t glucose = eHealth.glucoseDataVector[0].glucose;      
    
          //Data sensor must be sent in this order to mobile android application 
          Serial.print(int(airFlow));     Serial.print("#");
          Serial.print(ECG);         	  Serial.print("#");
          Serial.print(int(0));           Serial.print("#"); //Systolic is not implemented
          Serial.print(int(0));           Serial.print("#"); //Diastolic is not implemented 
          Serial.print(int(0));           Serial.print("#"); //Glucose is not implemented
          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(int(pos));         Serial.print("#");
          Serial.print(int(EMG));         Serial.print("#");      
          Serial.print("\n");    
        
          // Reduce this delay for more data rate
          delay(250);  
      }
    }
    
    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 of 50 measures to reduce the latency
        eHealth.readPulsioximeter();  
        cont = 0;
      }
    }
    
    
    }

    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.

    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.

    xbee

    Example code

    This example shows the way to communicate with the Arduino using Zigbee protocol. Upload the next 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()
    { 
      Serial.begin(9600);
      
      eHealth.initPulsioximeter();
      eHealth.initPositionSensor(); 
      
      //Attach the inttruptions for using the pulsioximeter.   
      PCintPort::attachInterrupt(6, readPulsioximeter, RISING);
      delay(1000);
      
    }
    
    void loop()
    {    
          
          //1. Read from eHealth. 
           int airFlow = eHealth.getAirFlow();     
           float temperature = eHealth.getTemperature();     
           float conductance = eHealth.getSkinConductance();   
           float resistance = eHealth.getSkinResistance();
           int BPM = eHealth.getBPM();     
           int SPO2 = eHealth.getOxygenSaturation();     
           uint8_t pos = eHealth.getBodyPosition();      
        
    
          Serial.print(int(airFlow));     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(pos));         Serial.print("#");
          Serial.print("\n");    
        
          // Reduce this delay for more data rate
          delay(250);   
    }
    
    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 of 50 measures to reduce the latency
        eHealth.readPulsioximeter();  
        cont = 0;
      }
    }

    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:

    /*
     *  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 send a text message with 
     *  the coporal temperature using the GPRS module. 
     *
     *  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 GPRS shield please see our tutorial
    // in cooking-hacks web site. http://www.cooking-hacks.com
    
    
    #include <eHealth.h>
    
    // the pin to switch on the module (without press on button) 
    int pinModuleOn = 2;      
    
    // ********* is the number to call
    char phoneNumber[]="**********";    
    
    
    void switchModule(){       
      digitalWrite(pinModuleOn,HIGH);
      delay(2000);
      digitalWrite(pinModuleOn,LOW);
    }
    
    void setup() {
    
      // UART baud rate
      Serial.begin(115200);               
      delay(2000);
    
      // Sitches the module ON
      // switchModulo();    
    
      for (int i=0;i < 5;i++){
        Serial.println("Push the button");
        delay(5000);
      }
      // Sets the SMS mode to text
      Serial.println("AT+CMGF=1");         
      delay(100);
    }
    
    void loop(){
    
      delay(100);
      float temperature = eHealth.getTemperature();     
    
      delay(1500);
      // send the SMS number 
      Serial.print("AT+CMGS=\"");     
      Serial.print(phoneNumber);
      Serial.println("\"");
      // the SMS body 
      while(Serial.read()!='>');      
      Serial.print(temperature);
    
      delay(1000);
      //sends ++
      Serial.write(0x1A);       
      Serial.write(0x0D);
      Serial.write(0x0A);
      delay(5000);
    
    }

    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.

    Example code

    This example how to send data using 3G shield and making a connection to a server. Upload the next 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);
    }
    
    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);
      } 
    
      Serial.println("AT+CGSOCKCONT=1,\"IP\",\"internetmas\"");
      Serial.flush();
      x=0;
      do
      {
        while(Serial.available()==0);
        data[x]=Serial.read();  
        x++;  
      } while(!(data[x-1]=='K'&&data[x-2]=='O')); //waits for response "Network opened"
    
    
    }
    
    void loop()
    {
      float temperature = eHealth.getTemperature();    
      int longitud = sprintf(tosend,"%d", temperature); 
    
      Serial.print("AT+NETOPEN=\"TCP\",");
      //Opens the socket with the type of protocol and the port 
      Serial.println(port);        
      Serial.flush();
      x=0;
      
      do
      {
        while(Serial.available()==0);
        data[x]=Serial.read();  
        x++;  
      }
      while(!(data[x-1]=='K'&&data[x-2]=='O'));        //waits for response "Network opened"
    
      Serial.print("AT+TCPCONNECT=\""); //Connects with the server
      Serial.print(server);
      Serial.print("\",");    
      Serial.println(port);
    
      Serial.flush();
      while(Serial.read()!='K');  
    
      Serial.print("AT+TCPWRITE=");
      Serial.println(longitud, DEC);    //Sends TCP data
      Serial.flush();
    
    
    
      do 
      { 
        while (Serial.available() == 0) {};      
        //Serial.println(char(Serial.read()));      
      } while(Serial.read()!='>');  
    
      Serial.println(tosend); 
    
      x=0;
    
      do
      {
        while(Serial.available()==0);
        data[x]=Serial.read();  
        x++;                        
      }
      while(!(data[x-1]=='K'&&data[x-2]=='O'));
    
      Serial.println("AT+NETCLOSE"); //Opens the socket with the type of protocol and the port 
      Serial.flush();
      while(Serial.read()!='K'); 
    
      while(1);
    
    }

    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

    3G camera

    Insert the camera with metallic contacts facing up

    3G camera

    Example Code

    Take photos is very easy. Upload the next 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 Gállego
    */
    
    
    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);
        }   
    
        Serial.println("AT+CCAMS");     //starts the camera
        while(Serial.read()!='K');
    
        Serial.println("AT+CCAMSETD=640,480");     //sets VGA (640*480) resolution
        while(Serial.read()!='K');
        
        Serial.println("AT+FSLOCA=0");     //stores the image file in the 3G module
        while(Serial.read()!='K');
        
    
    }
    
    void loop(){
    
        delay(1500);
        while(Serial.available()!=0){
            Serial.read();
        }
        Serial.println("AT+CCAMTP");     //takes a picture, but not saved it
        while(Serial.read()!='K');  
    
        Serial.println("AT+CCAMEP");     // saves the picture into C:/Picture    
        Serial.flush();     
        while(Serial.read()!='/');
        while(Serial.read()!='/');
    
        x=0;
        do{
            while(Serial.available()==0);
            name[x]=Serial.read();
            x++;
        }while(x < 19);
    
        while(Serial.read()!='K');  
        Serial.println(name); 
    
        Serial.println("AT+CCAME");     // stops the camera
        while(Serial.read()!='K');  
    
        while(1);
        
    }

    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

    Sensors