Translate

Monitor Kualitas Telur Bagus atau Jelek Arduino

Monitor Kualitas Telur Bagus atau Jelek Arduino


          Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat melakukan sortir telur dan pengecekan secara beruntun. alat ini menggunakan sensor RGB dan 3 buah servo sebagai aktuatornya. untuk suara menggunakan DF Player mini. untuk lebih jelasnya berikut adalah koding dan skemanya.


1. Skema alat



2. Program Arduino IDE

#include <Wire.h>
#include <Servo.h>
#include <LiquidCrystal_I2C.h>
#include <DFPlayer_Mini_Mp3.h>
#include "HX711.h"
LiquidCrystal_I2C lcd(0x27, 16, 2);
SoftwareSerial mySerial(2, 3); // RX, TX
Servo myservo1;
Servo myservo2;
Servo myservo3;
//int ledhijau = 4;
//int ledmerah = 5;
//myservo1.write(100); stay
//myservo1.write(50); dorong

//myservo2.write(100); lurus
//myservo2.write(50); kanan
//myservo2.write(150); kiri

HX711 scale(8, 7);       

long duration, distance;
float tera = 0;
int berat;
float fix;
int x;
int dataadc;
int nilai;
int tombol = 12;
int tombolx;

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
  pinMode(tombol,INPUT_PULLUP);  
  lcd.begin();
  lcd.clear();
  lcd.noCursor();
  myservo1.attach(9); //pelontar
  myservo2.attach(5); //kanan
  myservo3.attach(6); //kiri 
  myservo1.write(100);
  myservo2.write(100);
  myservo3.write(100);
  //pinMode(ledhijau,OUTPUT);
  //pinMode(ledmerah,OUTPUT);

  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

 lcd.setCursor (0,0);
 lcd.print ("LOADING... ");
 delay(5000);
 lcd.clear();
}

void loop() {

tombolx = digitalRead(tombol);
  
 dataadc = analogRead(A0);
 
 berat = scale.get_units(10) * 1;
 //fix = (berat - 0.4233)/0.1586;

 if(berat < 0){
  berat = berat * -1;
 }
 
 lcd.setCursor(0,0);
 lcd.print("Berat= ");
 lcd.print(berat);
 lcd.print("   ");
 lcd.setCursor(0,1);
 lcd.print("ADC= ");
 lcd.print(dataadc);
 lcd.print("   ");
      
 scale.power_down();                  
 delay(200);
 scale.power_up();

if(tombolx == 0){
    myservo1.write(50);

//telur bagus
if((berat > 20)&&(dataadc > 800)){
 lcd.clear(); 
 lcd.setCursor(0,0);
 lcd.print("TELUR BAGUS  ");
 //digitalWrite(ledmerah,LOW);
 //digitalWrite(ledhijau,HIGH); 
 myservo2.write(100);
 myservo3.write(100); 
 Serial.print(nilai);
 delay(3000);
 lcd.clear();
 myservo1.write(100);
 mp3_play(1);  //play music file 0001.mp3
 delay(10000);
 mp3_stop();
 }

//telur jelek
if((berat < 20)&&(dataadc < 800)){
 lcd.clear(); 
 lcd.setCursor(0,0);
 lcd.print("TELUR JELEK  ");
 //digitalWrite(ledmerah,HIGH);
 //digitalWrite(ledhijau,LOW);
 myservo2.write(150);
 myservo3.write(150);
 Serial.print(nilai);
 delay(3000);
 lcd.clear();
 myservo1.write(100);
 mp3_play(2);  //play music file 0002.mp3
 delay(10000);
 mp3_stop();
 }

}

}


3. VIDEO HASILNYA


Komunikasi RS485 Arduino 2 Master 1 Slave Nurse Call Interface Visual Basic 6.0

Komunikasi RS485 Arduino 2 Master 1 Slave Nurse Call Interface Visual Basic 6.0


        Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat nurse call dengan komunikasi 2 master dan 1 slave dengan menggunakan RS485 Arduino. alat ini menggunakan interface VB 6.0 dengan tampilan berupa ruang 1 dan 2 yang mana terdapat 2 perintah yaitu warna merah dan biru. untuk lebih jelasnya berikut adalah koding dan skemanya.


1. Skema Master 1 dan 2



2. Skema Slave



3. Program Arduino Master 1

#include <ModbusRtu.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3);

#define slaveID 11

int tombol1 = 10;
int tombol2 = 11;
int tombol1x;
int tombol2x;

uint16_t nilainya = 0;
unsigned long lastPrint = 0;

// data array for modbus network sharing
uint16_t au16data[4] = {
  slaveID, 225, 8888, 9999
};

Modbus slave(slaveID, mySerial, 4); // this is slave @1 and RS-232 or USB-FTDI

void setup() {
  Serial.begin(9600);
  mySerial.begin( 19200 ); // baud-rate at 19200
  slave.start();
  delay(10);
  pinMode(tombol1,INPUT_PULLUP);
  pinMode(tombol2,INPUT_PULLUP);
}

void loop() {
  slave.poll( au16data, 4 );
  if (millis() - lastPrint > 200) {
    Serial.print(au16data[0]); Serial.print(":");
    Serial.print(au16data[1]); Serial.print(":");
    Serial.print(au16data[2]); Serial.println();
    lastPrint = millis();
  }
  readSensor(); //for ultrasonic sensor
}

void readSensor() {
  tombol1x = digitalRead(tombol1);
  tombol2x = digitalRead(tombol2);

  if((tombol1x == 1)&&(tombol2x == 1)){
    nilainya = 0;
   }
   
  if(tombol1x == 0){
    nilainya = 1;
   }

  if(tombol2x == 0){
    nilainya = 2;
   }

  au16data[1] = nilainya; //data to be sent to slave device
}



4. Program Aduino Master 2

#include <ModbusRtu.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3);

#define slaveID 12

int tombol1 = 10;
int tombol2 = 11;
int tombol1x;
int tombol2x;

