Translate

Membuat Alat Pasien Monitor Suhu Tubuh DS18B20, BPM heart beat, Respirasi Sound Sensor, GSR Kelenjar Keringat via INTERNET IOT ethernet web server

Membuat Alat Pasien Monitor Suhu Tubuh DS18B20, BPM heart beat, Respirasi Sound Sensor, GSR Kelenjar Keringat via INTERNET IOT ethernet web server


          Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat alat untuk monitoring suhu tubuh, heart beat BPM, respirasi dan keringat tubuh GSR. alat ini dilengkapi dengan fasilitas internet atau database online, jadi data akan masuk ke server dan ditampilkan via website. untuk lebih jelasnya berikut adalah skema dan programnya.



a. Arduino + Ethernet Shield




b. Sensor Suhu DS18b20




c. Sensor Respirasi / SOUND SENSOR




d. Sensor GSR




e. Sensor BPM / Heart Beat





f. Program Arduino IDE

#include "Wire.h"
#include <LiquidCrystal_I2C.h>
#include <OneWire.h>
#include <SPI.h>
#include <Ethernet.h>

LiquidCrystal_I2C lcd(0x3F,16,2);

OneWire  ds(7);  // 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 led = 8;

int bt1 = 2;

int bt1x = 0;

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

String txData="";
int gsrz;
int suhuz;
int bpmz;
int respirasiz;

String txData2="";

byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
  char server[] = "www.alat-pasien-monitor.com";
IPAddress ip(192,168,0,99);

EthernetClient client;



void setup() {
 
  Serial.begin(9600);
  while (!Serial) {
    ;
  }

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    Ethernet.begin(mac, ip);
  }

    delay(1000);
    Serial.println("connecting...");
  //  kirim ();

  lcd.begin();
  lcd.clear();
  lcd.noCursor();

  pinMode(led,OUTPUT);

  pinMode(bt1,INPUT_PULLUP); 

  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("START");
 
  bt1x = digitalRead(bt1);

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

  digitalWrite(led,LOW);
 
bpm = 0;
resp = 0;

tampilbpm();
tampilrespirasi();
tampilsuhu();
tampilgsr();
kirimbt();

}
        
}


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(led, HIGH);
  x = 0;
  bpm = bpm + 1;
  }

  else if ((dataadc1 < 512) && (x < 1)) {
  x = 2;
  digitalWrite(led, 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(led, HIGH);
  w = 0;
  resp = resp + 1;
  }

  else if ((dataadc2 < 512) && (w < 1)) {
  w = 2;
  digitalWrite(led, 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(){

lcd.setCursor(0,0);
lcd.print("S=");
lcd.print(celsius);
lcd.print(" B=");
lcd.print(bpm);
lcd.print("      ");

lcd.setCursor(0,1);
lcd.print("R=");
lcd.print(resp);
lcd.print(" G=");
lcd.print(voltgsr);
lcd.print("      ");

gsrz = voltgsr;
bpmz = bpm;
suhuz = celsius;
respirasiz = resp;

/*
 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");
 }
*/

kirim();

kirimbt();

}



void kirim (){

  EthernetClient client;

if (client.connect(server, 80)){
    txData = "gsrz="+ (String (gsrz)) + "&bpmz=" + (String (bpmz)) + "&suhuz=" + (String (suhuz)) + "&respirasiz=" + (String (respirasiz));           
    Serial.println("connected");
    Serial.print(txData);
    client.println("POST /updatex.php HTTP/1.1");
    client.println("Host: www.alat-pasien-monitor.com");
    client.println("Connection: close");
    client.print("Content-Type: application/x-www-form-urlencoded\n");
    client.print("Content-Length: ");
    client.print(txData.length());
    client.print("\n\n");
    client.print(txData);
    Serial.println(txData);    
    delay (5000);
        
  }  
  else{
    Serial.println("Connection Failed.");
    Serial.println();
    delay (3000);
  }
}



 
g. VIDEO HASILNYA












No comments:

Post a Comment