Translate

Monitor Arus dan Tegangan serta Fitur Pembatas Arus (over current) Sensor PZEM-004t ARDUNO

Monitor Arus dan Tegangan serta Fitur Pembatas Arus (over current) Sensor PZEM-004t ARDUNO


           Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat digunakan untuk monitor arus dan tegangan dan juga ada fitur pembatas arus sehingga kita bisa set pada berapa amper terjadi over current atau arus berlebih, jika terjadi arus berlebih maka akan otomatis off selama 2.5 detik. untuk lebih jelasnya berikut adalah komponen dan programnya.



a. Arduino Nano




b. Sensor PZEM-004t




c. SSR (Solid State Relay)






d. Program Arduino IDE

#include <Wire.h>
#include <Keypad.h>
#include <LiquidCrystal_I2C.h>  
#include <PZEM004Tv30.h>

PZEM004Tv30 pzem(2,3);
LiquidCrystal_I2C lcd(0x27, 16, 2); 

int relay = 4;
int led = 9;
int buzzer = 10; 
int arus = 0;
float arusx;
float arusflo;

char customKey;
const byte ROWS = 4;
const byte COLS = 4;

char keys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};

byte rowPins[ROWS] = {A0,A1,A2,A3}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {5,6,7,8}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS); 


void setup() 
{
  
  pinMode(relay, OUTPUT);
  digitalWrite(relay, LOW);
  pinMode(led, OUTPUT);
  digitalWrite(led, HIGH);
  pinMode(buzzer, OUTPUT);
  digitalWrite(buzzer, HIGH);
  
  lcd.begin(); 
  lcd.noCursor(); 
  lcd.clear(); 
  Serial.begin(9600);   

}

void loop() 
{
  
    float voltage = pzem.voltage();
    float current = pzem.current();
    float power = pzem.power();
    float energy = pzem.energy();
    float frequency = pzem.frequency();
    float pf = pzem.pf();
    
    lcd.setCursor(0,0); 
    lcd.print("I= ");
    lcd.print(current,2);
    lcd.print(" / ");
    lcd.print(voltage,1);
    lcd.print("     ");
    lcd.setCursor(0,1); 
    lcd.print("S= ");
    lcd.print(arusx,2);
    lcd.print("   ");
 
    customKey = customKeypad.getKey();
    
    if(customKey == 'A'){
    lcd.clear();
    delay(1000);  
    arus = 0;
    arusx = 0;
    setting();
    }

    if((current > arusx)&&(arusx > 0)){
      digitalWrite(relay,HIGH);
      digitalWrite(buzzer,LOW);
      digitalWrite(led,LOW);
      delay(2500);
      digitalWrite(relay,LOW);
      digitalWrite(buzzer,HIGH);
      digitalWrite(led,HIGH);
      }

    if((current < arusx)&&(arusx > 0)){
      digitalWrite(relay,LOW);
      digitalWrite(buzzer,HIGH);
      digitalWrite(led,HIGH);
      }  

   delay(200);
}

void setting(){

  lcd.setCursor(0,0); 
  lcd.print("Set Max Arus");
  
  customKey = customKeypad.getKey();

  if(customKey >= '0' && customKey <= '9')
  {
      arus = arus * 10 + (customKey - '0');
      lcd.setCursor(0,1);
      lcd.print(arus);
  }

    if(customKey == 'A')
  {
   arusx = 0; 
   arus = 0;
   lcd.clear();
   delay(1000);
  }

  if(customKey == 'B')
  {
   arusx = arus / 1.0; 
   lcd.clear();
   delay(1000);
   return;
  }

  if(customKey == 'C')
  {
   arusx = arus / 10.0; 
   lcd.clear();
   delay(1000);
   return;
  }

  if(customKey == 'D')
  {
   arusx = arus / 100.0;
   lcd.clear();
   delay(1000);
   return; 
  }

setting();
}