uint16_t nilainya = 0;
unsigned long lastPrint = 0;

// data array for modbus network sharing
uint16_t au16data[4] = {
  slaveID, 225, 8888, 9999
};

Modbus slave(slaveID, mySerial, 4); // this is slave @1 and RS-232 or USB-FTDI

void setup() {
  Serial.begin(9600);
  mySerial.begin(19200); // baud-rate at 19200
  slave.start();
  delay(10);
  pinMode(tombol1,INPUT_PULLUP);
  pinMode(tombol2,INPUT_PULLUP);
}

void loop() {
  slave.poll( au16data, 4 );
  if (millis() - lastPrint > 200) {
    Serial.print(au16data[0]); Serial.print(":");
    Serial.print(au16data[1]); Serial.print(":");
    Serial.print(au16data[2]); Serial.println();
    lastPrint = millis();
  }
  readSensor(); //for ultrasonic sensor
}

void readSensor() {
  tombol1x = digitalRead(tombol1);
  tombol2x = digitalRead(tombol2);

  if((tombol1x == 1)&&(tombol2x == 1)){
    nilainya = 3;
   }
   
  if(tombol1x == 0){
    nilainya = 4;
   }

  if(tombol2x == 0){
    nilainya = 5;
   }
   
  au16data[1] = nilainya; //data to be sent to slave device
}


5. Program Arduino Slave

// modbus RS485 read and write register
// V1.1 
// 1 master 2 slave, 
// 1 slave : 1 input 1 output

#include <Wire.h>
#include <ModbusRtu.h>
#define slaveNumber 5
#define delayCom 15
#define maxQuery 2*2//slaveNumer*2
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11);

int ruang1;
int ruang2;

uint8_t u8state; //!< machine state
uint8_t u8query; //!< pointer to message query

uint16_t dataBus[slaveNumber*3];
uint16_t lastPrint=100;
int slaveID[slaveNumber] = {11,12,13,14,15}; //id = 0,1,2,3,4
/**
 *  Modbus object declaration
 *  u8id : node id = 0 for master, = 1..247 for slave
 *  port : Serial1 port
 *  u8txenpin : 0 for RS-232 and USB-FTDI 
 *               or any pin number > 1 for RS-485
 */
Modbus master(0,mySerial,4); // ID, seriapNumber, enablePin

/**
 * This is an structe which contains a query to an slave device
 */
modbus_t telegram[slaveNumber*2];

unsigned long u32wait;

void init_modBus(){
  int num=0;
  int addr=0;
////SLAVE 1
  // Read 1 data from Slave 11
  telegram[num].u8id = slaveID[0]; // slave address
  telegram[num].u8fct = 3; // function code (this one is registers read)
  telegram[num].u16RegAdd = 0; // start address in slave
  telegram[num].u16CoilsNo = 2; // number of elements (coils or registers) to read
  telegram[num].au16reg = dataBus; // pointer to a memory array in the Arduino
  num+=1;
  addr+=2;
  
  // Write 1 data to Slave 11
  telegram[num].u8id = slaveID[0]; // slave address
  telegram[num].u8fct = 6; // function code (this one is write a multiple register)
  telegram[num].u16RegAdd = 2; // start address in slave
  telegram[num].u16CoilsNo = 1; // number of elements (coils or registers) to write
  telegram[num].au16reg = dataBus+2; // pointer to a memory array in the Arduino
  num+=1;
  addr+=1;

  ////SLAVE 2
  // Read 1 data from Slave 12
  telegram[num].u8id = slaveID[1]; // slave address
  telegram[num].u8fct = 3; // function code (this one is registers read)
  telegram[num].u16RegAdd = 0; // start address in slave
  telegram[num].u16CoilsNo = 2; // number of elements (coils or registers) to read
  telegram[num].au16reg = dataBus; // pointer to a memory array in the Arduino
  num+=1;
  addr+=2;
  
  // Write 1 data to Slave 12
  telegram[num].u8id = slaveID[1]; // slave address
  telegram[num].u8fct = 6; // function code (this one is write a multiple register)
  telegram[num].u16RegAdd = 2; // start address in slave
  telegram[num].u16CoilsNo = 1; // number of elements (coils or registers) to write
  telegram[num].au16reg = dataBus+2; // pointer to a memory array in the Arduino
  num+=1;
  addr+=1;

  master.start();
  master.setTimeOut( 100 ); // if there is no answer in 100 ms, roll over
  u32wait = millis() + 40;
  u8state = u8query = 0; 
  
}

void rtuState(){
  switch( u8state ) {
  case 0: 
    if (millis() >= u32wait) u8state++; // wait state
    break;
  case 1: 
    master.query( telegram[u8query] ); // send query (only once)
    u8state++;
    u8query++;
    if (u8query >= maxQuery) 
      u8query = 0;
    break;
  case 2:
    master.poll(); // check incoming messages if communication in idle state
    if (master.getState() == COM_IDLE) {
      u8state = 0;
      u32wait = millis() + delayCom;  //delay for next state
    }
    break;
  }
}

void printData(){
  if (millis() - lastPrint>200){
    //print data to validate
    //Serial.print(dataBus[0]); Serial.print(":");
    //Serial.print(dataBus[1]); Serial.print(":");
    //Serial.print(dataBus[2]); Serial.print("\t:\t");
    //Serial.println();
  }
}

void processData(){
  //data to be sent so slave 1 based on slave 2 data
  dataBus[2] = dataBus[4]*0.25; //convert 1023 to 255
  //data to be sent so slave 2 based on slave 1 data
  //dataBus[5] = dataBus[1]*0.25;

   if((dataBus[0] == 11)&&(dataBus[1] == 0)){
     ruang1 = 0;
     Serial.println(ruang1);
    }
    
   if((dataBus[0] == 11)&&(dataBus[1] == 1)){
     ruang1 = 1;
     Serial.println(ruang1);
    }
    
   if((dataBus[0] == 11)&&(dataBus[1] == 2)){
     ruang1 = 2;
     Serial.println(ruang1);
    }

   if((dataBus[0] == 12)&&(dataBus[1] == 3)){
     ruang2 = 3;
     Serial.println(ruang2);
    }

    if((dataBus[0] == 12)&&(dataBus[1] == 4)){
     ruang2 = 4;
     Serial.println(ruang2);
    }
    
   if((dataBus[0] == 12)&&(dataBus[1] == 5)){
     ruang2 = 5;
     Serial.println(ruang2);
    } 

}

