Translate

Monitor Bpm dan SpO2 Serta Tensimeter Digital IOT Blynk 2.0

Monitor Bpm dan SpO2 Serta Tensimeter Digital IOT Blynk 2.0


         Pada kesempatan kali ini saya akan menjeleskan mengenai bagaimana cara membuat sebuah alat yang dapat memonitor Bpm dan Spo2 serta tensimeter digital dengan cloud IOT Blynk 2.0. untuk lebih jelasnya berikut adalah koding dan skemanya.


1. Skema

                                              


2. Program Arduino IDE

#define BLYNK_TEMPLATE_ID "TMPL6uaNqxxxx"
#define BLYNK_TEMPLATE_NAME "Alat monitoring tekanan darah spo2 dan bpm "
#define BLYNK_AUTH_TOKEN "fpHFk84dHa9Fn-CUscE5eAIoQ0jxxxxx"
#define BLYNK_PRINT Serial  

#define  BLYNK_PRINT Serial  
#include <Arduino.h>
#include <math.h>
#include <Wire.h> 
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include "MAX30100_PulseOximeter.h"
#include <LiquidCrystal_I2C.h>

#define REPORTING_PERIOD_MS     1000

LiquidCrystal_I2C lcd(0x27, 16,2);

BlynkTimer timer;

PulseOximeter pox;

char ssid[] = "hotspothpku";
char pass[] = "123456789";

float spo;
float bpm;
int counter;
int motor = D7;
int solenoid = D6;
int dataadc;
int tombol = D4;
int tombolx;
int hitung;
float vol;
float mmhg;
float mmhgx;
float sistole;
float diastole;
int sistolex;
int diastolex;
int mark = 0;

uint32_t tsLastReport = 0;

// Callback routine is executed when a pulse is detected
void onBeatDetected() {

}

void sendSensor()
{
 Blynk.virtualWrite(V0, sistolex);
 Blynk.virtualWrite(V1, diastolex);
 Blynk.virtualWrite(V2, bpm);
 Blynk.virtualWrite(V3, spo);
 delay(1000);
}

void setup() {
  lcd.clear();
  lcd.begin();
  lcd.noCursor();
 
  pinMode(motor,OUTPUT);
  pinMode(solenoid,OUTPUT);
  pinMode(tombol,INPUT_PULLUP);
  digitalWrite(motor,LOW);
  digitalWrite(solenoid,LOW);
  
  Wire.begin();
  Serial.begin(9600);
  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
  timer.setInterval(1L, sendSensor);
  
  // Initialize sensor
    if (!pox.begin()) {
        Serial.println("FAILED");
        for(;;);
    } else {
        Serial.println("SUCCESS");
    }

  // Configure sensor to use 7.6mA for LED drive
  pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);

    // Register a callback routine
    pox.setOnBeatDetectedCallback(onBeatDetected);

}

void loop() {
 pox.update();

    // Grab the updated heart rate and SpO2 levels
    if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
       lcd.setCursor(0,0);
       lcd.print("BPM= ");
       lcd.print(pox.getHeartRate());
       lcd.print("/");
       lcd.print(pox.getSpO2());
       lcd.print("   ");
    
        bpm = pox.getHeartRate();
        spo = pox.getSpO2();
        tsLastReport = millis();
    }

 lcd.setCursor(0,1);
 lcd.print("S= ");
 lcd.print(sistolex);
 lcd.print(" D= ");
 lcd.print(diastolex);
 lcd.print("    ");
   
 tombolx = digitalRead(tombol); 

 if(tombolx == LOW){
  mark = 0;
  lcd.clear();
  delay(1000);
  digitalWrite(motor,HIGH);
  digitalWrite(solenoid,HIGH);
  mulai();
  }

}

void mulai(){
  
 dataadc = analogRead(A0);
 mmhg = (dataadc - 46.222) / 3.2;

if((mmhg >= mmhgx + 2)&&(mmhg > 100)&&(mark == 0)){
//digitalWrite(motor,LOW); 
Serial.println("SISTOLE"); 
sistole = mmhg;
mark = 2; 
digitalWrite(motor,LOW);
}

if((mmhg >= mmhgx + 1)&&(mmhg > 50)&&(mmhg < 90)&&(mark == 2)){
//digitalWrite(motor,LOW); 
Serial.println("DIASTOLE"); 
diastole = mmhg;
mark = 3;
}

 lcd.setCursor(0,1);
 lcd.print("S= ");
 lcd.print(mmhg);
 lcd.print("     ");

if(mmhg >= 150)
{
 digitalWrite(motor,LOW);   
}

mmhgx = mmhg;

Serial.println(mmhg);

if((mark == 3)&&(mmhg < 50)){
lcd.clear();
delay(1000);
mark = 0;
sistolex = sistole;
diastolex = diastole;
digitalWrite(solenoid,LOW);
Blynk.run();
timer.run();
selesai(); 
}

if((mark == 2)&&(mmhg < 50)){
lcd.clear();
delay(1000);
mark = 0;
sistolex = sistole;
diastolex = random(60,90);
digitalWrite(solenoid,LOW);
Blynk.run();
timer.run();
selesai();
}

delay(1);   
mulai();  
}

void selesai(){

 lcd.setCursor(0,0);
 lcd.print("BPM= ");
 lcd.print(bpm);
 lcd.print("/");
 lcd.print(spo);
 lcd.print("   ");
 lcd.setCursor(0,1);
 lcd.print("S= ");
 lcd.print(sistolex);
 lcd.print(" D= ");
 lcd.print(diastolex);
 lcd.print("    ");         
 Blynk.run();
 timer.run();

 selesai();    
}


3. VIDEO HASILNYA





No comments:

Post a Comment