e. VIDEO HASILNYA








Monitor Kecepatan Aliran Air / Udara (Air Flow Speed Meter / Water Flow Speed Meter)

Monitor Kecepatan Aliran Air / Udara (Air Flow Speed Meter / Water Flow Speed Meter)


             Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat untuk monitor kecepatan aliran udara atau air dengan menggunakan sensor water flow. alat ini menggunakan interface lcd 16x2 dan arduino nano sebagai mikrokontrollernya. untuk lebih jelasnya berikut adalah program dan komponennya.




a. Arduino Nano




b. Sensor Water Flow 




c. LCD + I2C






d. Program Arduino IDE

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2); 

byte sensorInterrupt = 0;  // 0 = digital pin 2
byte sensorPin       = 2;

float calibrationFactor = 4.5;

volatile byte pulseCount; 

unsigned int frac;
float flowRate;
unsigned int flowMilliLitres;
float totalMilliLitres;

unsigned long oldTime;

int btok = 3;
int btup = 4;
int btdown = 5;
int btset = 6;

int btokx,btupx,btdownx,btsetx;

int led1 = 7;
int led2 = 8;
float nilaiset;

void setup()
{

pinMode(btok,INPUT_PULLUP);;  
pinMode(btset,INPUT_PULLUP);;  
pinMode(btup,INPUT_PULLUP);;  
pinMode(btdown,INPUT_PULLUP);;  

pinMode(led1,OUTPUT);;  
pinMode(led2,OUTPUT);;  
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);

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

 pinMode(sensorPin, INPUT);
  digitalWrite(sensorPin, HIGH);

  pulseCount        = 0;
  flowRate          = 0.0;
  flowMilliLitres   = 0;
  totalMilliLitres  = 0;
  oldTime           = 0;

  attachInterrupt(sensorInterrupt, pulseCounter, FALLING);

}


void loop(){
  
if((millis() - oldTime) > 1000)    // Only process counters once per second
  {

    detachInterrupt(sensorInterrupt);
    flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;
    oldTime = millis();
    flowMilliLitres = (flowRate / 60) * 1000;
    totalMilliLitres += flowMilliLitres;
      
    // Print the flow rate for this second in litres / minute
    lcd.setCursor(0,0);
    lcd.print("S: ");
    lcd.print(int(flowRate));  // Print the integer part of the variable
    lcd.print(".");             // Print the decimal point
    // Determine the fractional part. The 10 multiplier gives us 1 decimal place.
    frac = (flowRate - int(flowRate)) * 10;
    lcd.print(frac, DEC) ;      // Print the fractional part of the variable
    lcd.print(" L/min    ");
    // Print the number of litres flowed in this second
    //Serial.print("  Current Liquid Flowing: ");             // Output separator
    //Serial.print(flowMilliLitres);
    //Serial.print("mL/Sec");

    // Print the cumulative total of litres flowed since starting
    //Serial.print("  Output Liquid Quantity: ");             // Output separator
    //Serial.print(totalMilliLitres);
    //Serial.println("mL");

    // Reset the pulse counter so we can start incrementing again
    pulseCount = 0;
   
    // Enable the interrupt again now that we've finished sending output
    attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
  }
  
  
  if(flowRate < nilaiset){
  digitalWrite(led1,LOW);
  digitalWrite(led2,HIGH);
  }
  
  if(flowRate > nilaiset){
  digitalWrite(led1,HIGH);
  digitalWrite(led2,LOW);
  }
  
  if(flowRate < 0){
   flowRate = 0;
  }
  
  if(frac < 0){
   frac = 0;
  }


btsetx = digitalRead(btset);

if(btsetx == 0){
delay(1000);
lcd.clear();
setting();
}

lcd.setCursor(0,1);
lcd.print("SET= ");
lcd.print(nilaiset);   
   
}


void pulseCounter()
{
  pulseCount++;
}


