Translate

Monitor Suhu Tubuh, BPM, TENSIMETER ONLINE BLYNK + Fitur Suara DF PLAYER Mini

 Monitor Suhu Tubuh, BPM, TENSIMETER ONLINE BLYNK + Fitur Suara DF PLAYER Mini
 

          Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat digunakan untuk monitor suhu tubuh, bpm dan tensi secara online dengan menggunakan Blynk, selain itu terdapat fitur suara yang dihasilkan oleh modul DF Player Mini. untuk lebih jelasnya berikut adalah koding dan daftar komponennya.
 
 
 
a. Arduino Uno
 

 
 
b. LCD 16x2
 

 
 
c. MPX5050GP
 

 
 
d. Modul DF Player Mini
 

 
 
e. Max30100
 

 
 
f. MLX90614
 

 
 
g. Nodemcu ESP8266
 

 

h. Setting File MP3 Format FAT32





 
 
i. Program Arduino IDE
 
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Adafruit_MLX90614.h>  
#include <MAX30100_PulseOximeter.h>
#include <SoftwareSerial.h>
#include <DFPlayer_Mini_Mp3.h>
#define REPORTING_PERIOD_MS 5000
#include "MAX30100.h" //library sensor

SoftwareSerial mySerial(10, 11); // RX, TX

LiquidCrystal_I2C lcd(0x27,16,2); //library lcd

MAX30100* pulseOxymeter;   //library

int cacah; //membuat variabel
int spo;
float bpm;
Adafruit_MLX90614 mlx = Adafruit_MLX90614();

int btreset = 12;
float TargetC;
int motor = 8;
int solenoid = 9;
int dataadc;
int tombolx;
int hitung;
float vol;
float mmhg;
float mmhgx;
int sistole;
int diastole;
int sistolex;
int diastolex;
int mark = 0;
int bttensi = 3;
int suhunya;
int bpmku;

PulseOximeter pox;

uint32_t tsLastReport = 0;
String hrData = "";
void onBeatDetected()
{
//    Serial.println("Beat!");
}

void setup() {

  Serial.begin (9600);
  mySerial.begin (9600);
  mp3_set_serial (mySerial);  //set softwareSerial for DFPlayer-mini mp3 module
  delay(1);  //wait 1ms for mp3 module to set volume
  mp3_set_volume (30);  //volume 0-30
 
  Wire.begin();
  mlx.begin();
//  Serial.begin(9600);
  lcd.begin();
  lcd.clear();
  pinMode(4,OUTPUT);
  pinMode(5,OUTPUT);
  pinMode(6,OUTPUT);
  pinMode(7,OUTPUT);
  digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(6,HIGH);
  digitalWrite(7,HIGH);
  pinMode(motor,OUTPUT);
  pinMode(solenoid,OUTPUT);
  pinMode(bttensi,INPUT_PULLUP);

  digitalWrite(motor,LOW);
  digitalWrite(solenoid,LOW);

   //Serial.print("Initializing pulse oximeter..");
 
    if (!pox.begin()) {
        //Serial.println("FAILED");
        for(;;);
    } else {
        //Serial.println("SUCCESS");
    }
 
   pox.setIRLedCurrent(MAX30100_LED_CURR_11MA);
   pox.setOnBeatDetectedCallback(onBeatDetected);
 
}
   
