Renga
Published © GPL3+

ACT(Active Covid Tracker)

To assist the doctors to track their patients during COVID-19

IntermediateShowcase (no instructions)5 hours92
ACT(Active Covid Tracker)

Things used in this project

Hardware components

ESP8266 ESP-12E
Espressif ESP8266 ESP-12E
×1
ProtoCentral Pulse Oximeter & Heart Rate Sensor based on MAX30100
ProtoCentral Pulse Oximeter & Heart Rate Sensor based on MAX30100
×1
SparkFun Power Cell - LiPo Charger/Booster
SparkFun Power Cell - LiPo Charger/Booster
1S LIPO CHARGER AND 5V BOOST CONVERTER
×1
Battery, 3.7 V
Battery, 3.7 V
×1
thermister 10k
×1
0.96" OLED 64x128 Display Module
ElectroPeak 0.96" OLED 64x128 Display Module
Recommended is 128x32 I2C OLED module
×1

Software apps and online services

Blynk
Blynk
Ubidots
Ubidots
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
PCB, For DMB-4775
PCB, For DMB-4775

Story

Read more

Schematics

Basic connection of esp

soon i will upload complete connection

Code

ACT

Arduino
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <EasyButton.h>
#include "MAX30100_PulseOximeter.h"
#include "MAX30100.h"
#define BLYNK_PRINT Serial//redefine  BLYNK_PRINT as Serial
#include <ESP8266WiFi.h>//header file for controlling wifi
#include <BlynkSimpleEsp8266.h>//header for blynk
#include <TimeLib.h>//header file for counter
#include <WidgetRTC.h>// header file for Real Time Clock
#include "Ubidots.h"
long int update_timer=millis();
long int button_timer=millis();
long int on_screen=millis();
long int on_screen_heart=millis();
long int random_time=millis();
#define BUTTON_PIN D7
#define REPORTING_PERIOD_MS      1000
#define PULSE_WIDTH              MAX30100_SPC_PW_1600US_16BITS
#define IR_LED_CURRENT           MAX30100_LED_CURR_50MA  
#define LED_CURRENT              MAX30100_LED_CURR_20_8MA 
#define SAMPLING_RATE            MAX30100_SAMPRATE_1000HZ
PulseOximeter pox;
MAX30100 sensor;
#define OLED_RESET 4
Adafruit_SSD1306 display(-1);
uint32_t tsLastReport = 0;
uint32_t last_beat=0;
bool initialized=false;
int HRclean;
int SpO2;
char context[50];
char lattitude[20];
char longitude[20];
int ThermistorPin =A0;
int Vo;
float R1 = 4500;
float logR2, R2, T, Tc, Tf;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;
int menu=1;
int beat=0;
int oxygen=0;
int heart=0;
int heart_screen=0;
int oxygen_screen=0;

/*=================================================================================================================*/

char auth[] = "Auth_code";// indentification of your board like phone number
const char* DEVICE_TYPE = "device";     // Edit here your device type label
const char* WIFI_SSID = "wifi_name";           // Put here your Wi-Fi SSID
const char* WIFI_PASS = "password";           // Put here your Wi-Fi password
const char* UBIDOTS_TOKEN = "TOKEN";  // Put here your Ubidots TOKEN


/*================================================================================================================*/