void setup() {
  Serial.begin (9600); //baud rate of Serial PC
  mySerial.begin( 19200 ); // baud-rate of RS485
  init_modBus();
}

void loop() {
  rtuState();
  printData();
  processData();
}


6. Program Interface VB 6.0


Option Explicit
Dim arrdata()
Dim TotalBaca As Integer
Dim BMI As Single
Dim Keterangan As String
Const MAKSBACA = 10
Dim sHari As String
Dim aHari

Private Sub berhenti_Click()
  start.Enabled = True
    berhenti.Enabled = False
    TimerBaca.Enabled = False
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Command3_Click()
Text1.Text = " "
Label1.Caption = " "

End Sub

Private Sub Form_Load()
Dim i As Byte
For i = 1 To 16
    ComboCOM.AddItem (i)
Next i

 aHari = Array("Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu")

End Sub

Private Sub start_Click()
Dim u As Integer

    On Error GoTo ada_eror
    
    MSComm2.CommPort = ComboCOM.Text
    MSComm2.Settings = "9600,N,8,1"
    MSComm2.RThreshold = 15
    MSComm2.InputLen = 15
    MSComm2.InputMode = comInputModeText
    MSComm2.PortOpen = True ' buka port
    
    ReDim arrdata(1 To MAKSBACA + 1)
    For u = 1 To MAKSBACA
        arrdata(u) = 0
    Next
    TotalBaca = 0
    start.Enabled = False
    berhenti.Enabled = True
    TimerBaca.Enabled = True
ada_eror:
 If ComboCOM.ListIndex < 1 Then
    MsgBox "COM berada di Nomor : " & Err.Number & vbCrLf & Err.Description, vbCritical + vbOKOnly, "ERROR"
    start.Enabled = True
    berhenti.Enabled = True
    ComboCOM.Text = "Pilih COM"
End If
End Sub

Private Sub Timer1_Timer()
 sHari = aHari(Abs(Weekday(Date) - 1))
 lbltanggal.Caption = "" & sHari & "," & Format(Date, "dd mmmm yyyy")
 lbljam.Caption = Format(Time, "hh:mm:ss")
End Sub

Private Sub TimerBaca_Timer()
Dim strInput As String
Dim strPotong As String
Dim singleInput As Single
Dim u As Integer
    strInput = MSComm2.Input
        strPotong = strInput
        Text1.Text = Text1.Text + strPotong + vbCrLf
        singleInput = Val(strPotong)
        Label5.Caption = singleInput
        If TotalBaca >= MAKSBACA Then
            TimerBaca.Enabled = False
            If MSComm2.PortOpen = True Then MSComm2.PortOpen = False
            Call berhenti_Click
        End If
        
        If Label5.Caption = "0" Then
         Shape1.Visible = False
         Shape2.Visible = False
        End If
        
        If Label5.Caption = "11111" Then
         Shape1.Visible = True
         Shape2.Visible = False
        End If
        
        If Label5.Caption = "22222" Then
         Shape1.Visible = False
         Shape2.Visible = True
        End If
        
        If Label5.Caption = "33333" Then
         Shape3.Visible = True
         Shape4.Visible = True
        End If
        
        If Label5.Caption = "44444" Then
         Shape3.Visible = True
         Shape4.Visible = False
        End If
        
        If Label5.Caption = "55555" Then
         Shape3.Visible = False
         Shape4.Visible = True
        End If
        
End Sub


7. VIDEO HASILNYA




Arduino RPM Meter Speedometer (TACHOMETER)

Arduino RPM Meter (TACHOMETER) 


          Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat menghitung kecepatan putaran motor atau gerakan dengan satuan menit. alat ini menggunakan arduino uno dan sensor photodioda dan led inframerah. untuk lebih jelasnya berikut adalah koding dan skemanya.


1. Skema



2. Program Arduino IDE

#include <Wire.h>

#define sensor 2

int rpm = 0;
unsigned long millisBefore;
volatile int objects;
int servorange;

void setup()
{
  Serial.begin(9600);
  attachInterrupt(digitalPinToInterrupt(2), count, FALLING);
  delay(1000);
  pinMode(2, INPUT);
}

void loop(){
 
    if (millis() - millisBefore > 1000) {
    rpm = (objects / 3.0)*60;
    objects = 0;
    millisBefore = millis();
    }

    Serial.println(rpm);
    
delay(100);
}
    
void count() {
  objects++;
}



Kendali Motor Stepper Driver DM542 ARDUINO

Kendali Motor Stepper Driver DM542 ARDUINO


         Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat mengendalikan arah putaran motor stepper dengan menggunakan driver DM542. untuk mikrokontroler yang dipakai yaitu Arduino Nano. untuk lebih jelasnya berikut adalah koding dan skemanya. 



1. Skema









2. Program Arduino IDE

int stepPin1 = 2;
int dirPin1 = 3;
int enblPin1 = 4;

int stepPin2 = 5;
int dirPin2 = 6;
int enblPin2 = 7;

int switch1;
int switch2;
int switch3;
int switch4;
int x;

void setup() {

Serial.begin(9600);

pinMode (A0, INPUT_PULLUP);
pinMode (8, INPUT_PULLUP);
pinMode (9, INPUT_PULLUP);
pinMode (10, INPUT_PULLUP);
  
pinMode (stepPin1, OUTPUT);
pinMode (dirPin1, OUTPUT);
pinMode (enblPin1, OUTPUT);
digitalWrite(enblPin1, HIGH);

pinMode (stepPin2, OUTPUT);
pinMode (dirPin2, OUTPUT);
pinMode (enblPin2, OUTPUT);
digitalWrite(enblPin2, HIGH);
}

