Translate

MEMBUAT PASIEN MONITOR DENGAN ARDUINO LOADCELL HX711 AMPLIFIER, HEARTBEAT PULSE SENSOR, TEMPERATURE SENSOR DS18B20

MEMBUAT PASIEN MONITOR DENGAN ARDUINO LOADCELL HX711 AMPLIFIER, HEARTBEAT PULSE SENSOR, TEMPERATURE SENSOR DS18B20


            Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat alat untuk pasien monitor, alat ini dikhususkan untuk bayi jadi detak jantung, suhu tubuh dan beratnya harus sangat diperhatikan, maka dari itu sensor yang digunakan juga harus yang terbilang akurat, sensor yang dipakai yaitu loadcell 5Kg, pulse sensor, dan sensor suhu DS18B20. jika BPM lebih dari 150 maka buzzer akan berbunyi, dan juga jika ingin memulai counter BPM, bisa menekan tombol PLAY atau push button. untuk lebih jelasnya berikut skema dan programnya.



a. ARDUINO MEGA





b.PULSE SENSOR / HEART BEAT SENSOR





c.Loadcell + HX711





c. Sensor Suhu DS18B20 water proof






d. Program ARDUINO IDE

//library HX711 bisa di download di link berikut
//https://github.com/bogde/HX711 

#include <Wire.h>
#include <OneWire.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
#include "HX711.h"

// HX711.DOUT    - pin #21
// HX711.PD_SCK    - pin #20

HX711 scale(21, 20);        // parameter "gain" is ommited; the default value 128 is used by the library

OneWire  ds(10);  //output ds18b20 ke pin 10 arduino

int n = 0;
int bpm = 0;
int x = 0;
int suhux = 0;
int bpmx = 0;
int buzzer = 8;

const int buttonPin1 = 52;
int buttonState1 = 0;
const int buttonPin2 = 53;
int buttonState2 = 0;



void setup() {
 
  pinMode(buttonPin1, INPUT);
  digitalWrite(buttonPin1, HIGH);
  pinMode(buttonPin2, INPUT);
  digitalWrite(buttonPin2, HIGH);

  pinMode(buzzer, OUTPUT);
  digitalWrite(buzzer, LOW);

  lcd.begin(16, 2);
  lcd.clear();
  lcd.noCursor();
  pinMode(13, OUTPUT);
  Serial.begin(9600);

  Serial.println("Before setting up the scale:");
  Serial.print("read: \t\t");
  Serial.println(scale.read());            // print a raw reading from the ADC

  Serial.print("read average: \t\t");
  Serial.println(scale.read_average(20));      // print the average of 20 readings from the ADC

  Serial.print("get value: \t\t");
  Serial.println(scale.get_value(5));        // print the average of 5 readings from the ADC minus the tare weight (not set yet)

  Serial.print("get units: \t\t");
  Serial.println(scale.get_units(5), 1);    // print the average of 5 readings from the ADC minus tare weight (not set) divided
                        // by the SCALE parameter (not set yet) 

  scale.set_scale(2280.f);                      // this value is obtained by calibrating the scale with known weights; see the README for details
  scale.tare();                        // reset the scale to 0

  Serial.println("After setting up the scale:");

  Serial.print("read: \t\t");
  Serial.println(scale.read());                 // print a raw reading from the ADC

  Serial.print("read average: \t\t");
  Serial.println(scale.read_average(20));       // print the average of 20 readings from the ADC

  Serial.print("get value: \t\t");
  Serial.println(scale.get_value(5));        // print the average of 5 readings from the ADC minus the tare weight, set with tare()

  Serial.print("get units: \t\t");
  Serial.println(scale.get_units(5), 1);        // print the average of 5 readings from the ADC minus tare weight, divided
                        // by the SCALE parameter set with set_scale

  Serial.println("Readings:");

 
//  lcd.setCursor(0, 0);
//  lcd.print("WELLCOME");
//  delay(20000);
//  lcd.clear();

}

void loop() {
 
  buttonState1 = digitalRead(buttonPin1);
  buttonState2 = digitalRead(buttonPin2);
   
  int berat = scale.get_units(10) * -1;
  float fix = (berat - 0.036) / 0.191;
 
  if (fix < 0 ) {
  fix = 0;
  }
 
 // Serial.print("one reading:\t");
 // Serial.print(scale.get_units(), 1);
 // Serial.print("\t| average:\t");
 // Serial.println(scale.get_units(10), 1);

  lcd.setCursor(0, 0);
  lcd.print("Berat= ");
  lcd.print(fix);
  lcd.print(" gr");

  scale.power_down();                    // put the ADC in sleep mode
  delay(1000);
  scale.power_up();
 
  if (buttonState1 == LOW) {
  lcd.clear();
  n = 0;
  bpm = 0;
  delay(200);
 
 // buttonState1 = digitalRead(buttonPin1);
 // buttonState2 = digitalRead(buttonPin2);

  while(n <= 300 ){
       
  n = n + 1;
  delay(200);
  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 (n > 300) {
  lcd.clear();
  }

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

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

  }
 
  }
 
  }
 

//  if ( n > 300 ) {

  datatampil();
//  }


}


void datatampil() {
  n = 0;
 
  byte i;
  byte present = 0;
  byte type_s;
  byte data[12];
  byte addr[8];
  int celsius, fahrenheit;

  if ( !ds.search(addr)) {
    ds.reset_search();
    delay(250);
    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

  present = ds.reset();
  ds.select(addr); 
  ds.write(0xBE);     

  for ( i = 0; i < 9; i++) {           // we need 9 bytes
    data[i] = ds.read();

  }

  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, 1);
  lcd.print("T= ");
  lcd.print(celsius);
  lcd.print("C");
 
 // lcd.clear();
 
  lcd.setCursor(9, 1);
  lcd.print("BPM= ");
  lcd.print(bpm);
 
  if (bpm > 150) {
     digitalWrite(buzzer, HIGH);
  }else
  {
     digitalWrite(buzzer, LOW); 
  }
 
  delay(200);
 // lcd.clear();
 
 
 // Serial.println(bpm);
 // Serial.println(celsius);


 // n = 0;
 // bpm = 0;
 // lcd.clear();

}





e. VIDEO HASILNYA












No comments:

Post a Comment