IoT-BangladeshSalah Uddin
Published © LGPL

Covid-19 Patient Monitoring Device based on LoRa

Lora network based covid-19 patient monitoring device.

AdvancedFull instructions providedOver 2 days10,259
Covid-19 Patient Monitoring Device based on LoRa

Things used in this project

Story

Read more

Schematics

circuit diagram

Code

source

Arduino
#include <TheThingsNetwork.h>
#include <SPI.h>
#include <MAX30100_PulseOximeter.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>


// Set your AppEUI and AppKey
const char *appEui = "0000000000000000";
const char *appKey = "00000000000000000000000000000000";

#define loraSerial Serial1
#define debugSerial Serial

// Replace REPLACE_ME with TTN_FP_EU868 or TTN_FP_US915
#define freqPlan REPLACE_ME

//VARIABLE TO HOLD THE SENSORS DATA
int bpm;
int spo2;
float temp;

//the sea level presure in your region (****)
Adafruit_BME280 bme; 		// BME280  Sensnor declaration 
unsigned long currentMillis;   //hold the current time



//pulse oximeter time period (measurment time period)
#define REPORTING_PERIOD_MS     1000
PulseOximeter pox;
uint32_t tsLastReport = 0;

// Callback (registered below) fired when a pulse is detected
void onBeatDetected()
{
    // Serial.println("Beat!");
}


void measured_pulse(){
    
    pox.update();
    if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
      bpm=pox.getHeartRate();
      tsLastReport = millis();
    }
    
}


TheThingsNetwork ttn(loraSerial, debugSerial, freqPlan);

void setup()
{
  loraSerial.begin(57600);
  debugSerial.begin(9600);

  // Wait a maximum of 10s for Serial Monitor
  while (!debugSerial && millis() < 10000)
    ;

  debugSerial.println("-- STATUS");
  ttn.showStatus();

  debugSerial.println("-- JOIN");
  ttn.join(appEui, appKey);
  
  Serial.println(F("BME280 test"));
  Serial.println("Initializing MAX30100");
  
  pox.begin();
  pox.setOnBeatDetectedCallback(onBeatDetected);
  
  bool status;
  
  status = bme.begin();
  if (!status) {
    Serial.println("Could not find a valid BME280 sensor, check wiring!");
    while (1);
  }

  pinMode(7, OUTPUT);
  pinMode(A0,INPUT);
  pinMode(8,INPUT);
  pinMode(6,INPUT);

}



void loop()
{
  debugSerial.println("-- LOOP");
  
  h_rate = analogRead(A0);
  button = digitalRead(8);
  temperature = pox.getTemperature();
  spo2 = pox.getSpO2();
  bpm =  bpm;
  humidity =  bme.readHumidity();
  movement = digitalRead(6);
 
 
 
 
 


  byte payload[6];
  payload[0] = highByte(bpm);
  payload[1] = lowByte(temperature);
  payload[2] = highByte(humidity);
  payload[3] = lowByte(movement);
  payload[4] = lowByte(spo2);
  payload[5] = lowByte(button);
  payload[6] = lowByte(h_rate);

  debugSerial.print("Temperature: ");
  debugSerial.println(temperature);
  debugSerial.print("Humidity: ");
  debugSerial.println(humidity);
  
  debugSerial.print("BPM: ");
  debugSerial.println(bpm);
  debugSerial.print("SPO2: ");
  debugSerial.println(spo2);
  
  debugSerial.print("H_rate: ");
  debugSerial.println(h_rate);
  
  debugSerial.print("Button: ");
  debugSerial.println(button);
  debugSerial.print("Movement: ");
  debugSerial.println(movement);


  ttn.sendBytes(payload, sizeof(payload));

  delay(20000);
}

Credits

IoT-Bangladesh

IoT-Bangladesh

19 projects • 49 followers
Salah Uddin

Salah Uddin

44 projects • 148 followers
Technology and IoT Hacker, Robot Killer and Drone lover.

Comments