void setting(){

btokx = digitalRead(btok);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);

lcd.setCursor(0,0);
lcd.print("Set Nilai: ");
lcd.setCursor(0,1);    
lcd.print(nilaiset);
lcd.print("      ");

if(btupx == 0){
delay(1000);  
nilaiset = nilaiset + 0.5;
}

if(btdownx == 0){
delay(1000);
nilaiset = nilaiset - 0.5;
}  
  
if(nilaiset < 0){
nilaiset = 0;
}
  
if(btokx == 0){
delay(1000);
lcd.clear();
return;
}

setting();
}




e. VIDEO HASILNYA







Simulasi Traffic Light Simpang 4 Proteus 7 dan ARDUINO

Simulasi Traffic Light Simpang 4 Proteus 7 dan ARDUINO


               Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat atau simulasi yang berfungsi sebagaimana kinerja dari traffic light atau lampu merah di perkotaan. alat ini menggunakan arduino dan interface lcd i2c serta dilengkapi dengan RTC. untuk lebih jelasnya berikut komponen dan kodingnya.



a. Arduino




b. Lcd 16x2 + I2C




c. RTC Ds1307




d. Led




e. Push Button






f. Program Arduino IDE

#include <Wire.h>
#include <EEPROM.h>
#include <LiquidCrystal_I2C.h>
#define DS3231_I2C_ADDRESS 0x68
//0x20 untuk simulasi proteus jika real gunakan 0x27 atau 0x3F
LiquidCrystal_I2C lcd(0x20,16,2); 
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;

int addr1 = 0;
int addr2 = 1;
int addr3 = 2;
int addr4 = 3;
int addr5 = 4;
int addr6 = 5;

int ledg1 = 0;
int ledy1 = 1;
int ledr1 = 2;

int ledg2 = 3;
int ledy2 = 4;
int ledr2 = 5;

int ledg3 = 6;
int ledy3 = 7;
int ledr3 = 8;

int ledg4 = 9;
int ledy4 = 10;
int ledr4 = 11;

int btset = A0;
int btup = A1;
int btdown = A2;
int btok = A3;

int btsetx = 0;
int btupx = 0;
int btdownx = 0;
int btokx = 0;

int delaykuning = 300;

// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
  return( (val/10*16) + (val%10) );
}
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
  return( (val/16*10) + (val%16) );
}

int jam,menit,hari,awalflash,akhirflash;
int hijau1,hijau2,hijau3,hijau4;