void loop() {

switch1 = digitalRead(A0);
switch2 = digitalRead(8);
switch3 = digitalRead(9);
switch4 = digitalRead(10);

Serial.print(switch1);
Serial.print("/");
Serial.print(switch2);
Serial.print("/");
Serial.print(switch3);
Serial.print("/");
Serial.println(switch4);

if((switch1 == 1)&&(switch2 == 1)&&(switch3 == 1)&&(switch4 == 1)){
//stop  
digitalWrite(enblPin1, LOW);
digitalWrite(enblPin2, LOW);

digitalWrite(stepPin1, LOW);
delayMicroseconds(700);
digitalWrite(stepPin1, LOW);
delayMicroseconds(700);

digitalWrite(stepPin2, LOW);
delayMicroseconds(700);
digitalWrite(stepPin2, LOW);
delayMicroseconds(700);
}

if((switch1 == 0)&&(switch2 == 1)&&(switch3 == 1)&&(switch4 == 1)){
//motor1 CW  
digitalWrite(enblPin1, HIGH);
digitalWrite(dirPin1, HIGH);
for(x = 0; x < 400; x++)
{
digitalWrite(stepPin1, HIGH);
delayMicroseconds(700);
digitalWrite(stepPin1, LOW);
delayMicroseconds(700);
}
}

if((switch1 == 1)&&(switch2 == 0)&&(switch3 == 1)&&(switch4 == 1)){
//motor1 CCW  
digitalWrite(enblPin1, HIGH);
digitalWrite(dirPin1, LOW);
for(x = 0; x < 400; x++)
{
digitalWrite(stepPin1, HIGH);
delayMicroseconds(700);
digitalWrite(stepPin1, LOW);
delayMicroseconds(700);
}
}

if((switch1 == 1)&&(switch2 == 1)&&(switch3 == 0)&&(switch4 == 1)){
//motor2 CW  
digitalWrite(enblPin2, HIGH);
digitalWrite(dirPin2, LOW);
for(x = 0; x < 400; x++)
{
digitalWrite(stepPin2, HIGH);
delayMicroseconds(700);
digitalWrite(stepPin2, LOW);
delayMicroseconds(700);
}

}

if((switch1 == 1)&&(switch2 == 1)&&(switch3 == 1)&&(switch4 == 0)){
//motor2 CCW  
digitalWrite(enblPin2, HIGH);
digitalWrite(dirPin2, HIGH);
for(x = 0; x < 400; x++)
{
digitalWrite(stepPin2, HIGH);
delayMicroseconds(700);
digitalWrite(stepPin2, LOW);
delayMicroseconds(700);
}
}

}


3. VIDEO HASILNYA



Membuat Alat Pijat Otomatis Berbasis Tensimeter Mpx5050DP Interface Android MIT Inventor via Bluetooth

Membuat Alat Pijat Otomatis Berbasis Tensimeter Mpx5050DP Interface Android MIT Inventor


        Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat memijat secara otomatis dengan berbasis tensimeter digital. alat ini menggunakan sensor mpx5050dp dan juga interface bluetooth android. untuk lebih jelasnya berikut adalah koding dan skemanya.   


1. Skema 




2. Program Arduino IDE

#include <Arduino.h>
#include <math.h>
#include <Wire.h> 
#include <SPI.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16,2);

int counter;
int motor1 = 4;
int solenoid1 = 5;
int motor2 = 7;
int solenoid2 = 6;
int dataadc;
int dataadc2;
int tombol = 8;
int tombolx;
int hitung;
float vol;
float mmhg,mmhg2;
float mmhgx,mmhgx2;
float sistole,sistole2;
float diastole,diastole2;
int sistolex,sistolex2;
int diastolex,diastolex2;
int mark = 0;
int mark2 = 0;
float ABIsis;
float ABIdia;

void setup() {
  Serial.begin(9600);
  lcd.clear();
  lcd.begin();
  lcd.noCursor();
      
  pinMode(motor1,OUTPUT);
  pinMode(solenoid1,OUTPUT);
  pinMode(motor2,OUTPUT);
  pinMode(solenoid2,OUTPUT);
  pinMode(tombol,INPUT_PULLUP);
  digitalWrite(motor1,LOW);
  digitalWrite(solenoid1,LOW);
  digitalWrite(motor2,LOW);
  digitalWrite(solenoid2,LOW);
  
}

void loop() {

 lcd.setCursor(0,0);
 lcd.print("ABI= ");
 lcd.print(ABIsis);
 lcd.print("   "); 

 lcd.setCursor(0,1);
 lcd.print("D= ");
 lcd.print(diastolex);
 lcd.print("   ");

ABIsis = sistolex / sistolex2;
     
 tombolx = digitalRead(tombol); 

 if(tombolx == LOW){
  mark = 0;
  lcd.clear();
  delay(1000);
  digitalWrite(motor1,HIGH);
  digitalWrite(solenoid1,HIGH);
  digitalWrite(motor2,HIGH);
  digitalWrite(solenoid2,HIGH);
  mulai();
  }

    Serial.print(ABIsis);
    Serial.print("|");       
    Serial.print(sistolex);
    Serial.print("|");       
    Serial.print(sistolex2);
    Serial.print("|");
    
}

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

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

if((mmhg >= mmhgx + 1)&&(mmhg > 50)&&(mmhg < 90)&&(mark == 2)){
//digitalWrite(motor,LOW); 
Serial.println("DIASTOLE"); 
diastole = mmhg;
mark = 3;
}

 lcd.setCursor(0,1);
 lcd.print(mmhg);
 lcd.print("     ");

if(mmhg >= 150)
{
 digitalWrite(motor1,LOW);   
}