void loop(){
pox.update();
           
       bpm = pox.getHeartRate();
       spo = pox.getSpO2();
       //bpmku = bpm;

       if(bpm > 0){
         bpmku = bpm;  
       }

       lcd.setCursor(0,1);
       lcd.print("Bpm: ");
       lcd.print(bpmku);
       lcd.print("     ");

mlx.begin();
TargetC = mlx.readObjectTempC();
suhunya = TargetC;

int bttensix = digitalRead(bttensi);

if(bttensix == 0){
 lcd.clear();
 delay(3000);
 mulai();
}

lcd.setCursor(0,0);
lcd.print("S=");
lcd.print(suhunya);
lcd.print("/");
lcd.print(sistole);
lcd.print("/");
lcd.print(diastole);
lcd.print("   ");
lcd.setCursor(0,1);
lcd.print("Bpm: ");
lcd.print(bpmku);
lcd.print("     ");

if((suhunya > 0)&&(suhunya < 38)&&(bpmku > 60)&&(bpmku < 100)&&(sistole > 0)&&(diastole > 0)){
delay(3000);
kirimblynk();
lcd.clear();
delay(1000);
digitalWrite(4,LOW);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
lcd.setCursor(0,0);
lcd.print("play music 1");
mp3_play (1);   //play music file 0001.mp3
delay(20000);
mp3_stop ();
lcd.clear();
delay(1000);
bpmku = 0;
pinMode(btreset,OUTPUT);
digitalWrite(btreset,LOW);
}

if((suhunya >= 38)&&(bpmku > 60)&&(bpmku < 100)&&(sistole > 0)&&(diastole > 0)){
delay(3000);
kirimblynk();
lcd.clear();
delay(1000);
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
lcd.setCursor(0,0);
lcd.print("play music 2");
mp3_play (2);  //play music file 0002.mp3
delay(20000);
mp3_stop ();
lcd.clear();
delay(1000);
bpmku = 0;
pinMode(btreset,OUTPUT);
digitalWrite(btreset,LOW);
}

delay(1);

cacah++;

if(cacah >= 10){
cacah = 0;
 
//internet blynk
Serial.print("*");
Serial.print(suhunya);
Serial.print(",");
Serial.print(bpmku);
Serial.print(",");
Serial.print(sistole);
Serial.print(",");
Serial.print(diastole);
Serial.println("#");

/*
//bluetooth
Serial.print("Suhu= ");
Serial.println(suhunya);
Serial.print("Bpm= ");
Serial.println(bpm);
Serial.print("Sistole= ");
Serial.println(sistole);
Serial.print("Diastole= ");
Serial.println(diastole);
*/

}

}

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

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

if((mmhg >= mmhgx + 5)&&(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);
return;  
}

delay(1);   
mulai();  
}

void kirimblynk(){
 
//internet blynk
Serial.print("*");
Serial.print(suhunya);
Serial.print(",");
Serial.print(bpmku);
Serial.print(",");
Serial.print(sistole);
Serial.print(",");
Serial.print(diastole);
Serial.println("#");
 
}
 
 
 
j. Program Nodemcu ESP8266
 
#define BLYNK_PRINT Serial   
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>

int temp;
int x = 5;
int y;

int value1;
int value2;
int value3;
int value4;

int suhuku;
int bpmku;
int sistole;
int diastole;

float datain1;
float datain2;
float datain3;
float datain4;

String dataIn;
String dt[10];
int i;
boolean parsing=false;

char auth[] = "hgjhg768ghbjhhgd424gfhghgh98iuhgjhhvq";
char ssid[] = "Hotspot Wifiku";
char pass[] = "123456789";

SimpleTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means

// that you define how often to send data to Blynk App.
void sendSensor()
{

 Blynk.virtualWrite(V4, suhuku);
 Blynk.virtualWrite(V5, bpmku);
 Blynk.virtualWrite(V6, sistole);
 Blynk.virtualWrite(V7, diastole);
 delay(1000);

}

void setup()
{
 
  dataIn="";
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  timer.setInterval(1000L, sendSensor);
}

void loop()
{

while(Serial.available()>0) {
//  dataIn="";
    char inChar = (char)Serial.read();
    dataIn += inChar;
    if (inChar == '\n') {
    parsing = true;
  }
}

if(parsing){
  parsingData();
   
  Blynk.run();
  timer.run();
}

}

void parsingData(){
int j=0;

//kirim data yang telah diterima sebelumnya
//Serial.print("data masuk : ");
//Serial.print(dataIn);
//Serial.print("\n");

//inisialisasi variabel, (reset isi variabel)
dt[j]="";
//proses parsing data
for(i=1;i<dataIn.length();i++){
//pengecekan tiap karakter dengan karakter (#) dan (,)
if ((dataIn[i] == '#') || (dataIn[i] == ','))
{
//increment variabel j, digunakan untuk merubah index array penampung
j++;
dt[j]="";       //inisialisasi variabel array dt[j]
}
else
{
//proses tampung data saat pengecekan karakter selesai.
dt[j] = dt[j] + dataIn[i];
}
}

datain1 = dt[0].toInt();
datain2 = dt[1].toInt();
datain3 = dt[2].toInt();
datain4 = dt[3].toInt();

//kirim data hasil parsing
Serial.print("data 1 : ");
Serial.print(datain1);
Serial.print("\n");
Serial.print("data 2 : ");
Serial.print(datain2);
Serial.print("\n");
Serial.print("data 3 : ");
Serial.print(datain3);
Serial.print("\n");
Serial.print("data 4 : ");
Serial.print(datain4);
Serial.print("\n");

suhuku = datain1 / 1;
bpmku = datain2 / 1;
sistole = datain3 / 1;
diastole = datain4 / 1;

}

 
 
 
k. VIDEO HASILNYA
 

 
 
 
 
 

No comments:

Post a Comment