Laura Juliana Vargas Escobar
Published © GPL3+

e-Care Heart

E-health Prototype System for Cardiac Telemonitoring "Caring your heart anywhere"

IntermediateWork in progress5,603
e-Care Heart

Things used in this project

Hardware components

LinkIt ONE
MediaTek Labs LinkIt ONE
×1
Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
Pulse-oximeter
×1

Software apps and online services

Ubidots
Ubidots

Story

Read more

Schematics

Required Devices

This image shows all the devices used and how they should be connected, the board circuit is only a CMOS connected as buffer to make that the maximum output voltage of the Arduino is not greater than 3.3v.

Code

GPS_AND_PULSEOXIMETER.ino

C/C++
This is the code to obtain de GPS coordinates and to communicate the
Link It ONE to the e-health card for Arduino UNO to obtain the cardiac pulse signal.
This data is send and posted in UBIDOTS
/*This is the code to obtain de GPS coordinates and to communicate the
Link It ONE to the e-health card for Arduino UNO to obtain the cardiac pulse signal.
This data is send and posted in UBIDOTS*/

//Libraries
#include <LGPS.h>
#include <LTask.h>
#include <LWiFi.h>
#include <LWiFiClient.h>

//WiFi Configuration
#define WIFI_AP "bisemic"//put your network name
#define WIFI_PASSWORD "bisemick305"//put your network password
#define WIFI_AUTH LWIFI_WPA  //network configuration->LWIFI_OPEN, LWIFI_WPA, or LWIFI_WEP.

//Variables
#define SITE_URL "things.ubidots.com"
#define TOKEN "XIBVJIamJMfxVEcJTUiXUFihiqOBoP"//This token is generate on your ubidots profile
#define IDGPS "5644e9d57625425c3e6219e3"//variable id->it is generate at the ubidots's dashboard
#define IDPULSO "5659dc1c7625423b5e627699"//variable id->it is generate at the ubidots's dashboard

LWiFiClient c;
gpsSentenceInfoStruct info;
String Location = "";          // Will build the Location string here. this is for the GPS information

//configuration to read the pulse-oximeter data
#include<HardwareSerial.h>
#include<UARTClass.h>
int dato=0;

void setup() {
  Serial1.begin(9600);//this serial is the serial port to communicate the Link It ONE with the Arduino UNO and transmit the data
  Serial.begin(9600);
  LGPS.powerOn();
  Serial.println("LGPS Power on, and waiting ..."); 

//***************WiFi Conection****************//////
  LWiFi.begin();
  LTask.begin();
  Serial.println();
  Serial.println("Connecting to AP...");
//This secction is to conect to the network
  if(LWiFi.connectWPA(WIFI_AP,WIFI_PASSWORD)<0)
    {
      Serial.println("FAIL!");
      return;
    }
    Serial.println("OK");
//This secction is to conect to the site
    Serial.print("Connecting to site...");
    if(!c.connect(SITE_URL, 80))
      {
        Serial.println("FAIL!");
        return;
      }
      Serial.println("OK");
  // send HTTP request, ends with 2 CR/LF
  Serial.println("send HTTP GET request");
  c.println("GET / HTTP/1.1");
  c.println("Host: " SITE_URL);
  c.println("Connection: close");
  c.println();
//*****************END OF WIFI CONECTION***********//
}

void loop() {
  Serial.println("LGPS loop"); 
  LGPS.getData(&info);
  //*******ParseLocation is the function to obtain the GPS coordinates**********//
   ParseLocation((const char*)info.GPGGA);

   
//**************pulse-oximeter lecture********************//
  dato=Serial1.read();
    Serial.println("EMG:");
    Serial.println(Serial1.read());
 //*******"datos_bpm" is the function to post the pulse-oximeter data in UBIDOTS
  datos_bpm(String(dato));
      delay(1000);
}

//////////************************FUNCTION PARSELOCATION****************///////
void ParseLocation(const char* GPGGAstr)
// Refer to http://www.gpsinformation.org/dale/nmea.htm#GGA
// Sample data: $GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47
{
  char latarray[6];
  char longarray[6];
  int index = 0;
  Serial.println(GPGGAstr);
  Serial.print("Fix Quality: ");
  Serial.println(GPGGAstr[43]);
  if (GPGGAstr[43]=='0') {        //  This is the place in the sentence that shows Fix Quality 0 means no fix
    Serial.println("No GPS Fix");
    Location = "";           // No fix then no Location string
  }
  String GPSstring = String(GPGGAstr);
  for (int i=20; i<=26; i++) {         // We have to jump through some hoops here
    latarray[index] = GPGGAstr[i];     // we need to pick out the minutes from the char array
    index++;
  }
  float latdms = atof(latarray);        // and convert them to a float
  float lattitude = latdms/60;          // and convert that to decimal degrees
  String lattstring = String(lattitude,8);// Then put back into a string with 8 decimal position
  Location = "{\"lat\":";
  if(GPGGAstr[28] == 'S')Location = Location + "-";      
 Location=Location+ GPSstring.substring(19,20) + "." + lattstring.substring(2,10);
String  lat=GPSstring.substring(19,20) + "." + lattstring.substring(2,10);
  index = 0;
  for (int i=33; i<=38; i++) {         // And do the same thing for longitude
    longarray[index] = GPGGAstr[i];     // the good news is that the GPS data is fixed column
    index++;
  }
  float longdms = atof(longarray);        // and convert them to a float
  float longitude = longdms/60;          // and convert that to decimal degrees
  String longstring = String(longitude,8);// Then put back into a string with 8 decimal position
  Location=Location+"\"lng\":";
  if(GPGGAstr[41] == 'W') Location = Location + "-";
  if(GPGGAstr[30] == '0') {
    Location = Location+ GPSstring.substring(31,33) + "." + longstring.substring(2,10);
    String lng=GPSstring.substring(31,33) + "." + longstring.substring(2,10);
  //*******"dato_gps" is the function to post the GPS data
    dato_gps(lat,"-"+lng);
  }
  else {
    Location = Location+ GPSstring.substring(30,33) + "." + longstring.substring(2,10);
    String lng=GPSstring.substring(30,33) + "." + longstring.substring(2,10);
  //*******"dato_gps" is the function to post the GPS data
    dato_gps(lat,"-"+lng);
  }
Location=Location+"}";
     
}
/////////*************END OF PARSELOCATION FUNCTION**************////////////////////