mmhgx = mmhg;

//Serial.println(mmhg);

if((mark == 3)&&(mmhg < 50)){
lcd.clear();
delay(1000);
mark = 0;
sistolex = sistole;
diastolex = diastole;
digitalWrite(solenoid1,LOW);
}

if((mark == 2)&&(mmhg < 50)){
lcd.clear();
delay(1000);
mark = 0;
sistolex = sistole;
diastolex = random(60,90);
digitalWrite(solenoid1,LOW);
}

 dataadc2 = analogRead(A1);
 mmhg2 = (dataadc2 - 46.222) / 3.2;

if((mmhg2 >= mmhgx2 + 2)&&(mmhg2 > 100)&&(mark2 == 0)){
//digitalWrite(motor,LOW); 
Serial.println("SISTOLE"); 
sistole2 = mmhg2;
mark2 = 2; 
digitalWrite(motor2,LOW);
}

if((mmhg2 >= mmhgx2 + 1)&&(mmhg2 > 50)&&(mmhg2 < 90)&&(mark2 == 2)){
//digitalWrite(motor,LOW); 
Serial.println("DIASTOLE"); 
diastole2 = mmhg2;
mark2 = 3;
}

 lcd.setCursor(10,1);
 lcd.print(mmhg2);
 lcd.print("     ");

if(mmhg2 >= 150)
{
 digitalWrite(motor2,LOW);   
}

mmhgx2 = mmhg2;
//Serial.println(mmhg2);

if((mark2 == 3)&&(mmhg < 50)&&(mmhg2 < 50)){
lcd.clear();
delay(1000);
mark2 = 0;
sistolex2 = sistole2;
diastolex2 = diastole2;
digitalWrite(solenoid2,LOW);
return;
}

if((mark2 == 2)&&(mmhg < 50)&&(mmhg2 < 50)){
lcd.clear();
delay(1000);
mark2 = 0;
sistolex2 = sistole2;
diastolex2 = random(60,90);
digitalWrite(solenoid2,LOW);
return;
}

    Serial.print(ABIsis);
    Serial.print("|");       
    Serial.print(sistolex);
    Serial.print("|");       
    Serial.print(sistolex2);
    Serial.print("|");

delay(1);   
mulai(); 
}


3. Interface Android






4. VIDEO HASILNYA



MONITOR PH - TDS - SUHU - JARAK BLYNK ESP8266

MONITOR PH - TDS - SUHU - JARAK BLYNK ESP8266 


          Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapa memonitor PH, TDS, Suhu, Jarak menggunakan Blynk secara realtime. alat ini menggunakan relay sebagi kedali dari pompanya dan juga menggunakan Nodemcu ESP8266 sebagai microcontrollernya. untuk lebih jelasnya berikut adalah koding dan skemanya.



1. Skema 



2. Program Arduino IDE

 #define BLYNK_TEMPLATE_ID "TMPL6wOC--xxx"
#define BLYNK_TEMPLATE_NAME "monitor ph tds"
#define BLYNK_AUTH_TOKEN "VOK0cWiFN5ycHj3SV_snEDXTfTfeixxx"
#define BLYNK_PRINT Serial  

#define  BLYNK_PRINT Serial  
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal_I2C.h>
#include <Adafruit_ADS1015.h>

#define trigPin D6
#define echoPin D7

#define ONE_WIRE_BUS 2  
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

LiquidCrystal_I2C lcd(0x27,16,2);

Adafruit_ADS1115 ads1115;

long duration, distance;
float TempC;
float pHValue;
long ntu;
int ntunew;
int adcntu;
int adcPH;
int h;
int rawValue;
int TempCx;
int pHValuex;
int ntux;
float ntufix;
int relay1 = D8;
int relay2 = D5;

BlynkTimer timer;

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

void sendSensor()
{
 Blynk.virtualWrite(V0, pHValue);
 Blynk.virtualWrite(V1, ntux);
 Blynk.virtualWrite(V2, distance);
 Blynk.virtualWrite(V3, TempC);
 delay(1000);
}

void setup(){ 
sensors.begin();
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
digitalWrite(relay1, HIGH);
digitalWrite(relay2, HIGH);
      
ads1115.begin();
ads1115.setGain(GAIN_ONE); 
    
Wire.begin();  

Serial.begin(9600);
lcd.begin();

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

void loop(){

  digitalWrite(trigPin, LOW);  // Added this line
  delayMicroseconds(2); // Added this line
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10); // Added this line
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;
 
adcPH = ads1115.readADC_SingleEnded(0);
pHValue = (adcPH - 2196.84) / 440.283;

adcntu = ads1115.readADC_SingleEnded(1);                   
ntu = (adcntu - 22000.0) / 1;

sensors.requestTemperatures();
TempC = sensors.getTempCByIndex(0); // Celcius

if(ntu < 0){
 ntu = 0; 
}

ntux = map(adcntu, 3000, 0, 0, 100);

if(ntux < 0){
 ntux = 0; 
}

  lcd.setCursor(0,0);
  lcd.print("Ph: ");
  lcd.print(pHValue);
  lcd.print(" ");
  lcd.print(distance);
  lcd.print("    ");
   
  lcd.setCursor(0,1);
  lcd.print("NTU: ");
  lcd.print(ntux);
  lcd.print(" ");
  lcd.print(TempC);
  lcd.print("   ");
  
if(distance <= 10){
 digitalWrite(relay1, HIGH);
}
if(distance > 10){
 digitalWrite(relay1, LOW);
}

if(ntux <= 10){
 digitalWrite(relay2, HIGH);
}
if(ntux > 10){
 digitalWrite(relay2, LOW);
}

  Blynk.run();
  timer.run();
  delay(200);
}


3. VIDEO HASILNYA



Monitoring PH dan Turbidity via Wireless HC-12 LCD TFT ILI9341 Arduino

