Energy Monitoring & Controlling System by Proteus
Phase angle, Power factor, Voltage, Current, Real Power, Reactive power, Apparent power, Frequency, Time, Power (W, Kw, Kwh).
Components and supplies
1
DS3231M - ±5ppm, I2C Real-Time Clock
1
Resistor 10k ohm
1
High Accuracy Pi RTC (DS3231)
1
Arduino Mega 2560
1
Oscillator IC, Voltage Controlled
Project description
Code
Code
c_cpp
Here added project code.
1#include <Wire.h> 2#include <ds3231.h> 3#include<math.h> 4 5 6// Power factor variable decleation 7float PulsWidth = 0; 8float PowerFactor = 0; 9float Phase = 0; 10 11 12//Real power variable declearation 13int x; 14float v; 15double AcsOffset = 2.5; 16double Sensibl = 0.100; 17double I = 0; //Current 18double ReadVoltage = 0; 19double P;// real power 20 21 22// Reactive power Variable declearition 23double Q; // Reactive power 24double ReactivePower; 25 26 27// Apparant Power Variable declearition 28double S, X, y; 29 30//Frequency variable declearation 31const int PulsePin = 7; 32int PulseHigh; // Integer variable to capture High time of the incoming pulse 33int PulseLow; // Integer variable to capture Low time of the incoming pulse 34float PulseTotal; // Float variable to capture Total time of the incoming pulse 35float Frequency; // Calculated Frequency 36 37 38// bills variavle declaration 39double kw, kwh, Price; 40 41 42// Time RTC 43struct ts t; 44int input = 2, output = 3 ; 45//const int temp = 10; 46double T; 47 48 49void setup() 50{ 51 pinMode(A0, INPUT); 52 pinMode(A1, INPUT); 53 pinMode(PulsePin, INPUT); // For requency 54 55 Serial.begin(9600); 56 57 // RTC TIME CLOCK 58 Wire.begin(); 59 DS3231_init(DS3231_INTCN); 60 61 t.hour=00; 62 t.min=00; 63 t.sec = 0; 64 t.mday=15; 65 t.mon=8; 66 t.year=2021; 67 68 pinMode(input, INPUT); 69 pinMode(output, INPUT); 70 71 DS3231_set(t); 72} 73 74void loop() 75{ 76 //Starts here 77 Serial.println("=====================Printing Values======================="); 78 79 // Power factor 80 PulsWidth = pulseIn(8, HIGH); 81 Phase = (2 * 180 * 50 * PulsWidth) / 1000000; 82 Serial.print("Phase = "); 83 Serial.print(Phase); 84 Serial.println(" Degree"); 85 86 delay(400); 87 88 PowerFactor = cos(Phase * 3.1416 / 180); 89 Serial.print("Power Fector = "); 90 Serial.println(PowerFactor); 91 92 delay(400); 93 94 // Voltage 95 x = analogRead(A0); 96 v = (x * 0.304177); 97 Serial.print("Voltage = "); 98 Serial.print(v); 99 Serial.println(" V"); 100 101 delay(400); 102 103 // Current 104 double Value = analogRead(A1); 105 ReadVoltage = (Value * 5.0 / 1023); 106 I = (ReadVoltage - AcsOffset) / Sensibl; 107 Serial.print("Current = "); 108 Serial.print(I); 109 Serial.println(" A"); 110 111 delay(400); 112 113 // Real Power 114 P = (v * I * PowerFactor); 115 Serial.print("Real Power = "); 116 Serial.print(P); 117 Serial.println(" W"); 118 119 delay(400); 120 121 // Reactive Power 122 ReactivePower = sin(Phase * 3.1416 / 180); 123 Q = v * I * ReactivePower; 124 Serial.print("Reactive Power = "); 125 Serial.print(Q); 126 Serial.println(" KVAR"); 127 128 delay(400); 129 130 // Apparant Power 131 X = pow(P, 2); 132 y = pow(Q, 2); 133 134 Serial.print("Apparant Power = "); 135 Serial.print(P+Q); 136 Serial.println(" KVA"); 137 138 delay(400); 139 140 // Frequency 141 PulseHigh = pulseIn(PulsePin, HIGH); 142 PulseLow = pulseIn(PulsePin, LOW); 143 PulseTotal = PulseHigh + PulseLow; // Time period of the pulse in microseconds 144 Frequency = 1000000 / PulseTotal; // Frequency in Hertz (Hz) 145 Serial.print("Frequency = "); 146 Serial.print(Frequency); 147 Serial.println(" Hz"); 148 149 delay(400); 150 151 //RTC Time Clock 152 DS3231_get(&t); 153 154 if (digitalRead(input) == HIGH) 155 { 156 Serial.print("Time = "); 157 Serial.print(t.sec); 158 Serial.println(" s"); 159 160 delay(400); 161 162 Serial.print("Power = "); 163 Serial.print(P); 164 Serial.println(" W"); 165 166 delay(400); 167 168 kw = P / 1000; 169 Serial.print("Power Kw = "); 170 Serial.print(kw); 171 Serial.println(" kw"); 172 173 delay(400); 174 175 Serial.print("Power kwh = "); 176 T = t.sec; 177 kwh = kw * (T / 60); 178 Serial.print(kwh); 179 Serial.println(" kwh"); 180 181 delay(400); 182 183 Price = kwh * 5.72; //5.72 Tk per unit in BD 184 Serial.print("Price = "); 185 Serial.print(Price); 186 Serial.println(" TK"); 187 188 delay(400); 189 190 Serial.println("==========================================================="); 191 Serial.println(); 192 Serial.println(); 193 } 194 195 else 196 { 197 Serial.println("System Failure"); 198 } 199 200} 201
Code
c_cpp
Here added project code.
1#include <Wire.h> 2#include <ds3231.h> 3#include<math.h> 4 5 6// Power factor variable decleation 7float PulsWidth = 0; 8float PowerFactor = 0; 9float Phase = 0; 10 11 12//Real power variable declearation 13int x; 14float v; 15double AcsOffset = 2.5; 16double Sensibl = 0.100; 17double I = 0; //Current 18double ReadVoltage = 0; 19double P;// real power 20 21 22// Reactive power Variable declearition 23double Q; // Reactive power 24double ReactivePower; 25 26 27// Apparant Power Variable declearition 28double S, X, y; 29 30//Frequency variable declearation 31const int PulsePin = 7; 32int PulseHigh; // Integer variable to capture High time of the incoming pulse 33int PulseLow; // Integer variable to capture Low time of the incoming pulse 34float PulseTotal; // Float variable to capture Total time of the incoming pulse 35float Frequency; // Calculated Frequency 36 37 38// bills variavle declaration 39double kw, kwh, Price; 40 41 42// Time RTC 43struct ts t; 44int input = 2, output = 3 ; 45//const int temp = 10; 46double T; 47 48 49void setup() 50{ 51 pinMode(A0, INPUT); 52 pinMode(A1, INPUT); 53 pinMode(PulsePin, INPUT); // For requency 54 55 Serial.begin(9600); 56 57 // RTC TIME CLOCK 58 Wire.begin(); 59 DS3231_init(DS3231_INTCN); 60 61 t.hour=00; 62 t.min=00; 63 t.sec = 0; 64 t.mday=15; 65 t.mon=8; 66 t.year=2021; 67 68 pinMode(input, INPUT); 69 pinMode(output, INPUT); 70 71 DS3231_set(t); 72} 73 74void loop() 75{ 76 //Starts here 77 Serial.println("=====================Printing Values======================="); 78 79 // Power factor 80 PulsWidth = pulseIn(8, HIGH); 81 Phase = (2 * 180 * 50 * PulsWidth) / 1000000; 82 Serial.print("Phase = "); 83 Serial.print(Phase); 84 Serial.println(" Degree"); 85 86 delay(400); 87 88 PowerFactor = cos(Phase * 3.1416 / 180); 89 Serial.print("Power Fector = "); 90 Serial.println(PowerFactor); 91 92 delay(400); 93 94 // Voltage 95 x = analogRead(A0); 96 v = (x * 0.304177); 97 Serial.print("Voltage = "); 98 Serial.print(v); 99 Serial.println(" V"); 100 101 delay(400); 102 103 // Current 104 double Value = analogRead(A1); 105 ReadVoltage = (Value * 5.0 / 1023); 106 I = (ReadVoltage - AcsOffset) / Sensibl; 107 Serial.print("Current = "); 108 Serial.print(I); 109 Serial.println(" A"); 110 111 delay(400); 112 113 // Real Power 114 P = (v * I * PowerFactor); 115 Serial.print("Real Power = "); 116 Serial.print(P); 117 Serial.println(" W"); 118 119 delay(400); 120 121 // Reactive Power 122 ReactivePower = sin(Phase * 3.1416 / 180); 123 Q = v * I * ReactivePower; 124 Serial.print("Reactive Power = "); 125 Serial.print(Q); 126 Serial.println(" KVAR"); 127 128 delay(400); 129 130 // Apparant Power 131 X = pow(P, 2); 132 y = pow(Q, 2); 133 134 Serial.print("Apparant Power = "); 135 Serial.print(P+Q); 136 Serial.println(" KVA"); 137 138 delay(400); 139 140 // Frequency 141 PulseHigh = pulseIn(PulsePin, HIGH); 142 PulseLow = pulseIn(PulsePin, LOW); 143 PulseTotal = PulseHigh + PulseLow; // Time period of the pulse in microseconds 144 Frequency = 1000000 / PulseTotal; // Frequency in Hertz (Hz) 145 Serial.print("Frequency = "); 146 Serial.print(Frequency); 147 Serial.println(" Hz"); 148 149 delay(400); 150 151 //RTC Time Clock 152 DS3231_get(&t); 153 154 if (digitalRead(input) == HIGH) 155 { 156 Serial.print("Time = "); 157 Serial.print(t.sec); 158 Serial.println(" s"); 159 160 delay(400); 161 162 Serial.print("Power = "); 163 Serial.print(P); 164 Serial.println(" W"); 165 166 delay(400); 167 168 kw = P / 1000; 169 Serial.print("Power Kw = "); 170 Serial.print(kw); 171 Serial.println(" kw"); 172 173 delay(400); 174 175 Serial.print("Power kwh = "); 176 T = t.sec; 177 kwh = kw * (T / 60); 178 Serial.print(kwh); 179 Serial.println(" kwh"); 180 181 delay(400); 182 183 Price = kwh * 5.72; //5.72 Tk per unit in BD 184 Serial.print("Price = "); 185 Serial.print(Price); 186 Serial.println(" TK"); 187 188 delay(400); 189 190 Serial.println("==========================================================="); 191 Serial.println(); 192 Serial.println(); 193 } 194 195 else 196 { 197 Serial.println("System Failure"); 198 } 199 200} 201
Downloadable files
circuit diagram
Here added project circuit diagram.
circuit diagram

Comments
Only logged in users can leave comments