Monitor Tegangan Arus Daya KWH Meter Sensor PZEM-004t IOT BLYNK 2.0 ESP8266 NODEMCU
Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat mengukur tegangan arus daya dari VAC 220v. alat ini menggunakan IoT Blynk untuk memonitornya dan juga untuk mengendalikan relaynya. untuk lebih jelasnya berikut adalah kodingnya.
a. Komponen
2. Program Arduino IDE
#define BLYNK_TEMPLATE_ID "TMPL651DVXXXX"
#define BLYNK_TEMPLATE_NAME "monitor daya"
#define BLYNK_AUTH_TOKEN "3_d7wLIQkxjAFuAe9_jY_IXSDrMXxXxx"
#define BLYNK_PRINT Serial
#include <Wire.h>
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SoftwareSerial.h>
#include <PZEM004Tv30.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
PZEM004Tv30 pzem(D7,D8);
float voltage;
float current;
float power;
int relay = D6;
int pinValue;
BlynkTimer timer;
char ssid[] = "hotspothpku";
char pass[] = "123456789";
BLYNK_WRITE(V3)
{
pinValue = param.asInt();
if(pinValue == 1){
digitalWrite(relay, LOW);
}
if(pinValue == 0) {
digitalWrite(relay, HIGH);
}
Serial.print("button value is: ");
Serial.println(pinValue);
}
void sendSensor()
{
Blynk.virtualWrite(V0, voltage);
Blynk.virtualWrite(V1, current);
Blynk.virtualWrite(V2, power);
delay(1000);
}
void setup() {
Serial.begin(9600);
lcd.begin();
lcd.noCursor();
lcd.clear();
pinMode(relay,OUTPUT);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
timer.setInterval(1000L, sendSensor);
}
void loop() {
voltage = pzem.voltage();
current = pzem.current();
power = pzem.power();
lcd.setCursor(0, 0);
lcd.print("V:");
lcd.print(voltage,1);
lcd.print(" P:");
lcd.print(power,1);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print("I:");
lcd.print(current,1);
lcd.print(" ");
if(current > 5){
digitalWrite(relay, LOW);
}
Blynk.run();
timer.run();
delay(200);
}
#define BLYNK_TEMPLATE_NAME "monitor daya"
#define BLYNK_AUTH_TOKEN "3_d7wLIQkxjAFuAe9_jY_IXSDrMXxXxx"
#define BLYNK_PRINT Serial
#include <Wire.h>
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SoftwareSerial.h>
#include <PZEM004Tv30.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
PZEM004Tv30 pzem(D7,D8);
float voltage;
float current;
float power;
int relay = D6;
int pinValue;
BlynkTimer timer;
char ssid[] = "hotspothpku";
char pass[] = "123456789";
BLYNK_WRITE(V3)
{
pinValue = param.asInt();
if(pinValue == 1){
digitalWrite(relay, LOW);
}
if(pinValue == 0) {
digitalWrite(relay, HIGH);
}
Serial.print("button value is: ");
Serial.println(pinValue);
}
void sendSensor()
{
Blynk.virtualWrite(V0, voltage);
Blynk.virtualWrite(V1, current);
Blynk.virtualWrite(V2, power);
delay(1000);
}
void setup() {
Serial.begin(9600);
lcd.begin();
lcd.noCursor();
lcd.clear();
pinMode(relay,OUTPUT);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
timer.setInterval(1000L, sendSensor);
}
void loop() {
voltage = pzem.voltage();
current = pzem.current();
power = pzem.power();
lcd.setCursor(0, 0);
lcd.print("V:");
lcd.print(voltage,1);
lcd.print(" P:");
lcd.print(power,1);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print("I:");
lcd.print(current,1);
lcd.print(" ");
if(current > 5){
digitalWrite(relay, LOW);
}
Blynk.run();
timer.run();
delay(200);
}
3. VIDEO HASILNYA
No comments:
Post a Comment