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








No comments:

Post a Comment