// 'mm', 33x32px
const unsigned char thermometer [] PROGMEM = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 
  0x04, 0x10, 0x00, 0x00, 0x00, 0x04, 0x10, 0x00, 0x00, 0x00, 0x04, 0x10, 0x00, 0x00, 0x00, 0x1c, 
  0x10, 0x00, 0x00, 0x00, 0x04, 0x10, 0x00, 0x00, 0x00, 0x04, 0x10, 0x00, 0x00, 0x00, 0x1c, 0x10, 
  0x00, 0x00, 0x00, 0x04, 0x10, 0x00, 0x00, 0x00, 0x04, 0x10, 0x00, 0x00, 0x00, 0x1c, 0x10, 0x00, 
  0x00, 0x00, 0x04, 0x90, 0x00, 0x00, 0x00, 0x0c, 0x90, 0x00, 0x00, 0x00, 0x04, 0x90, 0x00, 0x00, 
  0x00, 0x04, 0x90, 0x00, 0x00, 0x00, 0x04, 0x90, 0x00, 0x00, 0x00, 0x08, 0x88, 0x00, 0x00, 0x00, 
  0x11, 0x84, 0x00, 0x00, 0x00, 0x21, 0xc2, 0x00, 0x00, 0x00, 0x23, 0xe2, 0x00, 0x00, 0x00, 0x27, 
  0xf2, 0x00, 0x00, 0x00, 0x67, 0xf3, 0x00, 0x00, 0x00, 0x27, 0xf2, 0x00, 0x00, 0x00, 0x23, 0xe2, 
  0x00, 0x00, 0x00, 0x21, 0xc2, 0x00, 0x00, 0x00, 0x10, 0x04, 0x00, 0x00, 0x00, 0x08, 0x18, 0x00, 
  0x00, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};


// '3e3e3e', 30x30px
const unsigned char satellite [] PROGMEM = {
  0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 
  0x07, 0x60, 0x00, 0x00, 0x02, 0xf0, 0x00, 0x00, 0x01, 0xf0, 0x00, 0x00, 0x00, 0xec, 0x00, 0x00, 
  0x00, 0x5e, 0x70, 0x00, 0x00, 0x3e, 0xf8, 0x00, 0x00, 0x1d, 0xfc, 0x00, 0x00, 0x0b, 0xfc, 0x00, 
  0x00, 0x07, 0xfc, 0x00, 0x00, 0x0f, 0xf8, 0x00, 0x00, 0x0f, 0xf0, 0x00, 0x00, 0x0f, 0xee, 0x00, 
  0x00, 0x77, 0xdf, 0x00, 0x00, 0x7b, 0xbe, 0x00, 0x00, 0x3c, 0x1c, 0xc0, 0xc4, 0x1c, 0x09, 0xe0, 
  0xce, 0x0c, 0x03, 0xc0, 0x66, 0x00, 0x03, 0x98, 0x63, 0x00, 0x01, 0x3c, 0x73, 0xc0, 0x00, 0x78, 
  0x38, 0xe0, 0x00, 0x70, 0x1c, 0x00, 0x00, 0x20, 0x0e, 0x00, 0x00, 0x00, 0x07, 0xc0, 0x00, 0x00, 
  0x03, 0xe0, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00
};

// 'mml', 30x30px
const unsigned char heart_logo [] PROGMEM = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xf8, 0x7e, 0x00, 0x03, 0xfc, 0xff, 0x80, 
  0x07, 0xff, 0xff, 0x80, 0x0f, 0xff, 0xff, 0xc0, 0x0f, 0xff, 0xff, 0xc0, 0x0f, 0xff, 0xff, 0xc0, 
  0x0f, 0xff, 0xff, 0xc0, 0x07, 0xff, 0xff, 0x80, 0x07, 0xff, 0xff, 0x80, 0x03, 0xff, 0xff, 0x00, 
  0x01, 0xff, 0xfe, 0x00, 0x00, 0xff, 0xfc, 0x00, 0x00, 0x7f, 0xf8, 0x00, 0x00, 0x3f, 0xf0, 0x00, 
  0x00, 0x1f, 0xe0, 0x00, 0x00, 0x0f, 0xc0, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x03, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'mml', 15x15px
const unsigned char heart_logo_small_1 [] PROGMEM = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0xf0, 0x3f, 0xf8, 0x3f, 0xf8, 0x3f, 0xf8, 0x1f, 0xf0, 
  0x0f, 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'mml', 20x20px