void setup()
{
  
hijau1 = EEPROM.read(addr1);
hijau2 = EEPROM.read(addr2);
hijau3 = EEPROM.read(addr3);
hijau4 = EEPROM.read(addr4);
awalflash = EEPROM.read(addr5);
akhirflash = EEPROM.read(addr6);

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

pinMode(ledg1,OUTPUT);
pinMode(ledy1,OUTPUT);
pinMode(ledr1,OUTPUT);

pinMode(ledg2,OUTPUT);
pinMode(ledy2,OUTPUT);
pinMode(ledr2,OUTPUT);

pinMode(ledg3,OUTPUT);
pinMode(ledy3,OUTPUT);
pinMode(ledr3,OUTPUT);

pinMode(ledg4,OUTPUT);
pinMode(ledy4,OUTPUT);
pinMode(ledr4,OUTPUT);

pinMode(btset,INPUT_PULLUP);
pinMode(btup,INPUT_PULLUP);
pinMode(btdown,INPUT_PULLUP);
pinMode(btok,INPUT_PULLUP);

  Wire.begin();
  // set the initial time here:
  // DS3231 seconds, minutes, hours, day, date, month, year
  // setDS3231time(0,47,11,6,23,11,18);
   
btsetx = digitalRead(btset);
   
if(btsetx == 0)
{
   lcd.clear();  
   hijau1 = 0;
   hijau2 = 0;
   hijau3 = 0;
   hijau4 = 0;
   
   awalflash = 0;
   akhirflash = 0;
   
   settingjam();
   settingmenit();
   settinghari();
   setdelayhijau1();
   setdelayhijau2();
   setdelayhijau3();
   setdelayhijau4();
   setawalflash();
   setakhirflash();
   EEPROM.write(addr1, hijau1);
   EEPROM.write(addr2, hijau2);
   EEPROM.write(addr3, hijau3);
   EEPROM.write(addr4, hijau4);
   EEPROM.write(addr5, awalflash);
   EEPROM.write(addr6, akhirflash);
  // DS3231 seconds, minutes, hours, day, date, month, year
   setDS3231time(0,menit,jam,hari,23,11,20);
   
}


void setDS3231time(byte second, byte minute, byte hour, byte dayOfWeek, byte
dayOfMonth, byte month, byte year)
{
  // sets time and date data to DS3231
  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0); // set next input to start at the seconds register
  Wire.write(decToBcd(second)); // set seconds
  Wire.write(decToBcd(minute)); // set minutes
  Wire.write(decToBcd(hour)); // set hours
  Wire.write(decToBcd(dayOfWeek)); // set day of week (1=Sunday, 7=Saturday)
  Wire.write(decToBcd(dayOfMonth)); // set date (1 to 31)
  Wire.write(decToBcd(month)); // set month
  Wire.write(decToBcd(year)); // set year (0 to 99)
  Wire.endTransmission();
}
void readDS3231time(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0); // set DS3231 register pointer to 00h
  Wire.endTransmission();
  Wire.requestFrom(DS3231_I2C_ADDRESS, 7);
  // request seven bytes of data from DS3231 starting from register 00h
  *second = bcdToDec(Wire.read() & 0x7f);
  *minute = bcdToDec(Wire.read());
  *hour = bcdToDec(Wire.read() & 0x3f);
  *dayOfWeek = bcdToDec(Wire.read());
  *dayOfMonth = bcdToDec(Wire.read());
  *month = bcdToDec(Wire.read());
  *year = bcdToDec(Wire.read());
}
void displayTime()
{
  lcd.setCursor(0,0);
  // retrieve data from DS3231
  readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month,
  &year);
  // send it to the serial monitor
  lcd.print(hour, DEC);
  // convert the byte variable to a decimal number when displayed
  lcd.print(":");
  if (minute<10)
  {
    lcd.print("0");
  }
  lcd.print(minute, DEC);
  lcd.print(":");
  if (second<10)
  {
    lcd.print("0");
  }
  lcd.print(second, DEC);
  lcd.print(" ");
/* 
  lcd.setCursor(0,1);
  lcd.print(dayOfMonth, DEC);
  lcd.setCursor(0,2);
  lcd.print(month, DEC);
  lcd.print(" / ");
  lcd.print(year, DEC);
  lcd.setCursor(0,3);
  //lcd.print(" Day of week: ");
 
  switch(dayOfWeek){
  case 1:
    lcd.print("Sunday");
    break;
  case 2:
    lcd.print("Monday");
    break;
  case 3:
    lcd.print("Tuesday");
    break;
  case 4:
    lcd.print("Wednesday");
    break;
  case 5:
    lcd.print("Thursday");
    break;
  case 6:
    lcd.print("Friday");
    break;
  case 7:
    lcd.print("Saturday");
    break;
  }
*/  

lcd.setCursor(0,1);
lcd.print("TEXT BISA EDIT");

}