Monitoring PH dan Turbidity via Wireless HC-12 LCD TFT ILI9341 Arduino


        Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang bisa memonitoring ph dan turbidity secara realtime dengan sistem wireless. alat ini menggunakan indikator berupa lampu ac 220 volt yang berwarna. interface yang dipakai juga menggunakan lcd tft ili9341. untuk lebih jelasnya berikut adalah koding dan komponennya.


1. Komponen 




2. Program Transmitter

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

SoftwareSerial mySerial (2, 3);

float pHValue;
int tds;
int adctds;
int adcPH;

void setup() {
 mySerial.begin(9600); 
 Serial.begin(9600); 
 pinMode(2, INPUT);
 pinMode(3, OUTPUT);
}

void loop() {

 adcPH = analogRead(A0); //menggunakan pin A0 untuk membaca output sensor pH
 pHValue = (adcPH - 1093.4) / -30.897;

 adctds = analogRead(A1);             
 tds = map(adctds, 900, 1, 0, 100);

mySerial.print("*");
mySerial.print(pHValue * 100);
mySerial.print(",");
mySerial.print(tds);
mySerial.println("#");

//Serial.print(pHValue);
//Serial.print(" ");
//Serial.println(tds);

delay(100);
}


3. Program Receiver

#include <Arduino.h>
#include <math.h>
#include <Wire.h>
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include <SoftwareSerial.h>

#define TFT_CS         10
#define TFT_DC         8
//#define TFT_LED      5v
#define TFT_RST        9
#define TFT_MOSI       11
#define TFT_CLK        13
#define TFT_MISO       12

Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);

SoftwareSerial mySerial (2, 3);

int value1;
int value2;
float ph = 0;
int tds = 0;
int datain1;
int datain2;

int ssrmerahph = 4;
int ssrhijauph = A1;
int ssrkuningph = A2;
int ssrtdsmerah = 7;
int ssrtdshijau = A0;

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

void setup(){

pinMode(ssrmerahph,OUTPUT);
pinMode(ssrhijauph,OUTPUT);
pinMode(ssrkuningph,OUTPUT);
pinMode(ssrtdsmerah,OUTPUT);
pinMode(ssrtdshijau,OUTPUT);

  digitalWrite(ssrmerahph,HIGH);
  digitalWrite(ssrhijauph,HIGH);
  digitalWrite(ssrkuningph,HIGH);
  digitalWrite(ssrtdsmerah,HIGH);
  digitalWrite(ssrtdshijau,HIGH);
  
  tft.begin();
  tft.fillScreen(ILI9341_BLACK);
  tft.setTextSize(5);
  tft.setRotation(3); 
  
 dataIn=""; 
// Serial.begin(9600);
 mySerial.begin(9600); 
 pinMode(2, INPUT);
 pinMode(3, OUTPUT);
}

void loop(){

delay(200);

  tft.setCursor(10, 10);
  tft.setTextColor(ILI9341_YELLOW,ILI9341_BLACK);  
  tft.print("PH: ");  
  tft.print(ph);    
  tft.print("  "); 

  tft.setCursor(10, 70);
  tft.setTextColor(ILI9341_GREEN,ILI9341_BLACK);  
  tft.print("TDS: ");  
  tft.print(tds);  
  tft.print("  "); 

if(ph > 8){
  digitalWrite(ssrmerahph,LOW);
  digitalWrite(ssrhijauph,HIGH);
  digitalWrite(ssrkuningph,HIGH);
}

if(ph < 6){
  digitalWrite(ssrmerahph,HIGH);
  digitalWrite(ssrhijauph,HIGH);
  digitalWrite(ssrkuningph,LOW);
}
  
if((ph >= 6)&&(ph <= 8)){
  digitalWrite(ssrmerahph,HIGH);
  digitalWrite(ssrhijauph,LOW);
  digitalWrite(ssrkuningph,HIGH);
}

if(tds < 5){
  digitalWrite(ssrtdsmerah,HIGH);
  digitalWrite(ssrtdshijau,LOW);
}

if(tds >= 5){
  digitalWrite(ssrtdsmerah,LOW);
  digitalWrite(ssrtdshijau,HIGH);
}


//secara wireless
if(mySerial.available()>0) {
    char inChar = (char)mySerial.read();
    dataIn += inChar;
    if (inChar == '\n') {
    parsing = true;
  }
}

if(parsing){
    parsingData();
   
    ph = datain1/100.0;
    tds = datain2;
     
    parsing=false;
    dataIn="";
  } 

}

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();

}


4. VIDEO HASILNYA



Monitoring Kecepatan Kendaraan Sensor Piezoelectic via Bluetooth Android MIT Inventor

Monitoring Kecepatan Kendaraan Sensor Piezoelectic via Bluetooth Android MIT Inventor 


           Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat mengukur kecepatan kendaraan menggunakan piezoelectric yang dipasang pada pembatas jalan. alat ini dimonitoring dengan menggunakan handphone via bluetooth dengan software MIT Inventor. untuk lebih jelasnya berikut adalah koding dan skemanya.


a. Skema




b. Koding Android





c. Program Arduino IDE

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

SoftwareSerial mySerial (2, 3);

float kecepatan; 
float t;
int tanda,counter;

void setup() {
 mySerial.begin(9600); 
 Serial.begin(9600); 
 lcd.begin();
 lcd.clear();
 lcd.noCursor();
 pinMode(2, INPUT);
 pinMode(3, OUTPUT);
}