const unsigned char heart_logo_small_2 [] PROGMEM = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x9f, 0x00, 0x1f, 
  0xff, 0x80, 0x1f, 0xff, 0x80, 0x1f, 0xff, 0x80, 0x1f, 0xff, 0x80, 0x0f, 0xff, 0x80, 0x0f, 0xff, 
  0x00, 0x07, 0xfe, 0x00, 0x03, 0xfc, 0x00, 0x01, 0xf8, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x60, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

// 'dsds', 30x30px
const unsigned char black [] PROGMEM = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'ewew', 30x30px
const unsigned char lung_logo [] PROGMEM = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x38, 0x30, 0x00, 
  0x00, 0xfb, 0x7c, 0x00, 0x01, 0xf9, 0x7e, 0x00, 0x03, 0xfa, 0x7f, 0x00, 0x07, 0xfb, 0x7f, 0x80, 
  0x07, 0xfc, 0xff, 0xc0, 0x0f, 0x00, 0x03, 0xc0, 0x0f, 0x08, 0x61, 0xe0, 0x1e, 0x98, 0x76, 0xe0, 
  0x1f, 0xb8, 0x73, 0x70, 0x3f, 0x38, 0x71, 0xf0, 0x3e, 0xb8, 0x7d, 0xf0, 0x3e, 0xb8, 0x7e, 0xf0, 
  0x3d, 0xb8, 0x7e, 0x78, 0x3d, 0xf8, 0x77, 0x78, 0x3f, 0xf8, 0x7f, 0x78, 0x3f, 0xf8, 0x3f, 0x78, 
  0x3f, 0xf0, 0x3f, 0xf8, 0x3f, 0xe0, 0x0f, 0xf8, 0x3e, 0x00, 0x01, 0xf0, 0x18, 0x00, 0x00, 0x30, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'dsdsd', 30x30px
const unsigned char o_logo [] PROGMEM = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x3c, 0x30, 0x00, 
  0x00, 0x78, 0xec, 0x00, 0x00, 0x39, 0xc4, 0x00, 0x00, 0x01, 0x82, 0x00, 0x00, 0x02, 0x02, 0x00, 
  0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0xc8, 0x00, 0x00, 0xfe, 0x20, 0x00, 
  0x01, 0xff, 0x80, 0x00, 0x03, 0xb1, 0xc0, 0x00, 0x07, 0xc0, 0xe0, 0x00, 0x07, 0x80, 0x60, 0x00, 
  0x07, 0x00, 0x60, 0x00, 0x0f, 0x00, 0x67, 0x80, 0x0c, 0x00, 0x6c, 0x80, 0x06, 0x00, 0x60, 0xc0, 
  0x06, 0x00, 0x60, 0x80, 0x07, 0x00, 0xc3, 0x80, 0x03, 0x81, 0xc7, 0x00, 0x01, 0xff, 0x86, 0x00, 
  0x00, 0x7e, 0x0f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'asas', 30x30px
const unsigned char o2_logo [] PROGMEM = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 
  0x01, 0xff, 0xe0, 0x00, 0x03, 0xff, 0xf0, 0x00, 0x07, 0xc0, 0xf8, 0x00, 0x0f, 0x00, 0x78, 0x00, 
  0x0f, 0x00, 0x3c, 0x00, 0x0e, 0x00, 0x3c, 0x00, 0x1e, 0x00, 0x1c, 0x00, 0x1e, 0x00, 0x1c, 0x00, 
  0x1e, 0x00, 0x1c, 0x00, 0x1e, 0x00, 0x1c, 0x00, 0x1e, 0x00, 0x1c, 0x00, 0x1e, 0x00, 0x1c, 0x00, 
  0x0e, 0x00, 0x3c, 0x00, 0x0f, 0x00, 0x3c, 0x00, 0x07, 0x80, 0x78, 0x00, 0x07, 0xe3, 0xf1, 0xc0, 
  0x03, 0xff, 0xe2, 0x60, 0x00, 0xff, 0xc0, 0x60, 0x00, 0x1e, 0x00, 0x60, 0x00, 0x00, 0x00, 0xc0, 
  0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