void loop()
{
   displayTime();
   delay(1);

//hijau apil 1   
digitalWrite(ledg1,LOW);
digitalWrite(ledy1,HIGH);
digitalWrite(ledr1,HIGH);

digitalWrite(ledg2,HIGH);
digitalWrite(ledy2,HIGH);
digitalWrite(ledr2,LOW);

digitalWrite(ledg3,HIGH);
digitalWrite(ledy3,HIGH);
digitalWrite(ledr3,LOW);

digitalWrite(ledg4,HIGH);
digitalWrite(ledy4,HIGH);
digitalWrite(ledr4,LOW);
delay(hijau1);

//kuning apil 1 
digitalWrite(ledg1,HIGH);
digitalWrite(ledy1,LOW);
digitalWrite(ledr1,HIGH);
delay(delaykuning);


//hijau apil 2   
digitalWrite(ledg1,HIGH);
digitalWrite(ledy1,HIGH);
digitalWrite(ledr1,LOW);

digitalWrite(ledg2,LOW);
digitalWrite(ledy2,HIGH);
digitalWrite(ledr2,HIGH);

digitalWrite(ledg3,HIGH);
digitalWrite(ledy3,HIGH);
digitalWrite(ledr3,LOW);

digitalWrite(ledg4,HIGH);
digitalWrite(ledy4,HIGH);
digitalWrite(ledr4,LOW);
delay(hijau2);

//kuning apil 2 
digitalWrite(ledg2,HIGH);
digitalWrite(ledy2,LOW);
digitalWrite(ledr2,HIGH);
delay(delaykuning);


//hijau apil 3   
digitalWrite(ledg1,HIGH);
digitalWrite(ledy1,HIGH);
digitalWrite(ledr1,LOW);

digitalWrite(ledg2,HIGH);
digitalWrite(ledy2,HIGH);
digitalWrite(ledr2,LOW);

digitalWrite(ledg3,LOW);
digitalWrite(ledy3,HIGH);
digitalWrite(ledr3,HIGH);

digitalWrite(ledg4,HIGH);
digitalWrite(ledy4,HIGH);
digitalWrite(ledr4,LOW);
delay(hijau3);

//kuning apil 3 
digitalWrite(ledg3,HIGH);
digitalWrite(ledy3,LOW);
digitalWrite(ledr3,HIGH);
delay(delaykuning);
   

//hijau apil 4   
digitalWrite(ledg1,HIGH);
digitalWrite(ledy1,HIGH);
digitalWrite(ledr1,LOW);

digitalWrite(ledg2,HIGH);
digitalWrite(ledy2,HIGH);
digitalWrite(ledr2,LOW);

digitalWrite(ledg3,HIGH);
digitalWrite(ledy3,HIGH);
digitalWrite(ledr3,LOW);

digitalWrite(ledg4,LOW);
digitalWrite(ledy4,HIGH);
digitalWrite(ledr4,HIGH);
delay(hijau4);

//kuning apil 4 
digitalWrite(ledg4,HIGH);
digitalWrite(ledy4,LOW);
digitalWrite(ledr4,HIGH);
delay(delaykuning);   

if(hour == awalflash){
mulaiflash();
}
      
}


void settingjam(){

btokx = digitalRead(btok);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);

lcd.setCursor(0,0);
lcd.print("Jam = ");
lcd.print(jam);
lcd.print("   ");

if(btupx == 0){
delay(10);
jam++;
}
if(btdownx == 0){
delay(10);
jam--;
}

if(jam > 23){
jam = 0;
}

if(jam < 0){
jam = 23;
}

if(btokx == 0){
lcd.clear();
delay(100);
return;
}
  
settingjam();  
}


void settingmenit(){

btokx = digitalRead(btok);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);

lcd.setCursor(0,0);
lcd.print("menit = ");
lcd.print(menit);
lcd.print("   ");

if(btupx == 0){
menit++;
}
if(btdownx == 0){
menit--;
}

if(menit > 59){
menit = 0;
}

if(menit < 0){
menit = 59;
}

if(btokx == 0){
lcd.clear();
delay(100);
return;
}
  
settingmenit();  
}



void settinghari(){

btokx = digitalRead(btok);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);

lcd.setCursor(0,0);
lcd.print("hari= ");

