tejas bangeraParikshit Jadhav
Published © GPL3+

Smart Heart Monitoring System

LinkIt One and Olimax EKG shield is used to diagnose various heart conditions to counter rising Cardiovascular problems in Urban cities.

BeginnerFull instructions provided3,095
Smart Heart Monitoring System

Things used in this project

Hardware components

OLIMEX SHIELD-EKG-EMG
×1
OLIMEX ECG GEL ELECTRODES
×1
OLIMEX CONNECTOR FOR GEL ECG ELECTRODES
×1

Story

Read more

Schematics

Board

Code

CODE.ino

C/C++
1)Connect to your Wifi network
2)Change the password and choose from LWIFI_OPEN, LWIFI_WPA, or LWIFI_WEP
3)Upload and Run the program
#include <LTask.h>
#include <LWiFi.h>
#include <LWiFiClient.h>
#include <LFlash.h>
#include <LSD.h>
#include <LStorage.h>

#define WIFI_AP "NETGEAR" //connect to your Wifi network
#define WIFI_PASSWORD "123456"  //change the password
#define WIFI_AUTH LWIFI_WPA  // choose from LWIFI_OPEN, LWIFI_WPA, or LWIFI_WEP.
#define SITE_URL "http://52.91.67.155:8080/"
//#define Drv LFlash          // use Internal 10M Flash
#define Drv LSD           // use SD card
int i =0, sensor;
String val ="";
String lecg , ecg_data;
LWiFiClient c;
String dataStringfnl ;
void setup()
{
   //Serial.begin(9600);
Serial.begin(115200);

    while(!Serial.available());         // input any thing to start
Serial.println("1");


    Serial.print("Initializing SD card...");
    // make sure that the default chip select pin is set to
    // output, even if you don't use it:
    pinMode(10, OUTPUT);

    // see if the card is present and can be initialized:
    LTask.begin();
    Drv.begin();
    Serial.println("card initialized.");
    LFile dataFile = Drv.open("datalog.txt", FILE_WRITE);
     // make a string for assembling the data to log:
  String dataString = "";

  // read value from sensor and append to the string:
  for(i=0;i<500;i++){
     sensor = analogRead(A0);
      dataString += String(sensor);
      dataString += String(",");
      //dataFile.println(String(sensor));
      //dataString += "\n";
  }
  
Serial.println(dataString);
 
    dataFile.close();  
  Serial.println("data acquired");
 
  LWiFi.begin();
  // keep retrying until connected to AP
 Serial.println("Connecting to AP");
  while (0 == LWiFi.connect(WIFI_AP, LWiFiLoginInfo(WIFI_AUTH, WIFI_PASSWORD)))
  {
    delay(1000);
    Serial.println("2");
  }
String ecg_data = "ecg_data="+ dataString;
String lecg = String(ecg_data.length());
Serial.println(ecg_data);
  // keep retrying until connected to website
  Serial.println("Connecting to WebSite");
  while (0 == c.connect(SITE_URL, 8080))
  {
    Serial.println("Re-Connecting to WebSite");
    delay(1000);
  }
Serial.println("3");
  // send HTTP request, ends with 2 CR/LF
  Serial.println("send HTTP POST request");
  c.println("POST / HTTP/1.1");
  c.println("Host: " SITE_URL);
  c.println("Connection: keep-alive");
  c.println("Content-Type: application/x-www-form-urlencoded");
   c.print("Content-Length: ");
   c.println(ecg_data.length());
   c.println();
   c.println(ecg_data);
   
  // waiting for server response
  Serial.println("waiting HTTP response:");
  while (!c.available())
  {
    delay(100);
  }
  Serial.println("4");
}

boolean disconnectedMsg = false;



void loop()
{
  // Make sure we are connected, and the response content to Serial
  while (c)
  {
    int v = c.read();
    if (v != -1)
    {
      Serial.print((char)v);
    }
    else
    {
      Serial.println("no more content, disconnect");
      c.stop();
      while (1)
      {
        delay(1);
      }
    }
  }

  if (!disconnectedMsg)
  {
    Serial.println("disconnected by server");
    disconnectedMsg = true;
  }
  delay(500);
}

Credits

tejas bangera

tejas bangera

1 project • 7 followers
I'm a Techie , Engineer, IoT enthusiast
Parikshit Jadhav

Parikshit Jadhav

1 project • 4 followers
Just be Cool
Thanks to REDx Team.

Comments