//Ubidots ubidots(UBIDOTS_TOKEN, UBI_HTTP);
//Ubidots client(UBIDOTS_TOKEN);
Ubidots ubidots(UBIDOTS_TOKEN);
EasyButton button(BUTTON_PIN,60,false,false);
BlynkTimer timer;// creating timer
WidgetRTC rtc;//creating real time clock
WidgetLCD lcd(V3);


/*===================== RTC ==========================*/
BLYNK_CONNECTED() {
  rtc.begin();// Synchronize time on connection //getting current time from network
  Blynk.syncVirtual(V4);
}


/*===================== DECTECTING STATUS ==========================*/
void onBeatDetected()
{
    beat=1;
    Serial.println("beat");
    last_beat=millis();
}


/*===================== UPDATING MENU ==========================*/
void update_menu()
{
  if(millis()-button_timer>300)
  {
  menu++;
  button_timer=millis();
  if(menu>5)
  {
    menu=1;
  }
  display.clearDisplay();
  on_screen=millis();
  }
 
}
/*===================== MENU 1: CLOCK_DISPLAY ==========================*/
void clock_display()
{
  
  display.setTextColor(WHITE, BLACK);
  display.drawRect(117, 25, 3, 3, WHITE);     // Put degree symbol (  )
  draw_text(0, 25, "TEMPERATURE =", 1);
  draw_text(122, 25, "C", 1);
  /*============Display Date=================*/
  display.setTextSize(1);
  display.setCursor(0,0);
  display.print(dayStr(weekday()));
  char currentDate [16];
  uint8_t thisDay, thisMonth ;
  thisDay = day();
  thisMonth =  month();
  sprintf (currentDate, "%02d/%02d/", thisDay, thisMonth); //add leading zeros to the day and month
  display.setTextSize(1);
  display.setCursor(62,0);
  display.print(currentDate);
  display.setTextSize(1);
  display.setCursor(102,0);
  display.print(year(), DEC);
  /*================Display Time================*/ 
  char buffer [16];
  uint8_t thisSec, thisMin, thisHour;
  thisSec = second();
  thisMin =  minute();
  thisHour = hour();
  sprintf (buffer, "%02d:%02d:%02d", thisHour, thisMin, thisSec);
  display.setCursor(0,9);
  
  display.setTextSize(2);
  display.print(" ");
  display.setCursor(15,9);
  display.print(buffer);
  /*=============Display Temperature=====================*/
  display.setTextSize(1);
  display.setCursor(82,25);
  display.print(Tc);

  display.display(); 
  lcd.print(0,0,"     ACTIVE     ");
  lcd.print(0,1,"     TRACKER    ");

 }
void draw_text(byte x_pos, byte y_pos, char *text, byte text_size) {
  display.setCursor(x_pos, y_pos);
  display.setTextSize(text_size);
  display.print(text);
  display.display();
}

/*===================== MENU 2: HEART_RATE ==========================*/
void heart_rate(int i)
{
  if(i==1)
  {
  Serial.println("heart");
  Serial.println(HRclean);
   display.clearDisplay();
   display.setCursor(0,0);
   display.setTextSize(1);
   //display.setTextColor(WHITE);
   display.println("HEART RATE");
   display.setTextSize(2);
   display.setCursor(0,9);
   display.print(HRclean);
   display.setCursor(0,25);
   display.setTextSize(1);
    display.print("  BPM");
   if(heart_screen>=0 && heart_screen <5)
   {
  
    display.drawBitmap(90, 0,black,30,30, WHITE);
   display.drawBitmap(90, 0,heart_logo_small_1,15,15, WHITE);
   
   }
   else if(heart_screen>=5 && heart_screen<10)
   {
   display.drawBitmap(90, 0,black,30,30, WHITE);
   display.drawBitmap(90, 0,heart_logo_small_2,20,20, WHITE);
   
   }
   else if(heart_screen>=10 && heart_screen<15)
   {
    display.drawBitmap(90, 0,heart_logo, 30,30, WHITE);

   
   }
   display.display();
   heart_screen++;
   if(heart_screen>14)
   {
    heart_screen=0;
   }
   lcd.print(0, 0, "   Heart Rate   "); 
   lcd.print(0,1,"     ");
   lcd.print(4, 1,"   ");
   lcd.print(4, 1,HRclean);
   lcd.print(7, 1,"Bpm     ");
  }
 
}

