Translate

Monitor Arus dan Tegangan 3 Fasa via IOT BLYNK 2.0

Monitor Arus dan Tegangan 3 Fasa via IOT BLYNK 2.0 



       Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat memonitor tegangan 3 fasa dengan menggunakan IOT Blynk. sensor yang dipakai yaitu PZEM-004t dengan Microcontroller Arduino dan Nodemcu / wemos ESP8266. untuk lebih jelasnya berikut adalah koding dan skemanya.


 
a. Skema



b. Program Arduino IDE

#include <Wire.h>  // i2C Conection Library
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <PZEM004Tv30.h>
#include <SoftwareSerial.h>
LiquidCrystal_I2C lcd(0x27,20,4); 
PZEM004Tv30 pzem1(A12, A13);
PZEM004Tv30 pzem2(A8, A9);
PZEM004Tv30 pzem3(A10, A11);
int voltage1, voltage2, voltage3;
float arusR, arusS, arusT;

void setup() {
  lcd.begin();   
  lcd.noCursor();
  lcd.clear();
  Serial.begin(9600);    
}

void loop() {
  
voltage1 = pzem1.voltage();
voltage2 = pzem2.voltage();
voltage3 = pzem3.voltage();
arusR = pzem1.current();
arusS = pzem2.current();
arusT = pzem3.current();

/*
lcd.setCursor(0, 0);
lcd.print(arusR);
lcd.print("/");
lcd.print(arusS);
lcd.print("/");
lcd.print(arusT);
lcd.print(" ");
*/

lcd.setCursor(0, 1);
lcd.print("VR:  ");
lcd.print(voltage1);
lcd.print("  ");

lcd.setCursor(0, 2);
lcd.print("VS:  ");
lcd.print(voltage2);
lcd.print("  ");

lcd.setCursor(0, 3);
lcd.print("VT:  ");
lcd.print(voltage3);
lcd.print("  ");

Serial.print("*");
Serial.print(voltage1);
Serial.print(",");
Serial.print(voltage2);
Serial.print(",");
Serial.print(voltage3);
Serial.print(",");
Serial.print(arusR * 100.0);
Serial.print(",");
Serial.print(arusS * 100.0);
Serial.print(",");
Serial.print(arusT * 100.0);
Serial.println("#");  

delay(200);
}



c. Progam ESP8266

#define BLYNK_TEMPLATE_ID "TMPL6wxxxxxxx"
#define BLYNK_TEMPLATE_NAME "monitor daya"
#define BLYNK_AUTH_TOKEN "VOK0cWiFN5ycHj3SV_snEDXTfTxxxxx"

#define BLYNK_PRINT Serial    

#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

int temp;
int x = 5;
int y;

int value1;
int value2;

float vr = 0;
float vs = 0;
float vt = 0;
float arusR = 0;
float arusS = 0;
float arusT = 0;

float datain1;
float datain2;
float datain3;
float datain4;
float datain5;
float datain6;

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

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "hotspothpku";
char pass[] = "1234567890";

BlynkTimer timer;

void sendSensor()
{

 Blynk.virtualWrite(V0, vr);
 Blynk.virtualWrite(V1, vs);
 Blynk.virtualWrite(V2, vt);
 Blynk.virtualWrite(V3, arusR);
 Blynk.virtualWrite(V4, arusS);
 Blynk.virtualWrite(V5, arusT);
 delay(1000);

}

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

void loop()
{


if(vr < 200){
   Blynk.logEvent("tegangan Drop"); 
}

if(vs < 200){
   Blynk.logEvent("tegangan Drop"); 
}

if(vt < 200){
   Blynk.logEvent("tegangan Drop"); 
}
  

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();
datain5 = dt[4].toInt();
datain6 = dt[5].toInt();

 vr = datain1 / 1;
 vs = datain2 / 1;
 vt = datain3 / 1;
 arusR = datain4 / 100.0;
 arusS = datain5 / 100.0;
 arusT = datain6 / 100.0;

}



d. VIDEO HASILNYA




No comments:

Post a Comment