if(hari == 1){
lcd.print("senin     ");
}
if(hari == 2){
lcd.print("selasa   ");
}
if(hari == 3){
lcd.print("rabu     ");
}
if(hari == 4){
lcd.print("kamis    ");
}
if(hari == 5){
lcd.print("jumat     ");
}
if(hari == 6){
lcd.print("sabtu    ");
}
if(hari == 7){
lcd.print("minggu    ");
}

if(btupx == 0){
hari++;
}
if(btdownx == 0){
hari--;
}

if(hari < 1){
hari = 7;
}

if(hari > 7){
hari = 1;
}

if(btokx == 0){
lcd.clear();
delay(100);
return;
}
  
settinghari();  
}



void setdelayhijau1(){

btokx = digitalRead(btok);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);

lcd.setCursor(0,0);
lcd.print("delay1= ");
lcd.print(hijau1);
lcd.print("   ");

if(btupx == 0){
hijau1++;
}
if(btdownx == 0){
hijau1--;
}

if(hijau1 < 1){
hijau1 = 1;
}


if(btokx == 0){
lcd.clear();
delay(100);
hijau1 = hijau1 * 100; 
return;
}
  
setdelayhijau1();  
}



void setdelayhijau2(){

btokx = digitalRead(btok);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);

lcd.setCursor(0,0);
lcd.print("delay2= ");
lcd.print(hijau2);
lcd.print("   ");

if(btupx == 0){
hijau2++;
}
if(btdownx == 0){
hijau2--;
}

if(hijau2 < 1){
hijau2 = 1;
}


if(btokx == 0){
lcd.clear();
delay(100);
hijau2 = hijau2 * 100; 
return;
}
  
setdelayhijau2();  
}


void setdelayhijau3(){

btokx = digitalRead(btok);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);

lcd.setCursor(0,0);
lcd.print("delay3= ");
lcd.print(hijau3);
lcd.print("   ");

if(btupx == 0){
hijau3++;
}
if(btdownx == 0){
hijau3--;
}

if(hijau3 < 1){
hijau3 = 1;
}


if(btokx == 0){
lcd.clear();
delay(100);
hijau3 = hijau3 * 100; 
return;
}
  
setdelayhijau3();  
}


void setdelayhijau4(){

btokx = digitalRead(btok);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);

lcd.setCursor(0,0);
lcd.print("delay4= ");
lcd.print(hijau4);
lcd.print("   ");

if(btupx == 0){
hijau4++;
}
if(btdownx == 0){
hijau4--;
}

if(hijau4 < 1){
hijau4 = 1;
}


if(btokx == 0){
lcd.clear();
delay(100);
hijau4 = hijau4 * 100; 
return;
}
  
setdelayhijau4();  
}



void setawalflash(){

btokx = digitalRead(btok);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);

lcd.setCursor(0,0);
lcd.print("awalflash= ");
lcd.print(awalflash);
lcd.print("   ");

if(btupx == 0){
awalflash++;
}
if(btdownx == 0){
awalflash--;
}

if(awalflash < 0){
awalflash = 23;
}

if(awalflash > 23){
awalflash = 0;
}

if(btokx == 0){
lcd.clear();
delay(100);
return;
}
  
setawalflash();  
}


void setakhirflash(){

btokx = digitalRead(btok);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);

lcd.setCursor(0,0);
lcd.print("akhirflash= ");
lcd.print(akhirflash);
lcd.print("   ");

if(btupx == 0){
akhirflash++;
}
if(btdownx == 0){
akhirflash--;
}

if(akhirflash < 0){
akhirflash = 23;
}

if(akhirflash > 23){
akhirflash = 0;
}

if(btokx == 0){
lcd.clear();
delay(100);
return;
}
  
setakhirflash();  
}




