hrsajjad844
Published © MIT

Energy Monitoring & Controlling System by Proteus

Phase angle, Power factor, Voltage, Current, Real Power, Reactive power, Apparent power, Frequency, Time, Power (W, Kw, Kwh).

AdvancedShowcase (no instructions)1,123
Energy Monitoring & Controlling System by Proteus

Things used in this project

Story

Read more

Schematics

circuit diagram

Here added project circuit diagram.

Code

Code

C/C++
Here added project code.
#include <Wire.h>
#include <ds3231.h> 
#include<math.h>


// Power factor variable decleation
float PulsWidth = 0;
float PowerFactor = 0;
float Phase = 0;


//Real power variable declearation
int x;
float v;
double AcsOffset = 2.5;
double Sensibl = 0.100;
double I = 0;   //Current
double ReadVoltage = 0;
double P;// real power


// Reactive power Variable declearition
double Q;   // Reactive power
double ReactivePower;


// Apparant Power Variable declearition
double S, X, y;

//Frequency variable declearation
const int PulsePin = 7;
int PulseHigh;     // Integer variable to capture High time of the incoming pulse
int PulseLow;     // Integer variable to capture Low time of the incoming pulse
float PulseTotal;     // Float variable to capture Total time of the incoming pulse
float Frequency;     // Calculated Frequency


// bills variavle declaration
double kw, kwh, Price;


// Time RTC
struct ts t;
int input = 2, output = 3 ;
//const int temp = 10;
double T;


void setup() 
{
  pinMode(A0, INPUT);
  pinMode(A1, INPUT);
  pinMode(PulsePin, INPUT);     // For requency
  
  Serial.begin(9600);
  
  // RTC TIME CLOCK
  Wire.begin();
  DS3231_init(DS3231_INTCN);
  
  t.hour=00;
  t.min=00;
  t.sec = 0;
  t.mday=15;
  t.mon=8;
  t.year=2021;
  
  pinMode(input, INPUT);
  pinMode(output, INPUT);
  
  DS3231_set(t);
}

void loop() 
{
  //Starts here
  Serial.println("=====================Printing Values=======================");
  
  // Power factor
  PulsWidth = pulseIn(8, HIGH);
  Phase = (2 * 180 * 50 * PulsWidth) / 1000000;
  Serial.print("Phase = ");
  Serial.print(Phase);
  Serial.println(" Degree");
  
  delay(400);

  PowerFactor = cos(Phase * 3.1416 / 180);
  Serial.print("Power Fector = ");
  Serial.println(PowerFactor);
  
  delay(400);
  
  // Voltage
  x = analogRead(A0);
  v = (x * 0.304177);  
  Serial.print("Voltage = ");
  Serial.print(v);
  Serial.println(" V");
  
  delay(400);
  
  // Current
  double Value = analogRead(A1);
  ReadVoltage = (Value * 5.0 / 1023);
  I = (ReadVoltage - AcsOffset) / Sensibl;
  Serial.print("Current = ");
  Serial.print(I);
  Serial.println(" A");
  
  delay(400);
  
  // Real Power
  P = (v * I * PowerFactor);
  Serial.print("Real Power = ");
  Serial.print(P);
  Serial.println(" W");
  
  delay(400);
  
  // Reactive Power
  ReactivePower = sin(Phase * 3.1416 / 180);
  Q = v * I * ReactivePower;
  Serial.print("Reactive Power = ");
  Serial.print(Q);
  Serial.println(" KVAR");

  delay(400);
  
  // Apparant Power
  X = pow(P, 2);
  y = pow(Q, 2);
  
  Serial.print("Apparant Power = ");
  Serial.print(P+Q);
  Serial.println(" KVA");

  delay(400);
  
  // Frequency
  PulseHigh = pulseIn(PulsePin, HIGH);
  PulseLow = pulseIn(PulsePin, LOW);
  PulseTotal = PulseHigh + PulseLow;  // Time period of the pulse in microseconds
  Frequency = 1000000 / PulseTotal;  // Frequency in Hertz (Hz)
  Serial.print("Frequency = ");
  Serial.print(Frequency);
  Serial.println(" Hz");
  
  delay(400);
  
  //RTC Time Clock
  DS3231_get(&t);

  if (digitalRead(input) == HIGH)
  {
    Serial.print("Time = ");
    Serial.print(t.sec);
    Serial.println(" s");
    
    delay(400);
    
    Serial.print("Power = ");
    Serial.print(P);
    Serial.println(" W");
    
    delay(400);

    kw = P / 1000;
    Serial.print("Power Kw = ");
    Serial.print(kw);
    Serial.println(" kw");
    
    delay(400);
    
    Serial.print("Power kwh = ");
    T = t.sec;
    kwh = kw * (T / 60);
    Serial.print(kwh);
    Serial.println(" kwh");
    
    delay(400);

    Price = kwh * 5.72;   //5.72 Tk per unit in BD
    Serial.print("Price = ");
    Serial.print(Price);
    Serial.println(" TK");

    delay(400);

    Serial.println("===========================================================");
    Serial.println();
    Serial.println();
  }
  
  else
  {
    Serial.println("System Failure");
  }

}

Credits

hrsajjad844
1 project • 16 followers
Contact

Comments

Please log in or sign up to comment.