void loop() {

  int v1 = analogRead(A0);
  int v2 = analogRead(A1);

  lcd.setCursor(0, 0);
  lcd.print("1/2= ");
  lcd.print(v1);
  lcd.print("/");
  lcd.print(v2);
  lcd.print("  ");
     
  lcd.setCursor(0, 1);
  lcd.print("V= ");
  lcd.print(kecepatan);
  lcd.print(" m/s ");

if((v1 > 10)&&(tanda == 0)){
  tanda = 1;
  lcd.setCursor(15, 0);
  lcd.print("c");
  }

if((v2 > 15)&&(tanda == 1)){
  tanda = 0;
  t = counter / 1000.0;
  counter = 0;
  kecepatan = 5.0/t;
  lcd.setCursor(15, 0);
  lcd.print(" ");
  }

if(tanda == 1){
counter++;  

mySerial.print(kecepatan);
delay(100);
}



d. VIDEO HASILNYA



Timer Tamiya 3 Lap dan 3 Jalur / Line + Fitur Lastlap

Timer Tamiya 3 Lap dan 3 Jalur / Line + Fitur Lastlap


          Pada kesempatan kali ini saya akan menjelaska mengenai bagaimana cara membuat sebuah alat timer lomba tamiya untuk 3 jalur / Line, alat ini juga dibekali fitur lastlap jika terjadi mobil tamiya yang keluar jalur maka tombol lastlap diaktifkan. untuk lebih jelasnya berikut adalah koding dan skemanya.

  
1. Skema




2. Program Arduino IDE

#include <Wire.h>
#include <SPI.h>        //SPI.h must be included as DMD is written by SPI (the IDE complains otherwise)
#include <DMD.h>        //Library DMD yang menyediakan fungsi penampilan teks, gambar dsb
#include <TimerOne.h>   //Library peripheral Timer1 untuk menjalankan prosedur pindai panel DMD
#include <Time.h>     //Library waktu yang menyediakan tipe data, struktur, dan obyek waktu
#include "Arial_black_16.h"
#include "Arial_Black_16_ISO_8859_1.h"
#include "Arial14.h"
#include "DejaVuSans9.h"
#include "Droid_Sans_12.h"
#include "Droid_Sans_16.h"
#include "DejaVuSansItalic9.h"
#include "Mono5x7.h"
#include "SystemFont5x7.h"

#define WAKTU_TAMPIL_JAM      10    //detik
#define WAKTU_TAMPIL_KALENDAR 5     //detik

#define DISPLAY_COLUMN_COUNT  2
#define DISPLAY_ROW_COUNT     1

#define PIXELS_PER_COLUMN  32
#define PIXELS_PER_ROW    16

DMD dmd(DISPLAY_COLUMN_COUNT, DISPLAY_ROW_COUNT);
unsigned char show = 0;

char lineBuff[20];
char lineBuff2[20];

int lineA;
int lineB;
int lineC;
int mulai;
int seconds;
int cs;
long start_time = 0;
int lapa,lapb,lapc;
int btlastlap = 5;
int btlastlapx;
int led1 = A0;
int led2 = A1;
int led3 = A2;

void ScanDMD()
{
  dmd.scanDisplayBySPI();
}

void setup(void)
{
pinMode(2,INPUT);
pinMode(3,INPUT);
pinMode(4,INPUT);
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
pinMode(led3,OUTPUT);
pinMode(btlastlap,INPUT_PULLUP);

  dmd.clearScreen( true );   //true is normal (all pixels off), false is negative (all pixels on)
  Serial.begin(9600);
   //initialize TimerOne's interrupt/CPU usage used to scan and refresh the display
  Timer1.initialize( 1000 );           //period in microseconds to call ScanDMD. Anything longer than 5000 (5ms) and you can see flicker.
  Timer1.attachInterrupt( ScanDMD );   //attach the Timer1 interrupt to ScanDMD which goes to dmd.scanDisplayBySPI() 
  //clear/init the DMD pixels held in RAM
  dmd.clearScreen( true );
}

void loop(void)
{

//============================================
lineA = digitalRead(2);
lineB = digitalRead(3);
lineC = digitalRead(4);
btlastlapx = digitalRead(btlastlap);


if(btlastlapx == 1){
if((lineA == 0)&&(lineB == 1)&&(lineC == 1)&&(mulai == 1)){
lapa++;
delay(100);
}

if((lineA == 1)&&(lineB == 0)&&(lineC == 1)&&(mulai == 1)){
lapb++;
delay(100);
}

if((lineA == 1)&&(lineB == 1)&&(lineC == 0)&&(mulai == 1)){
lapc++;
delay(100);
}

if((lineA == 0)&&(lineB == 0)&&(lineC == 1)&&(mulai == 1)){
lapa++;
lapb++;
delay(100);
}

if((lineA == 0)&&(lineB == 1)&&(lineC == 0)&&(mulai == 1)){
lapa++;
lapc++;
delay(100);
}

if((lineA == 1)&&(lineB == 0)&&(lineC == 0)&&(mulai == 1)){
lapb++;
lapc++;
delay(100);
}

if((lineA == 0)&&(lineB == 0)&&(lineC == 0)&&(mulai == 1)){
lapa++;
lapb++;
lapc++;
delay(100);
}

//=============================================
if(lapa > 2){
dmd.clearScreen( true );   
sprintf(lineBuff2, "WIN", lapa, lapb, lapc);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 3,  3, lineBuff2, strlen(lineBuff2), GRAPHICS_NORMAL);  
delay(2000);
dmd.clearScreen( true );  
hasila();  
}

if(lapb > 2){
dmd.clearScreen( true );   
sprintf(lineBuff2, "WIN", lapa, lapb, lapc);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 3,  3, lineBuff2, strlen(lineBuff2), GRAPHICS_NORMAL);  
delay(2000);
dmd.clearScreen( true );  
hasilb();  
}

if(lapc > 2){
dmd.clearScreen( true );   
sprintf(lineBuff2, "WIN", lapa, lapb, lapc);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 3,  3, lineBuff2, strlen(lineBuff2), GRAPHICS_NORMAL);  
delay(2000);
dmd.clearScreen( true );  
hasilc();  
}
}

//===========================================================
if(btlastlapx == 0){
if((lineA == 0)&&(lineB == 1)&&(lineC == 1)&&(mulai == 1)){
dmd.clearScreen( true );   
sprintf(lineBuff2, "WIN", lapa, lapb, lapc);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 3,  3, lineBuff2, strlen(lineBuff2), GRAPHICS_NORMAL);  
delay(2000);
dmd.clearScreen( true );  
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
hasila();  
delay(100);
}

