Translate

Alat Monitor Arus dan Pembatas Arus Berlebih / Maksimal

 Alat Monitor Arus dan Pembatas Arus Berlebih / Maksimal

           Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara untuk membuat alat untuk memonitor arus dan juga terdapat fitur pembatas arus berlebih, alat ini menggunakan sensor pzem-004t dan kendali menggunakan SSR / solid state relay. untuk lebih jelasnya berikut adalah daftar komponen dan kodingnya.


a. Arduino Mega


b. Sensor PZEM-004t


c. Solid State Relay / SSR


d. Keypad 4x4



e. lcd 16x2 + i2c



f. Koding Arduino IDE Versi 1

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

PZEM004Tv30 pzem1(11,12);
PZEM004Tv30 pzem2(A8, A9);

LiquidCrystal_I2C lcd(0x27, 16, 2);

int relay1 = 2;
int relay2 = 3;
int led1 = 4;
int led2 = 5;
int buzzer1 = 6;
int buzzer2 = 7;
 
int arus1 = 0;
float arusx1;
int arus2 = 0;
float arusx2;
 
float voltage1;
float current1;

float voltage2;
float current2;
    
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] = {A12,A14,32,34}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {36,38,40,42}; //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(relay1, OUTPUT);
  digitalWrite(relay1, LOW);
  pinMode(led1, OUTPUT);
  digitalWrite(led1, HIGH);
  pinMode(buzzer1, OUTPUT);
  digitalWrite(buzzer1, HIGH);
 
  pinMode(relay2, OUTPUT);
  digitalWrite(relay2, LOW);
  pinMode(led2, OUTPUT);
  digitalWrite(led2, HIGH);
  pinMode(buzzer2, OUTPUT);
  digitalWrite(buzzer2, HIGH);
 
  lcd.begin();
  lcd.noCursor();
  lcd.clear();
  Serial.begin(9600);   

}

void loop()
{
 
    voltage1 = pzem1.voltage();
    current1 = pzem1.current();

    voltage2 = pzem2.voltage();
    current2 = pzem2.current();

    lcd.setCursor(0,0);
    lcd.print("I= ");
    lcd.print(current1,2);
    lcd.print(" / ");
    lcd.print(arusx1,2);
    lcd.print("     ");
    
    lcd.setCursor(0,1);
    lcd.print("I= ");
    lcd.print(current2,2);
    lcd.print(" / ");
    lcd.print(arusx2,2);
    lcd.print("     ");
 
    customKey = customKeypad.getKey();
    
    if(customKey == 'A'){
    lcd.clear();
    delay(1000);  
    arus1 = 0;
    arusx1 = 0;
    arus2 = 0;
    arusx2 = 0;
    setting1();
    lcd.clear();
    delay(1000);
    setting2();
    }

    if((current1 > arusx1)&&(arusx1 > 0)){
      digitalWrite(relay1,HIGH);
      digitalWrite(buzzer1,LOW);
      digitalWrite(led1,LOW);
      }

    if((current1 < arusx1)&&(arusx1 > 0)){
      digitalWrite(relay1,LOW);
      digitalWrite(buzzer1,HIGH);
      digitalWrite(led1,HIGH);
      }  

    if((current2 > arusx2)&&(arusx2 > 0)){
      digitalWrite(relay2,HIGH);
      digitalWrite(buzzer2,LOW);
      digitalWrite(led2,LOW);
      }

    if((current2 < arusx2)&&(arusx2 > 0)){
      digitalWrite(relay2,LOW);
      digitalWrite(buzzer2,HIGH);
      digitalWrite(led2,HIGH);
      }

   delay(200);
}

void setting1(){

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

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

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

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

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

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

setting1();
}

void setting2(){

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

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

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

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

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

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

setting2();
}



g. Koding Arduuino IDE Versi 2

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

PZEM004Tv30 pzem1(11,12);
PZEM004Tv30 pzem2(A8, A9);

LiquidCrystal_I2C lcd(0x27, 16, 2);

int relay1 = 2;
int relay2 = 3;
int led1 = 4;
int led2 = 5;
int buzzer1 = 6;
int buzzer2 = 7;
 
int arus1 = 0;
float arusx1;
int arus2 = 0;
float arusx2;
 
float voltage1;
float current1;

float voltage2;
float current2;
    
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] = {A12,A14,32,34}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {36,38,40,42}; //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(relay1, OUTPUT);
  digitalWrite(relay1, LOW);
  pinMode(led1, OUTPUT);
  digitalWrite(led1, HIGH);
  pinMode(buzzer1, OUTPUT);
  digitalWrite(buzzer1, HIGH);
 
  pinMode(relay2, OUTPUT);
  digitalWrite(relay2, LOW);
  pinMode(led2, OUTPUT);
  digitalWrite(led2, HIGH);
  pinMode(buzzer2, OUTPUT);
  digitalWrite(buzzer2, HIGH);
 
  lcd.begin();
  lcd.noCursor();
  lcd.clear();
  Serial.begin(9600);   

}

void loop()
{
 
    voltage1 = pzem1.voltage();
    current1 = pzem1.current();

    voltage2 = pzem2.voltage();
    current2 = pzem2.current();

    lcd.setCursor(0,0);
    lcd.print("I= ");
    lcd.print(current1,2);
    lcd.print(" / ");
    lcd.print(arusx1,2);
    lcd.print("     ");
    
    lcd.setCursor(0,1);
    lcd.print("I= ");
    lcd.print(current2,2);
    lcd.print(" / ");
    lcd.print(arusx2,2);
    lcd.print("     ");
 
    customKey = customKeypad.getKey();
    
    if(customKey == 'A'){
    lcd.clear();
    delay(1000);  
    arus1 = 0;
    arusx1 = 0;
    arus2 = 0;
    arusx2 = 0;
    setting1();
    lcd.clear();
    delay(1000);
    setting2();
    }

    if((current1 > arusx1)&&(arusx1 > 0)){
      digitalWrite(relay1,HIGH);
      digitalWrite(buzzer1,LOW);
      digitalWrite(led1,LOW);
      delay(1000);
      digitalWrite(relay1,LOW);
      }

    if((current1 < arusx1)&&(arusx1 > 0)){
      digitalWrite(relay1,LOW);
      digitalWrite(buzzer1,HIGH);
      digitalWrite(led1,HIGH);
      }  

    if((current2 > arusx2)&&(arusx2 > 0)){
      digitalWrite(relay2,HIGH);
      digitalWrite(buzzer2,LOW);
      digitalWrite(led2,LOW);
      delay(1000);
      digitalWrite(relay2,LOW);
      }

    if((current2 < arusx2)&&(arusx2 > 0)){
      digitalWrite(relay2,LOW);
      digitalWrite(buzzer2,HIGH);
      digitalWrite(led2,HIGH);
      }

   delay(200);
}

void setting1(){

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

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

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

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

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

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

setting1();
}

void setting2(){

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

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

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

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

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

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

setting2();
}


h. VIDEO HASILNYA



 

 

No comments:

Post a Comment