Ashwini kumar sinha
Created June 25, 2020 © MIT

Opensource Remote Covid-19 Oxymeter

This help doctors to do checkup remotely by reading patients data remotely. It reads the Health data Spo2 , Pulse, Temp and send to doctor.

IntermediateProtip5 hours15

Things used in this project

Story

Read more

Schematics

Schematics

Code

Code

Arduino
// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_SSD1306_RK.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <FreeSerif12pt7b.h>
#include <FreeMono9pt7b.h>
#include <FreeMono12pt7b.h>	
#include <FreeMonoOblique9pt7b.h>		
#include <TomThumb.h>
#include <FreeMonoBold12pt7b.h>	
#include <Org_01.h>	
#include <FreeMonoBold9pt7b.h>	
#define OLED_RESET D4
Adafruit_SSD1306 display(OLED_RESET);
#include "application.h"
SYSTEM_MODE (AUTOMATIC);
SYSTEM_THREAD (ENABLED);
#include "MAX30100_PulseOximeter.h"
#include "application.h"
#define REPORTING_PERIOD_MS     1000
#define slaveAddress 0x5A


PulseOximeter pox;
int BPM,sp;
float t;
uint32_t tsLastReport = 0;
uint32_t tsLastReport1 = 0;
int LED = D7;
int r1=0;
int r2=0;
// Callback (registered below) fired when a pulse is detected

//////////////////////////////////


const unsigned char bitmap [] PROGMEM=
{
 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x18, 0x00, 0x0f, 0xe0, 0x7f, 0x00, 0x3f, 0xf9, 0xff, 0xc0, 
 0x7f, 0xf9, 0xff, 0xc0, 0x7f, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff, 0xf0, 
  0xff, 0xf7, 0xff, 0xf0, 0xff, 0xe7, 0xff, 0xf0, 0xff, 0xe7, 0xff, 0xf0, 0x7f, 0xdb, 0xff, 0xe0, 
  0x7f, 0x9b, 0xff, 0xe0, 0x00, 0x3b, 0xc0, 0x00, 0x3f, 0xf9, 0x9f, 0xc0, 0x3f, 0xfd, 0xbf, 0xc0, 
  0x1f, 0xfd, 0xbf, 0x80, 0x0f, 0xfd, 0x7f, 0x00, 0x07, 0xfe, 0x7e, 0x00, 0x03, 0xfe, 0xfc, 0x00, 
  0x01, 0xff, 0xf8, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x00, 0x7f, 0xe0, 0x00, 0x00, 0x3f, 0xc0, 0x00, 
  0x00, 0x0f, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};




///////////////////////////////////
//////////////////////////////////////////////////////////

const BleUuid serviceUuid("5c1b9a0d-b5be-4a40-8f7a-66b36d0a5176");
BleCharacteristic spo2Characteristic("spo2", BleCharacteristicProperty::NOTIFY, BleUuid("fdcf4a3f-3fed-4ed2-84e6-04bbb9ae04d4"), serviceUuid);
BleCharacteristic bpmSourceCharacteristic("bpm", BleCharacteristicProperty::NOTIFY, BleUuid("cc97c20c-5822-4800-ade5-1f661d2133ee"), serviceUuid);
BleCharacteristic beatCharacteristic("beat", BleCharacteristicProperty::NOTIFY, BleUuid("d2b26bf3-9792-42fc-9e8a-41f6107df04c"), serviceUuid);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////

void onBeatDetected()
{
  Serial.println("Beat!");
  digitalWrite(LED,1);
  display.drawBitmap( 2, 3, bitmap, 28, 28,0);
  display.display(); 
  //delay(100);
}

void setup()
{
    pinMode(LED,OUTPUT);
    Serial.begin(115200);
    pox.begin();
   
    pox.setOnBeatDetectedCallback(onBeatDetected);
    
    display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  
    display.clearDisplay(); 
    display.setTextWrap(false);
     /// ble char setting 
	BLE.addCharacteristic(spo2Characteristic);
	BLE.addCharacteristic(bpmSourceCharacteristic);
	BLE.addCharacteristic(beatCharacteristic);
    ///for blr 
	BleAdvertisingData advData;
	// Advertise our private service only
	advData.appendServiceUUID(serviceUuid);
    // Continuously advertise when not connected
	BLE.advertise(&advData);
}

void loop()
{
    
pox.update();
BPM=pox.getHeartRate();
sp=pox.getSpO2();
t=pox.getTemperature();
digitalWrite(LED,1);

 r1 =map(sp, 0,100,0,110);
 r2 =map(BPM,0,100,0,110);
 
Serial.print("Heart rate:");
Serial.print(BPM);
Serial.print("bpm / SpO2:");
Serial.print(sp);
Serial.println("% ");
  digitalWrite(LED,0);
  
  			uint8_t sp02level[1];
			uint8_t bpmlevel[1];
			
			sp02level[0] = sp>> 4;
			bpmlevel[0] = BPM >> 4;
		
			
		    spo2Characteristic.setValue(sp02level);
		    bpmSourceCharacteristic.setValue(bpmlevel);
		   
		    
   
    
    Mesh.publish("spo2", String(sp));
    Mesh.publish("bpm", String(BPM));
  
if (millis() - tsLastReport1 > 1000) {
Particle.publish("BPM", String(BPM));
Particle.publish("spo2", String(sp));
Particle.publish("temp", String(t));
tsLastReport1 = millis();
}
 oleddis();
}

void oleddis(){
     display.clearDisplay(); 
     display.setFont(NULL);
     display.drawBitmap( 2, 3, bitmap, 28, 28, 1);
     display.setTextSize(1);
     display.setTextColor(WHITE);
     display.setCursor(30,20);
     display.setFont(&FreeMonoBold9pt7b);
     display.print("=");
     display.print(BPM);
     display.setFont(NULL);
     display.drawRoundRect(0, 30, 120, 8, 6, WHITE);
     display.fillRoundRect(0, 30, r2, 8, 6, WHITE);
     
     display.setTextSize(1);
     display.setTextColor(WHITE);
     display.setCursor(0,44);
     display.setFont(&FreeMonoBold9pt7b);
     display.print("Spo2=");
     display.setFont(&FreeMonoBold9pt7b);
     display.print(sp);
     display.print("%");
     display.drawRoundRect(0, 54, 120, 8, 6, WHITE);
     display.fillRoundRect(0, 54, r1, 8, 6, WHITE);
     display.display(); 
     
     
}

Credits

Ashwini kumar sinha

Ashwini kumar sinha

20 projects • 37 followers
Ashwini kumar sinha a Robotic lover and electronics hobbyist. Works at EFY-I

Comments