/*===================== MENU 3: OXYGEN_LEVEL ==========================*/
void oxygen_level(int i)
{
  if(i==1)
  {
  Serial.println("Oxygen");
  Serial.println(SpO2);
   display.clearDisplay();
   display.setCursor(0,0);
   display.setTextSize(1);
   //display.setTextColor(WHITE);
   display.println("Oxygen_level");
   display.setTextSize(2);
   display.setCursor(0,9);
   display.print(SpO2);
    display.print("%");
   if(oxygen_screen>=0 && oxygen_screen<10)
   {
   display.drawBitmap(90, 0,lung_logo, 30,30, WHITE);
   
   }
   else if(oxygen_screen>=10 && oxygen_screen<20)
   {
   
   display.drawBitmap(90, 0,o_logo,30,30, WHITE);
   
   }
  
   display.display();
   oxygen_screen++;
   if(oxygen_screen>19)
   {
    oxygen_screen=1;
   }
   lcd.print(0, 0, "  Oxygen_level  "); 
   lcd.print(0,1,"      ");
   lcd.print(5, 1,"   ");
   lcd.print(5,1,SpO2);
   lcd.print(8,1,"%     ");
  }
 
}

/*===================== MENU 4: TEMPERATURE ==========================*/
void temperature(int i)
{
  
  Vo = analogRead(ThermistorPin);
  R2 = R1 * (1023.0 / (float)Vo - 1.0);
  logR2 = log(R2);
  T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
  Tc = T - 273.15;
  Tf = (Tc * 9.0)/5.0 + 32.0; 
  if(i==1)
  {
  Serial.print("Temperature: "); 
  Serial.print(Tf);
  Serial.print(" F; ");
  Serial.print(Tc);
  Serial.println(" C");  
  display.clearDisplay();
  display.setCursor(0,0);
  display.setTextSize(2);
  display.println(Tc,1);
  display.setCursor(50,0);
  display.setTextSize(1);
  display.print("o");
  display.setCursor(60,0);
  display.setTextSize(2);
  display.print("C");
  display.setCursor(0,16);
  display.println(Tf,1);
  display.setCursor(50,16);
  display.setTextSize(1);
  display.print("o");
  display.setCursor(60,16);
  display.setTextSize(2);
  display.print("F");
  display.drawBitmap(85, 0,thermometer, 33,32, WHITE);
  display.display();
  
   lcd.print(0,0,"Body Temperature");
   lcd.print(0,1,int(Tc));
   lcd.print(3,1,"C   ");
   lcd.print(8,1,int(Tf));
   lcd.print(10,1,"F     ");
  
  }
}

/*===================== MENU 5: GPS_STATUS ==========================*/
 BLYNK_WRITE(V4) 
  {
   GpsParam gps(param);
   sprintf(context,"lat=%.6f$lng=%.6f",gps.getLat(),gps.getLon());
   sprintf(lattitude,"lat=%.6f",gps.getLat());
   sprintf(longitude,"lng=%.6f",gps.getLon());
 }
