Translate

Membuat Alat Pasien Monitor ( Suhu Tubuh, Heart Beat / HB, GSR / keringat tubuh, Respirasi) Menggunakan Arduino dan Monitor via Android Smartphone

Membuat Alat Pasien Monitor ( Suhu Tubuh, Heart Beat / HB, GSR / keringat tubuh, Respirasi) Menggunakan Arduino dan Monitor via Android Smartphone


         Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat alat yang berfungsi untuk monitor kesehatan pasien mengenai suhu tubuh, heart beat atau detak jantung / HB, GSR atau keringat tubuh, dan respirasi atau laju pernafaan, semua dimonitor dengan waktu satu menit, jadi lama pengambilan HB dan respirasi adalah 1 menit kemudian untuk GSR dan suhu sudah otomatis mendeteksi ketika alat dihidupkan. alat ini bisa mengirimkan hasil ke smartphone android terkait hasil 4 parameter tersebut dan juga terdapat kesimpulan dan saran yang harus dilakukan. untuk lebih jelasnya berikut adalah skema dan programnya.  



a. Arduino Uno




b. Bluetooth HC-05




c. Sensor Suhu DS18b20




d. Sensor Pulse / Heart Beat




e. Sensor GSR / Keringat




f. Sensor Suara / Hembusan




g. LCD 16x2 + I2C





h. Program Android







i. Program Arduino

#include "Wire.h"
#include <LiquidCrystal_I2C.h>
#include <OneWire.h>
LiquidCrystal_I2C lcd(0x27,16,2);

OneWire  ds(10);  // on pin 10 (a 4.7K resistor is necessary)

int n = 0;
int bpm = 0;
int x = 0;

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

int suhux = 0;
int bpmx = 0;

int ledgsr = 6;
int ledbpm = 7;
int ledrespirasi = 8;
int ledsuhu = 9;

int bt1 = 2;
int bt2 = 3;
int bt3 = 4;
int bt4 = 5;

int bt1x = 0;
int bt2x = 0;
int bt3x = 0;
int bt4x = 0;

  byte i;
  byte present = 0;
  byte type_s;
  byte data[12];
  byte addr[8];
  float celsius, fahrenheit;
  float voltgsr;

void setup() {
  
  Serial.begin(9600);
  lcd.begin();
  lcd.clear();
  lcd.noCursor();

  pinMode(ledgsr,OUTPUT);
  pinMode(ledbpm,OUTPUT);
  pinMode(ledrespirasi,OUTPUT);
  pinMode(ledsuhu,OUTPUT);

  pinMode(bt1,INPUT_PULLUP);
  pinMode(bt2,INPUT_PULLUP);
  pinMode(bt3,INPUT_PULLUP);
  pinMode(bt4,INPUT_PULLUP);
  
  digitalWrite(ledsuhu,HIGH);
  digitalWrite(ledgsr,HIGH);

  lcd.setCursor(0, 0);
  lcd.print("WELLCOME");
  delay(3000);
  lcd.clear();
  
}


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

  lcd.setCursor(0, 0);
  lcd.print("Tekan Tombol");
  lcd.setCursor(0, 1);
  lcd.print("HIJAU");
  
  bt1x = digitalRead(bt1);
  bt2x = digitalRead(bt2);
  bt3x = digitalRead(bt3);
  bt4x = digitalRead(bt4);

if(bt3x == 0){
  lcd.clear();
  delay(2000);

  digitalWrite(ledsuhu,LOW);
  digitalWrite(ledgsr,LOW);
  digitalWrite(ledbpm,LOW);
  digitalWrite(ledrespirasi,LOW);
bpm = 0;
resp = 0;

tampilbpm();
  digitalWrite(ledbpm,LOW);
tampilrespirasi();
  digitalWrite(ledrespirasi,LOW);

tampilsuhu();
tampilgsr();
kirimbt();

}

  digitalWrite(ledbpm,LOW);
  digitalWrite(ledrespirasi,LOW);
         
}


void tampilbpm(){
n = n + 1;

  int dataadc1 = analogRead(A1);           
  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(ledbpm, HIGH);
  x = 0;
  bpm = bpm + 1;
  }
  else if ((dataadc1 < 512) && (x < 1)) {
  x = 2; 
  digitalWrite(ledbpm, LOW);
  }
  delay(200);
  if ( n > 300 ) {
  lcd.clear();
  return;
  }
 tampilbpm(); 
}




void tampilrespirasi(){
m = m + 1;
  
  int dataadc2 = analogRead(A2);           
  lcd.setCursor(0, 0);
  lcd.print("m = ");
  lcd.print(m);
    
  lcd.setCursor(0, 1);
  lcd.print("RESP = ");
  lcd.print(resp);
  if ((dataadc2 > 512) && (w > 1)) {   
  digitalWrite(ledrespirasi, HIGH);
  w = 0;
  resp = resp + 1;
  }
  else if ((dataadc2 < 512) && (w < 1)) {
  w = 2; 
  digitalWrite(ledrespirasi, LOW);
  }
  delay(200);
  if ( m > 300 ) {
  lcd.clear();
  return;
  }
  
  tampilrespirasi();
}