//************GPS FUNCTION to post data*************
void dato_gps(String lat,String lng){
    Serial.println("Sending value to Ubidots...");
    LWiFiClient c;
  while (!c.connect(SITE_URL, 80))
  {    Serial.println("Retrying to connect...");
      delay(100);  }
//*****************Posting GPS data*******************//
double a=265;
  String valor=String(a);
  String data = "{\"value\":"+valor+",\"context\":{\"lat\":"+lat+",\"lng\":"+lng+"}}";
  String thisLength = String(data.length());
    // Build HTTP POST request
  c.print("POST /api/v1.6/variables/");
  c.print(IDGPS);
  c.print("/values?token=");
  c.print(TOKEN);
  c.println(" HTTP/1.1");
  c.println("Content-Type: application/json");
  c.println("Content-Length: " + thisLength);
  c.print("Host: ");
  c.println(SITE_URL);
  c.print("\n" + data);
  c.print(char(27));
  Serial.println(data);
 // read server response
  while (c){    Serial.print((char)c.read());  }
  c.stop(); 
}

//******************FUNCTION TO TRANSMIT THE PULXIOXIMETER DATA**************//
  void datos_bpm(String value){
   Serial.println("Sending value to Ubidots...");
   Serial.println(value);
  LWiFiClient c;
  while (!c.connect(SITE_URL, 80))
  {
    Serial.println("Retrying to connect...");
    delay(100);
  }
  String data = "{\"value\":"+ value + "}";
  String thisLength = String(data.length());
  // Build HTTP POST request
  c.print("POST /api/v1.6/variables/");
  c.print(IDPULSO);
  c.print("/values?token=");
  c.print(TOKEN);
  c.println(" HTTP/1.1");
  c.println("Content-Type: application/json");
  c.println("Content-Length: " + thisLength);
  c.print("Host: ");
  c.println(SITE_URL);
  c.print("\n" + data);
  c.print(char(26)); 
  // read server response
  while (c){
    Serial.print((char)c.read());
  }
  c.stop();
}

WIFI_communication.ino

C/C++
This is the code to connect by wifi to a network
/*
This is the code to connect to wifi 
 */
//Libaries
#include <LTask.h>
#include <LWiFi.h>
#include <LWiFiClient.h>

//Wifi Configuration
#define WIFI_AP "bisemic"//network name
#define WIFI_PASSWORD "bisemick305"//network password
#define WIFI_AUTH LWIFI_WPA  // network configuration-> LWIFI_OPEN, LWIFI_WPA, or LWIFI_WEP.

//web site to connect
#define SITE_URL "things.ubidots.com"
LWiFiClient c;

void setup()
{
  Serial.begin(9600);
  LWiFi.begin();  
  LTask.begin();
  
  Serial.println();
  Serial.println("Connecting to AP...");
  //Connecting to network
  if(LWiFi.connectWPA(WIFI_AP,WIFI_PASSWORD)<0)
    {
      Serial.println("FAIL!");
      return;
    }
    Serial.println("OK");
   //connecting to web site
    Serial.print("Connecting to site...");
    if(!c.connect(SITE_URL, 80))
      {
        Serial.println("FAIL!");
        return;
      }
      Serial.println("OK");
         
  // send HTTP request, ends with 2 CR/LF
  Serial.println("send HTTP GET request");
  c.println("GET / HTTP/1.1");
  c.println("Host: " SITE_URL);
  c.println("Connection: close");
  c.println();
}

void loop()
{

}

PULSE-OXIMETER_LECTURE.ino

C/C++
This code is to obtain the pulse-oximeter data and send
it to a serial port created, called "Serial1" to the LinkIt ONE
/*This code is to obtain the pulse-oximeter data and send
it to a serial port created, called "Serial1" to the LinkIt ONE
This code was developed by: Nelson F. Monroy R. from Bucaramanga-Colombia 
NOTE: The libraries were modificated to this purpose*/
#include <SoftwareSerial.h>
#include <eHealth.h>
#include <PinChangeInt.h>

SoftwareSerial serial1(4,5);//Pin 4 to RX, and pin 5 to TX
int cont=0, SPO2,BPM, dato;

void setup() {
serial1.begin(9600);
eHealth.initPulsioximeter();
PCintPort::attachInterrupt(6,readPulsioximeter,RISING);  
}

void loop() {
    BPM= eHealth.getBPM();//The BPM data is the data of cardiac pulse
    serial1.write(BPM);
    delay(5000);
}
void readPulsioximeter()
{
  cont ++;
  if (cont==20)
  {
  eHealth.readPulsioximeter();
  cont=0;
  }
}

Credits

Laura Juliana Vargas Escobar

Laura Juliana Vargas Escobar

1 project • 12 followers
Electronic engineering student of the Pontificia Bolivariana University-Bucaramanga branch. Areas of interest: Biomedica, seismic, e-health, home automation
Thanks to Mgs. Sergio Alexander Salinas and Ing. Nelson Fernando Monroy Rios.

Comments

Add projectSign up / Login