Translate

MONITOR ECG BPM DAN RESPIRASI SERTA SUHU TUBUH VIA IOT BLYNK 2.0

MONITOR ECG BPM DAN RESPIRASI SERTA SUHU TUBUH VIA IOT BLYNK 2.0


        Pada kesempatan kali ini saya akan mendemokan sebuah alat yang bisa memonitor ECG BPM dan respirasi serta suhu tubuh secara bergantian dalam satu alat. fitur dari alat ini yaitu mengguakan IOT Blynk 2.0 sehingga bisa dimonitor secara jarak jauh menggunakan internet. untuk lebih jelasnya berikut komponen dan kodingnya.



a. Komponen





b. Program Arduino IDE

#define BLYNK_TEMPLATE_ID "TMPL6p5131qBk"
#define BLYNK_TEMPLATE_NAME "baby inkubator"
#define BLYNK_AUTH_TOKEN "9lmYS6XNCggK7TwRS9rddlu7HNXUkWjo"
#define BLYNK_PRINT Serial  
  
#include <Wire.h>
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <LiquidCrystal_I2C.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 0  

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
LiquidCrystal_I2C lcd(0x27,16,2);

int n = 0;
int bpm = 0;
int x = 0;
int buzzer = D6;
int respirasipin;
int bpmku;
int respirasiku;

int m = 0;
int resp = 0;
int w = 0;

int suhux = 0;
int bpmx = 0;
float TempC;
int gsrz;
int suhuz;
int bpmz;
int respirasiz;

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

void sendSensor()
{
 Blynk.virtualWrite(V0, bpmku);
 Blynk.virtualWrite(V2, respirasiku);
 Blynk.virtualWrite(V1, TempC);
 delay(1000);
}

void setup() {
 
  Serial.begin(9600);
  pinMode(buzzer,OUTPUT);
  pinMode(D5,INPUT_PULLUP);
  digitalWrite(buzzer,LOW);
  lcd.begin();
  lcd.clear();
  lcd.noCursor();
  Wire.begin();  
  sensors.begin();
  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
  timer.setInterval(1000L, sendSensor);
 
}

void loop() {
n = 0;
m = 0;
bpm = 0;
resp = 0;

tampilbpm();
tampilrespirasi();
tampilsuhu();

  lcd.setCursor(0, 0);
  lcd.print("BPM: ");
  lcd.print(bpmku);
  lcd.print(" / ");
  lcd.print(TempC);
  lcd.print("   ");
  
  lcd.setCursor(0, 1);
  lcd.print("RESP = ");
  lcd.print(respirasiku);

Blynk.run();
timer.run();

delay(3000);
lcd.clear();        
}

void tampilbpm(){
n = n + 1;

  int dataadc1 = analogRead(A0);          

  lcd.setCursor(0, 0);
  lcd.print("n = ");
  lcd.print(n);
   
  lcd.setCursor(0, 1);
  lcd.print("BPM = ");
  lcd.print(bpm);

  if ((dataadc1 > 512) && (x > 1)) {  
  //digitalWrite(led, HIGH);
  x = 0;
  bpm = bpm + 1;
  }

  else if ((dataadc1 < 512) && (x < 1)) {
  x = 2;
  //digitalWrite(led, LOW);

  }

  delay(200);

  if ( n > 50 ) {
  lcd.clear();
  bpmku = bpm * 6;
  return;
  }

 tampilbpm();
}

void tampilrespirasi(){
m = m + 1;
 
  int dataadc2 = digitalRead(D5);          

  lcd.setCursor(0, 0);
  lcd.print("m = ");
  lcd.print(m);
   
  lcd.setCursor(0, 1);
  lcd.print("RESP = ");
  lcd.print(resp);

  if ((dataadc2 == 1) && (w > 1)) {  
  //digitalWrite(led, HIGH);
  w = 0;
  resp = resp + 1;
  }

  else if ((dataadc2 == 0) && (w < 1)) {
  w = 2;
  //digitalWrite(led, LOW);

  }

  delay(200);

  if ( m > 50 ) {
  lcd.clear();
  respirasiku = resp * 6;
  return;
  }
 
  tampilrespirasi();
}

void tampilsuhu(){
  sensors.requestTemperatures();
  TempC = sensors.getTempCByIndex(0); // Celcius
}




c. VIDEO HASILNYA




No comments:

Post a Comment