void mulaiflash(){
  
displayTime();
delay(1);
  
digitalWrite(ledg1,HIGH);
digitalWrite(ledy1,LOW);
digitalWrite(ledr1,HIGH);

digitalWrite(ledg2,HIGH);
digitalWrite(ledy2,LOW);
digitalWrite(ledr2,HIGH);

digitalWrite(ledg3,HIGH);
digitalWrite(ledy3,LOW);
digitalWrite(ledr3,HIGH);

digitalWrite(ledg4,HIGH);
digitalWrite(ledy4,LOW);
digitalWrite(ledr4,HIGH);
delay(200);

digitalWrite(ledg1,HIGH);
digitalWrite(ledy1,HIGH);
digitalWrite(ledr1,HIGH);

digitalWrite(ledg2,HIGH);
digitalWrite(ledy2,HIGH);
digitalWrite(ledr2,HIGH);

digitalWrite(ledg3,HIGH);
digitalWrite(ledy3,HIGH);
digitalWrite(ledr3,HIGH);

digitalWrite(ledg4,HIGH);
digitalWrite(ledy4,HIGH);
digitalWrite(ledr4,HIGH);
delay(200);

if(hour == akhirflash){
return;
}

mulaiflash();
}






g. VIDEO HASILNYA






(IOT) Monitor 2 Suhu (Temperature) Ds18b20 dan Kendali Relay via Internet ONLINE Aplikasi Blynk ARDUINO WEMOS ESP8266

(IOT) Monitor 2 Suhu (Temperature) Ds18b20 dan Kendali Relay via Internet ONLINE Aplikasi Blynk ARDUINO WEMOS ESP8266  


           Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang berbasis internet dengan fungsi yaitu untuk monitor 2 buah sensor suhu ds18b20 dan kendali 1 buah relay via aplikasi Blynk. alat ini juga dilengkapi 2 buah servo yang berfungsi untuk buka tutup tergantung suhu yang terbaca, jika suhu lebih dari 32 maka servo buka dan jika kurang dari 32 maka servo tutup. alat ini juga dilengkapi sensor tegangan dc sehingga pada interface Blynk tertampil tegangan yang sedang diukur oleh sensor. untuk lebih jelasnya berikut adalah program dan komponennya. 




a. Wemos D1




b. Sensor Tegangan DC




c. Sensor Suhu ds18b20




d. Servo Mini MG90S




e. Modul Relay






f. Program Arduino IDE

#include "Wire.h"
#define BLYNK_PRINT Serial    
#include <SPI.h>
#include <Servo.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <DallasTemperature.h>
#include <OneWire.h>
#define ONE_WIRE_BUS 13 //D7 pin of nodemcu
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "fjhgjHGJHGhjgresNBMNBN-mnmhgfhn";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Hotspotku nich";
char pass[] = "123456789";

SimpleTimer timer;

float suhu;
float suhu2;
Servo myservo1;
Servo myservo2;
int suhupin;
int senPin = A0;  
float v;

void sendSensor()
{
          
sensors.requestTemperatures();
suhu = sensors.getTempCByIndex(0);
suhu2 = sensors.getTempCByIndex(1);

if(suhu < 32){
myservo1.write(100);  
}

if(suhu >= 32){
myservo1.write(150);  
}

if(suhu2 < 32){
myservo2.write(100);  
}

if(suhu2 >= 32){
myservo2.write(150);  
}

Blynk.virtualWrite(V5, suhu);
Blynk.virtualWrite(V6, suhu2);
Blynk.virtualWrite(V7, v);  
}


void setup()
{
  Serial.begin(9600);  
  sensors.begin();
  myservo1.attach(5); //d3
  myservo2.attach(4); //d4 
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(1000L, sendSensor);
}

void loop()
{
  v = analogRead(senPin);
  v =  v * (5.0 / 1023.0);
  v = (v + 0.036) / 0.3075;
  
  Blynk.run(); //relay di D9
  timer.run();
}




g. Gambar Interface Blynk






h. VIDEO HASILNYA