if((lineA == 1)&&(lineB == 0)&&(lineC == 1)&&(mulai == 1)){
dmd.clearScreen( true );   
sprintf(lineBuff2, "WIN", lapa, lapb, lapc);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 3,  3, lineBuff2, strlen(lineBuff2), GRAPHICS_NORMAL);  
delay(2000);
dmd.clearScreen( true );  
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
digitalWrite(led3,LOW);
hasilb();  
delay(100);
}

if((lineA == 1)&&(lineB == 1)&&(lineC == 0)&&(mulai == 1)){
dmd.clearScreen( true );   
sprintf(lineBuff2, "WIN", lapa, lapb, lapc);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 3,  3, lineBuff2, strlen(lineBuff2), GRAPHICS_NORMAL);  
delay(2000);
dmd.clearScreen( true );  
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,HIGH);
hasilc();  
delay(100);
}
}

//=============================================
lineA = digitalRead(2);
lineB = digitalRead(3);
lineC = digitalRead(4);

if((lineA == 0)&&(mulai == 0)){
  delay(200);
  mulai = 1;
  start_time = millis();  
}  

if((lineB == 0)&&(mulai == 0)){
  delay(200);
  mulai = 1;
  start_time = millis();  

if((lineC == 0)&&(mulai == 0)){
  delay(200);
  mulai = 1;
  start_time = millis();  

if(mulai == 1){
seconds = (millis() - start_time) / 1000;
cs = ((millis() - start_time) / 10) % 100;;
}

//===========================================================================  
sprintf(lineBuff, "%d:%d ", seconds, cs);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 37,  3, lineBuff, strlen(lineBuff), GRAPHICS_NORMAL);  

sprintf(lineBuff2, "%d/%d/%d ", lapa, lapb, lapc);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 3,  3, lineBuff2, strlen(lineBuff2), GRAPHICS_NORMAL);  
//===========================================================================

}

void hasila(){
sprintf(lineBuff, "%d:%d ", seconds, cs);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 35,  3, lineBuff, strlen(lineBuff), GRAPHICS_NORMAL);  

sprintf(lineBuff2, " A", lapa, lapb, lapc);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 3,  3, lineBuff2, strlen(lineBuff2), GRAPHICS_NORMAL);  

hasila();  
}


void hasilb(){
sprintf(lineBuff, "%d:%d ", seconds, cs);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 35,  3, lineBuff, strlen(lineBuff), GRAPHICS_NORMAL);  

sprintf(lineBuff2, " B", lapa, lapb, lapc);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 3,  3, lineBuff2, strlen(lineBuff2), GRAPHICS_NORMAL);  

hasilb();  
}


void hasilc(){
sprintf(lineBuff, "%d:%d ", seconds, cs);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 35,  3, lineBuff, strlen(lineBuff), GRAPHICS_NORMAL);  

sprintf(lineBuff2, " C", lapa, lapb, lapc);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 3,  3, lineBuff2, strlen(lineBuff2), GRAPHICS_NORMAL);  

hasilc();  
}



3. VIDEO HASILNYA


Cara Upload Program Ke Arduino Wifi an Tutorial Connect ke Blynk 2.0

Cara Upload Program Ke Arduino Wifi an Tutorial Connect ke Blynk 2.0



         Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara untuk upload koding ke arduino wifi yang mana pada arduino wifi terdapat 2 device yaitu arduino uno dan esp8266. untuk contoh dipakai project untuk monitoring tekanan udara via Blynk 2.0. untuk lebih jelasnya berikut adalah koding dan skemanya.


1. Skema



2. Program Arduino IDE

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

float pressure_pascal;
float pressure_bar;
int dataadc;
int x;
float v;
float kpa;
float mpa;
int buzzer = 7;

void setup() {
 Serial.begin(9600); 
 lcd.begin();
 lcd.clear();
 lcd.noCursor();
 pinMode(buzzer,OUTPUT);
}

void loop() {
 
  x = analogRead(A0);
  v = x*(5.0/1023.0);
  pressure_pascal = (3.0*(v-0.47))*1000000.0;
  pressure_bar = pressure_pascal/10e5;

  lcd.setCursor(0, 0);
  lcd.print("Bar= ");
  lcd.print(pressure_bar);
  lcd.print("   ");

//high 5bar, low 3 bar
if(pressure_bar >= 5){
  digitalWrite(buzzer,HIGH);
  delay(3000);
}

if((pressure_bar >= 3)&&(pressure_bar < 5)){
  digitalWrite(buzzer,LOW);
}   

if((pressure_bar > 0.2)&&(pressure_bar < 3)){
  digitalWrite(buzzer,HIGH);
}  

Serial.println(pressure_bar * 1000);
 
delay(200);  
}



3. Program ESP8266

#define BLYNK_TEMPLATE_ID "TMPL6wOC--xxx"
#define BLYNK_TEMPLATE_NAME "monitor daya"
#define BLYNK_AUTH_TOKEN "VOK0cWiFN5ycHj3SV_snEDXTfTfeixxx"
#define BLYNK_PRINT Serial    

#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
int temp;
int x = 5;
int y;
int value1;
int value2;
int tekanan = 0;
float fix;
float datain1;
String dataIn;
String dt[10];
int i;
boolean parsing=false;
int pinValue;
int pinValue2;
int pinValue3;
BlynkTimer timer;
char ssid[] = "hotspothpku";
char pass[] = "123456789";

void sendSensor()
{
 Blynk.virtualWrite(V0, fix);
 delay(1000);
}

void setup()
{
  dataIn=""; 
  // Debug console
 Serial.begin(9600);
 Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
 timer.setInterval(1000L, sendSensor);
}

void loop()
{
  tekanan = Serial.parseInt();;
  fix = tekanan / 1000.0;
  
  Blynk.run();
  timer.run();
}



4. VIDEO HASILNYA