void tampilsuhu(){

   
  if ( !ds.search(addr)) {
    //Serial.println("No more addresses.");
    //Serial.println();
    ds.reset_search();
    delay(250);
    return;
  }
  //Serial.print("ROM =");
  for( i = 0; i < 8; i++) {
    //Serial.write(' ');
    //Serial.print(addr[i], HEX);
  }

  if (OneWire::crc8(addr, 7) != addr[7]) {
      //Serial.println("CRC is not valid!");
      return;
  }
  //Serial.println();

   //the first ROM byte indicates which chip
  switch (addr[0]) {
    case 0x10:
      //Serial.println("  Chip = DS18S20");  // or old DS1820
      type_s = 1;
      break;
    case 0x28:
      //Serial.println("  Chip = DS18B20");
      type_s = 0;
      break;
    case 0x22:
      //Serial.println("  Chip = DS1822");
      type_s = 0;
      break;
    default:
      //Serial.println("Device is not a DS18x20 family device.");
      return;
  }

  ds.reset();
  ds.select(addr);
  ds.write(0x44, 1);        // start conversion, with parasite power on at the end
  delay(1000);     // maybe 750ms is enough, maybe not
  // we might do a ds.depower() here, but the reset will take care of it.
  present = ds.reset();
  ds.select(addr);   
  ds.write(0xBE);         // Read Scratchpad

  //Serial.print("  Data = ");
  //Serial.print(present, HEX);
  //Serial.print(" ");
  for ( i = 0; i < 9; i++) {           // we need 9 bytes
    data[i] = ds.read();
    //Serial.print(data[i], HEX);
    //Serial.print(" ");
  }
  //Serial.print(" CRC=");
  //Serial.print(OneWire::crc8(data, 8), HEX);
  //Serial.println();

  // Convert the data to actual temperature
  // because the result is a 16 bit signed integer, it should
  // be stored to an "int16_t" type, which is always 16 bits
  // even when compiled on a 32 bit processor.
  int16_t raw = (data[1] << 8) | data[0];
  if (type_s) {
    raw = raw << 3; // 9 bit resolution default
    if (data[7] == 0x10) {
      // "count remain" gives full 12 bit resolution
      raw = (raw & 0xFFF0) + 12 - data[6];
    }
  } else {
    byte cfg = (data[4] & 0x60);
    // at lower res, the low bits are undefined, so let's zero them
    if (cfg == 0x00) raw = raw & ~7;  // 9 bit resolution, 93.75 ms
    else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
    else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
    //// default is 12 bit resolution, 750 ms conversion time
  }
  celsius = (float)raw / 16.0;
//  lcd.setCursor(0,0);
//  lcd.print("SUHU = ");
//  lcd.print(celsius);
//  lcd.print(" C ");
  return;
}




void tampilgsr(){

int dataadc0 = analogRead(A0);
 voltgsr = dataadc0 * (4.2 / 1023);

return;

}




void kirimbt(){

  bt1x = digitalRead(bt1);
  bt2x = digitalRead(bt2);
  bt3x = digitalRead(bt3);
  bt4x = digitalRead(bt4);

lcd.setCursor(0,0);
lcd.print("SUHU =");
lcd.print(celsius);

if(bt1x == 0){
delay(200);  
lcd.setCursor(0,1);
lcd.print("BPM =");
lcd.print(bpm);
lcd.print("      ");
}

if(bt2x == 0){
delay(200);  
lcd.setCursor(0,1);
lcd.print("Resp =");
lcd.print(resp);
lcd.print("      ");
}

if(bt4x == 0){
delay(200);  
lcd.setCursor(0,1);
lcd.print("GSR =");
lcd.print(voltgsr);
lcd.print("      ");
}

if(bt3x == 0){
lcd.clear();  
delay(3000);
  return;
}

  Serial.print("suhu = ");
  Serial.print(celsius);
  Serial.println(" c");
  Serial.print("BPM = ");
  Serial.println(bpm);

  Serial.print("Resp = ");
  Serial.print(resp);
  Serial.println(" kali/menit");
  Serial.print("GSR = ");
  Serial.print(voltgsr); 
  Serial.println(" v");

  Serial.println("  ");
 if ( bpm >= 100 ) {
 Serial.println("perbanyak istirahat dan ");
 }
else if ( bpm < 60 ) {
 Serial.println("segera hubungi dokter ");
 }

 if ( celsius >= 37.5 ) {
 Serial.println("kompres dengan air dingin");
 }
else if ( celsius < 34.0 ) {
 Serial.println("perbanyak aktifitas ");
 }

 if ( voltgsr >= 4 ) {
 Serial.println("Perbanyak menghibur diri");
 }

  
 if (( bpm > 100 ) && ( celsius > 37.5 ) && ( voltgsr > 4 )) {
 Serial.println("Terdeteksi STRESS");
 Serial.println("hibur diri dan konsul ke psikiater");
 } 


 kirimbt(); 

}






j. VIDEO HASILNYA












No comments:

Post a Comment