void gps()
{
 
  
  Serial.println(lattitude);
  Serial.println();
  Serial.println(longitude);
  display.clearDisplay();
  display.setTextSize(1);
  display.setCursor(0,0);
  display.setTextSize(2);
  display.println("  GPS");
  display.setTextSize(1);
  display.println(lattitude);
  display.println(longitude);
  display.drawBitmap(90, 0,satellite, 30,30, WHITE);
  display.display();
   lcd.print(0,0,lattitude);
   lcd.print(0,1,longitude);
   lcd.print(13, 0,"   ");
   lcd.print(13, 1,"   ");
  
}

void ubi_dots()
{
  
  Serial.println(context);
  heart_rate(0);
  oxygen_level(0);
  temperature(0);
  ubidots.add("Temperature",Tf);  // Change for your variable name
  ubidots.add("heart_rate",HRclean);
  ubidots.add("oxygen_level",SpO2);
  ubidots.send();
  if( minute()%10==0)
  {
  ubidots.add("position",1.0,context); 
  ubidots.send();
  }
  Blynk.virtualWrite(V0,Tf);
  Blynk.virtualWrite(V1,HRclean);
  Blynk.virtualWrite(V2,SpO2);
  if(Tf>103)
  {
    Blynk.email("rengarider31@gmail.com", "Patient:Renga","Temperature is beyond normal");
  }
  if(heart>103)
  {
    Blynk.email("rengarider31@gmail.com", "Patient:Renga","Heart rate is beyond normal");
  }
  if(oxygen<90 &&oxygen >0)
  {
    Blynk.email("rengarider31@gmail.com", "Patient:Renga","Oxygen level is less than  normal");
  }
  Serial.println("data sent");
}


void setup() {
  
   Serial.begin(115200);
   display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  
   display.clearDisplay();
   button.begin();
   button.enableInterrupt(update_menu); // enabling interrupt to call update_menu function
   
    pox.begin();
    pox.setOnBeatDetectedCallback(onBeatDetected); 
    pox.setIRLedCurrent(LED_CURRENT);  
    sensor.setMode(MAX30100_MODE_SPO2_HR);
    sensor.setLedsPulseWidth(PULSE_WIDTH);
    sensor.setSamplingRate(SAMPLING_RATE); 
   
   display.setTextSize(2);
   display.setTextColor(WHITE);
   display.println("CONNECTING");
   display.println("  TO NET  ");
   display.display();
   delay(500);
   ubidots.wifiConnect(WIFI_SSID, WIFI_PASS);
   Blynk.begin(auth,WIFI_SSID,WIFI_PASS);// connecting to Network
   display.clearDisplay();
   setSyncInterval(10* 60); //every 10min the system will sync the time from internet
   //timer.setInterval(60000L, clockDisplay);
   lcd.clear(); //Use it to clear the LCD Widget
   lcd.print(0,0,"     ACTIVE     ");
   lcd.print(0,1,"     TRACKER    ");
  
   heart_rate(0);
   oxygen_level(0);
   temperature(0);
}


void loop() {
    pox.update();
    HRclean = pox.getHeartRate();
    SpO2 = pox.getSpO2();
  
  if(millis()-update_timer >60000)
  {
   update_timer=millis();
   heart_rate(0);
   oxygen_level(0);
   temperature(0);
   ubi_dots();
  }
if(millis()-on_screen <60000)
{  
  if(menu==1)
  {
   temperature(0);
   clock_display();
   delay(100);
  }
  else if(menu==2)
  {
   heart_rate(1);
   delay(150);
  }
  else if(menu==3)
  {
   oxygen_level(1);
   delay(150);
  }
  else if(menu==4)
  {
    temperature(1);
    delay(150);
  }
  else if(menu==5)
  {
    gps();
    delay(150);
  }
  else if(menu>5)
  {
    menu=1;
  }
}
else
{
  Serial.println("sleep"); 
  menu=0;
  display.clearDisplay();
  display.display();
}
  Blynk.run();//communicate to mobile
}

Credits

Renga

Renga

7 projects • 6 followers

Comments

Add projectSign up / Login