Fibañ
Fibañ
Fibañ
University of Antique
COLLEGE OF ENGINEERING AND ARCHITECTURE
Sibalom, Antique
CHAPTER 1
INTRODUCTION
the world of power sector. Increasing the use of inductive loads generate
lagging currents that result into poor power factor of an electrical system. In
system has a poor power factor, it will draw higher current than an electrical
system with a power factor close to unity. This might be a cause of losses,
Higher currents can also result into voltage fluctuation that could
study will be useful for this study will improve the power factor which at the
same time monitor the voltage and alert the end user when voltage fluctuation
occur.
available in the market are too expensive. In this study, the researchers will
design and construct a device which is easy to assemble and cheaper than
1
The researcher will also investigate the use of the said microcontroller
to monitor the voltage and power factor of electricity. To improve the poor
into separate relay to improve the power factor of an electrical system. This
research will try to help solve the above mentioned problem. Which would
create a good quality of electricity for an equipment, gadgets and all other
loads to maintain your machines in good conditions and extend their life
span.
This study aimed to construct a portable device which will help improve
the power factor of an electrical system focusing on inductive linear loads and
also alert the user about voltage fluctuation.
2
1. End-user-of electricity
The end user will benefit on the device constructed in this study for
once the power factor of electrical system was improved, the current drawn
by the long line which supplies the inductive loadings will be reduced. This
means that it will free up some more capacity into the system then increase
their equipment’s condition and longevity for it decreases the voltage drop of
the system which reduce the fluctuation. This will be more economical in the
2. Distribution Utilities
The device in this study can be used as a power factor correction in the
distribution system. The improvement of the power factor from the load side
of every end user free up some capacity in the transformer that supplies
factor is cost economic because it reduces the parameters used to follow the
3
line supplying the building due to high current running through those long
cables. Power factor improvement reduces current drawn by poor power factor
circuit. This study could somehow correct a power factor to reduce voltage
fluctuations.
connected. The status (Voltage, Current, Reactive Power and Power Factor)
will be displayed in the liquid crystal display (LCD) Module and the user of
the system will be notified via SMS about the power factor or if there is a
electrical system where the maximum current drawn is 10A. The triggering
reactive power will depend on the individual capacitance of the capacitor. This
would mean that if the reactive compensation of the smallest capacitor is 240
reactive power before the first capacitor is connected into the line. This system
loads.
The device focused on improving the poor power factor of a 1.5 horse
power (HP) AC kenzo capacitor start motor type YC90L-4. In this study,
4
parallel with the line supplying inductive loading. Then the system notified
the user via global system for mobile communication (GSM) when both the
power factor was not in the range programmed in the device and when the
reactive power must at least meet the reactive compensation that can be
This device will be initialized around 5-7seconds for the GSM to register
service (SMS) when the user is out of reach and/or the Subscriber Identity
Module (SIM) Card in the GSM module has not been loaded. The mobile
(ranging from 0-100A) and power (22 kilowatts (kW)). The amount of
the microcontroller.
fluctuation occurred and or if the power factor was not within the range
the user about the current voltage or the power factor. The power factor
needed.
5
Due to the limitation in the rated capacitance of the capacitors the
capacitor). Thereby, this device is suitable for inductive loads whose reactive
power is above 240VAR. The power factor improvement of this device depends
on the reactive compensation of the power factor correcting capacitor and the
reactive power consumed by the load. The closer the reactive power of the
load to the reactive power compensated by the device the better the
improvement will be
This device will be enclosed with a portable and metal casing to protect
the system from any natural disturbances and also to ensure the safety of the
waves is not a concern of this study. It could be a subject for future studies.
SMS. In case of power interruption, there is no need for the system to work
6
1.5 Conceptual Framework
Knowledge Requirement
1. Arduino Programming
2. Power Factor
calculations
3. Reactive power
Design
calculations
4. Construction works
Software Requirements
1. Arduino IDE
Hardware requirements
Microcontroller Based
1. Microcontroller Power Factor
Fabrication
2. AC Power Monitoring improvement with
Voltage Monitoring
Module
3. LCD module
4. Relay Module
5. Capacitors
6. GSM module
1. Soldering Iron
2. Multimeter
3. Wires
4. Bolts
Current flows from negative to positive points. The SI unit for measuring
electric current is the ampere (A). One ampere of current is defined as one
Electricity, refers to the presence and flow of electric charge. Its best-
wires.
8
Electrical systems, refers to the groups of electrical components
GSM/GPRS network, available for GPRS and SMS message data remote
transmission.
current and as such, when you measure the current, it lags (is behind) the
voltage.
Power Factor, refers to the ratio of the real power flowing to the load
current transformer and USB adapter. The module can be used to test
terminals.
9
Reactive Power, refers to the power which flows back and forth that
mean it moves in both the direction in the circuit or react upon itself, is
Root Mean Square (RMS), refers to the RMS value is the square root
values. The amount of AC power that produces the same heating effect as
an equivalent DC power.
standard level.
standard level.
10
CHAPTER 2
Low power factor of electrical loads cause high current drawn from
load. In this manner, the key thought of this examination is the way
how effectively you are using electricity. Various types of power are at work
to provide us with electrical energy. Enhancing the power factor can maximize
losses, and lower electric bills. The least difficult approach to enhance power
11
thereby enhancing the power factor. The connection between power factor
Moreover, Jim Plourde (2011) stated that the first and most obvious
opportunity for motor energy saving is power factor correction. The power
factor of an AC electrical system is the ratio of the "real" power setting off to
the load to the "apparent" power in the circuit. Loads with a low power factor
will draw more current than a load with a high power factor for a similar
does not affect the magnetizing current or the leakage reactance of the motor,
but it offsets the inductive component at the point where the capacitor is
smaller until a unity power factor is achieved (θ = 0). At unity power factor,
transfer.
the power factor because in most power systems, a poor power factor resulting
factor correction unit would allow the system to restore its power factor close
to unity for economical operation. There are many methods of improving the
power factor that have been proposed such as capacitor banking, using
12
LCD MODULE (LIQUID CRYSTAL DISPLAY)
find a wide range of applications. A 16x2 LCD display is very basic module
and is very commonly used in various devices and circuits. A 16x2 LCD
means it can display 16 characters per line and there are 2 such lines. In this
13
Figure 1. LCD Module
https://www.engineersgarage.com/electronic-components/16x2-lcd-module-datasheet
RELAY MODULE
work under AC250V 10A or DC30V 10A. It has a standard interface that
14
Figure 2. 4 channel 5v relay module
http://wiki.sunfounder.cc/index.php?title=4_Channel_5V_Relay_Module
PZEM-004T
and USB adapter. The module can be used to test power, energy, voltage as
one key reset button, you can reset energy data by simply pressing one
button. Moreover, it can store data when power off, and store the
accumulated energy data before power off, so it is very convenient to use it.
15
Figure 3. PZEM – 004T module
https://www.amazon.com/PZEM-004T-Current-Voltage-Multimeter-80-260V/dp/B074QF7PGM
ARDUINO UNO
16
Figure 4. Arduino Uno
https://www.trossenrobotics.com/p/arduino-uno.aspx
available for GPRS and SMS message data remote transmission. The
Commands.
17
https://robokits.co.in/wireless-solutions/gsm-gprs/sim800l-gprs-gsm-module-micro-sim-card-core-
board-quad-band-ttl
electrical capacitor that alters the current to one or more windings of a single
18
https://www.aliexpress.com/item/CBB65A-1-40uF-5-AC-450V-50-60Hz-Non-Polar-Motor-Capacitor-
for-Air-Conditioner/32538327757.html
SOCKETS
primary alternating current (AC) power supply in buildings and at other sites.
19
https://en.wikipedia.org/wiki/AC_power_plugs_and_sockets
we are wasting a part of energy every day due to lagging power factor. The
the power factor. There are many methods of improving a power factor have
condenser instead of capacitor bank because of long life, achieve step less
windings offer higher thermal stability for higher short circuit currents. But
the disadvantages of this method is that the maintenance cost is high due to
rotating component, produces noise, there are losses in the motor, at low
power rating the cost is high compared to static capacitor method, and it
20
of synchronous condenser so as to improve power factor (Sayed, Ferdous &
People are not aware of energy wastage thus having poor power factor
current that may damage wire cables, voltage fluctuation due to voltage drop
and several losses are greatly ignored. A power factor correction unit would
allow the system to restore its power factor close to unity to minimize losses
and wastage.
footprint. Power factor correction was designed to build a device which is able
its power factor. An open source energy monitoring library was implemented
in the design for accurate power calculation. The device calculates the
lagging power factor using capacitance from a capacitor bank (Yasin Kabir,
21
Automatic Power Factor Controller using Pic Microcontroller
falls less than 0.9. ULN2003 turn on relays which in return connects
capacitor banks with the load. First of all the phase difference between voltage
and current waveforms are measured and then power factor is calculated. In
case of low power factor capacitors are added to improve it (Malik, 2015).
http://microcontrollerslab.com/automatic-power-factor-controller-using-pic-microcontroller/
accurate and reliable system to for measurement. This project work presents
a novel smart meter for an automatic and superior metering, billing and
warning system. The integration of the Arduino and LCD provide the meter
reading system with some automatic functions that are predefined. The
22
Peacefair. PZEM-004T having the ability to measure Electrical parameters
https://innovatorsguru.com/ac-digital-multi-function-smart-meter-using-arduino-and-pzem-004t/
microcontroller. If the calculated power factor is less than 0.9 then the relay
switches on the capacitor. The relays are switched using ULN2003 which is
is usually present in loads. Hence the phase difference between the current
https://electrosome.com/automatic-power-factor-controller-using-microcontroller/
This paper presents the design of a simple low cost wireless GSM energy
meter and its associated web interface, for automating billing and managing
the collected data globally. The proposed system replaces traditional meter
reading methods and enables remote access of existing energy meter by the
energy provider. Also they can monitor the meter readings regularly without
the person visiting each house. A GSM based wireless communication module
is integrated with electronic energy meter of each entity to have remote access
23
https://ieeexplore.ieee.org/document/6526385
CHAPTER 3
RESEARCH METHODOLOGY
This chapter details the step-by-step procedure of the project design, project
researcher.
2. The device have three direct current (DC) power supply inside one for
arduino and GSM module and LCD, one for the relay, and one for the
4. The power supply of the microcontroller, sensor and the relay was
different.
8. The capacitance of four capacitors were 12uF, 20uF, 40uF and 40uF.
24
9. GSM module used was Sim800l. The number of the recipient will be
11. The step correction of the device were as follow. At 230V AC, 60Hz
maximum.
Reactive power
Complex power(S) composed of the Real power (P) and the Reactive
power (Q). Calculation for the amount of capacitor to be switched into the
25
Mathematically, reactive power (Q):
Q = tan (Ө) * P
Where:
Ө = cos-1(P.F.)
( )
P.F. = ( )
Real Power (P), Vrms and Irms will be provided by the PZEM – 004T
Xc = = (⊖)∗
;
C=
( (⊖))
C=
Where:
Power Factor.
Q= * 2π*(Frequency)*(Capacitance)
Capacitor 1:
C = 12uF
Q = 230 * 2π*(60Hz)*(12*10 )
Q = 239.31 VAR
Capacitor 2:
C = 20uF
Q = 230 * 2π*(60Hz)*(20*10 )
Q = 398.86VAR
Capacitor 3:
C = 40uF
Q = 230 * 2π*(60Hz)*(40*10 )
Q = 797.71VAR
Capacitor 4:
C = 40uF
Q = 230 * 2π*(60Hz)*(40*10 )
27
Q = 797.71VAR
797.71VAR
28
MICROCONTROLLER BASED POWER FACTOR IMPROVEMENT WITH
VOLTAGE MONITORING
POWER
RELAY
SUPPLY
CAPACITORS LOAD
29
MICROCONTROLLER BASED POWER FACTOR IMPROVEMENT WITH
VOLTAGE MONITORING
START
INITIALIZE
T
READ PARAMETERS
DISPLAY
CHECK VOLTAGE
CHECK SMS
STATUS IS SMS SENT
ONCE
YES
DISPLAY
NO
YES
IS 0.80< PF <1 and VAR < 240
SEND SMS
NO
SEND SMS
SWITCH CAPACITOR
SEND SMS
DISPLAY
30
FABRICATION DESIGN
PZEM-004T Source
Lcd
Switch
Input
SOCKET GSM
RELAY ARDUINO
CAPACITORS
Switch
LCD Source
Input
Top View
SOCKET
FAN
31
SCHEMATIC DIAGRAM
32
Tools and Equipment Used
1. Multimeter
2. Pliers
3. Soldering Iron
4. Soldering Lead
5. Soldering Pump
6. Wires
7. Electric Drill
8. Breadboard
Construction Procedure
33
3.4 OPERATION AND TESTING PROCEDURE
The following procedures were followed for the test ‘run’ of the device:
In testing the operation of the system, the following procedures were done,
34
3. If the voltage is not within the range specified in the program a
SMS will be sent to the user as well as when the power factor is not
4. If the relays remains off because the power factor is not out of
range, wait for the LCD to update. This is indicated by brief flashing of
LCD module.
6. If power factor is less than 0.80 with Reactive Power greater than
240 VAR, microcontroller will send a message to the user and turn on
7. After the relays turn on and the capacitors connects with load, an
35
Instrumentation-Tools
a. Pliers – is a hand tool with two hinged arms ending in jaws that are
tool attachment usually a drill bit or driver bit, use for boring holes in
fasteners.
e. Soldering iron – is a tool that electrical heated and used for joining
36
Cost Estimate
(Php.) (Php.)
Soldering Meter 2 15 30
Lead
Wires Meter 3 20 60
Switch Pc. 1 40 40
37
Total 6840
Cost Analysis
Printing 500
TOTAL 13400
present during the said activity and were given evaluation copy. Respondents
38
who weren’t there during the demonstration were shown a video containing
Treatment of Data
From the data gathered, the mean (x) for each criterion was computed.
Then scoring system was employed in the scale of one (1) to five (5) with one
being lowest and five as the highest. The state criteria were scored and rated
5 Very Acceptable
4 Acceptable
3 Moderately Acceptable
2 Inacceptable
1 Very Inacceptable
The mean (x) for every criterion was computed and from it, the grand mean
(X) was computed to check the overall acceptability of the project. The
Where:
39
TIME TABLE
40
CHAPTER 4
the project.
voltage via GSM and automatically improved the power factor. The system
the low power factor by triggering-on and off a relay depending on how much
the capacitor is needed to improve the power factor. The project used PZEM-
The Power Factor Correction was enclosed in a metal casing. The GSM
fan were placed inside for the better arrangement and for protection. The LCD
Module was mounted in the casing and connected to the devices inside the
case, also a 3-Gang Socket was mounted at the front of the casing and is
connected to the devices inside. The 12-volts power supply that supply the
fan to avoid heating the system was inside the case. The GSM Sim-8001,
41
Relay, Capacitors, Arduino, Power Supply, PZEM-004T was supplied by a 5-
42
Figure 17. Right view of the device
43
4.3 Project Evaluation
tested the project based on the different criteria concerned with Functionality,
the following criteria were found on Appendix for reference. The data shown
below are the mean scores for each criteria from 10 respondents. From the
Table 4. Functionality
Table 5. Reliability
44
2. Fault Tolerance 4.1 ACCEPTABLE
Table 6. Usability
Table 7. Efficiency
Table 8. Maintainability
45
CRITERIA MEAN REMARKS
46
Device Application
VOLTAGE CURRENT
REACTIVE POWER
POWER FACTOR
47
Data Gathered.
48
The inductive load that were tested.
49
The first trial
50
The second trial
51
The third trial
52
The fourth trial
53
The fifth trial
54
Messages that were received by the user.
55
Figure 35. Message received
56
Figure 37. Message received
57
Figure 39. Message received
58
CHAPTER 5
Conclusion
loads. Arduino UNO controller was very popular at this event, likewise it is
An Inductive linear load (1.5 HP motor) was tested for this system. The
Voltage, Current, Reactive power and Power factor were shown in the LCD
module. The data gathered clearly shows the benefit of using the system. The
power factor of motor was improved from 0.52 to 0.85 and the current that
the motor draws were reduced to about 61% of the current drawn at lower
power factor. The device was also able to notify the user about the power
notification via SMS about the voltage fluctuation of the line. However, there
are times that the message containing the value of unimproved power factor
was failed to send due to no reception of GSM. This observed weakness would
59
By using the device the system could raise the power factor of an
electrical system and at the same time notify the user when a voltage
fluctuation occurs. This study gave awareness to the user of the excess
current drawn of the poor power factor loads will enable them to do necessary
action in improving the power factor to minimize the current drawn by the
inductive loads.
Recommendation
the message to improve this device for there is a possibility that mass
before the system is built for the closer the value of reactive power consumed
by the load to the reactive power compensated by the system the better the
capacitor with small gap in capacitance (between the capacitance of the first
60
capacitor to the preceding capacitor) will be developed to have a numerous
selection of capacitance.
REFERENCES
Kabir, Y., Mohsin, M.M., & Khan, M.M. (2017, February) Automated Power
Factor correction and Energy Monitoring System. Retrieved November
14, 2018, from http://www.researchgate.net.
Sayed, R., Ferdous, A.I., & Shobug, M.A. (2015, April) 2 automatic power
Factor correction by using synchronous condenser with continuous
monitoring. Retrieved November 14, 2018, from
https://www.researchgate.net.
Syirrazie CS1, H.Hasim1 Ahmad Asraf AS2 (2015) Impact Study on Power
Factor of Electrical Load in Power Distribution System. Retrieved
November 14 2018, from http://inis.iaea.org.
Robokits India (2018) SIM800L GPRS GSM MODULE MICRO SIM CARD CORE
BOARD QUAD-BAND TTL. Retrieved November 15, 2018 from
http://robokits.co.in
61
Trossen Robotics (n.d.) Arduino Uno R3 Microcontroller. Retrieved November
15, 2018 from http://www.trossenrobotics.com
Wikipedia (2018) AC power plugs and sockets. Retrieved November 15, 2018
from htttp://en.wikipedia.org
62
APPENDIX A
EVALUATION CRITERIA
Direction:
Legend:
3 – Moderately Acceptable
5 4 3 2 1
I.FUNCTIONALITY
63
Function required for the system are
implemented(Suitability)
provided(Interoperability
II.RELIABILITY
failure occurs(Recoverability)
III.USABILITY
Easy to operate(Understandability)
IV.EFFICIENCY
64
Provides good responses and high
throughput(time behavior)
V.MAINTAINABILITY
system(Changeability)
others(stability)
modification is made(testability)
Summary: Average:
A.Functionality
B.Reliability
C.Usability
D.Efficiency
E.Maintainability
65
Total Score_________ ÷5 = ____________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________.
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________.
__________________________________________
(Signature)
Evaluator
Date: ______________________
66
APPENDIX B
Reps. A1 A2 A3 A4 B1 B2 B3 C1 C2 C3 D1 E1 E2 E3 E4
1 5 5 5 5 4 5 5 5 5 5 5 5 5 5 5
2 4 4 3 4 4 3 4 5 4 3 4 4 4 3 4
3 5 5 5 5 3 4 5 5 5 5 5 4 5 5 5
4 5 5 5 5 5 5 5 5 5 5 5 4 5 4 3
5 5 4 4 5 5 5 5 5 5 5 4 4 5 4 5
6 5 5 4 5 4 5 5 5 5 5 5 5 4 4 5
7 5 5 5 4 5 5 4 4 4 3 4 5 4 5 3
8 5 4 4 5 5 5 4 4 4 4 5 4 4 5 5
9 4 4 4 4 5 4 4 4 5 5 5 4 4 4 4
10 5 5 5 5 4 4 5 5 5 5 5 4 5 5 5
Total 48 46 44 47 44 45 46 47 47 45 47 43 45 44 44
Mean 4.8 4.6 4.4 4.7 4.4 4.5 4.6 4.7 4.7 4.5 4.7 4.3 4.5 4.4 4.4
APPENDIX C
67
ARDUINO PROGRAM
68
boolean cap40 = LOW;
void setup()
{
pzem.setAddress(ip); // Set ip Pzem
lcd.begin(); // Begin lcd
lcd.backlight(); // Backlight
Sim800l.begin(); //initialize GSM
pinMode(cap1,OUTPUT); //Pinmode Output //40
pinMode(cap2,OUTPUT); //Pinmode Output
pinMode(cap3,OUTPUT); //Pinmode Output
pinMode(cap4,OUTPUT); //Pinmode Output
number = "09058795441"; // SEt the number
digitalWrite(cap1,HIGH); // SET ALL CAP INITIALLY HIGH / OFF
digitalWrite(cap2,HIGH);
digitalWrite(cap3,HIGH);
digitalWrite(cap4,HIGH);
Welcome(); //Call Welcome message
}
void Welcome()
{
lcd.clear(); //clear lcd
lcd.print("Group 4 Thesis"); //print in lcd
lcd.setCursor(0,1); // set cursor in lcd
lcd.print("BSEE- 5A"); //print lcd
delay(2000); // delay
lcd.clear(); // clear
lcd.print("C. Zabala");
lcd.setCursor(0,1);
lcd.print("R. Necesito");
delay(2000);
lcd.clear();
lcd.print("F. Patino");
lcd.setCursor(0,1);
lcd.print("B. Pancubila");
delay(2000);
lcd.clear();
lcd.print("Please Wait..");
69
delay(4000);
}
void Display()
{
ReadParameters();
lcd.clear(); // clears LCD
lcd.print(Voltage); //print voltage
lcd.setCursor(6,0); // setCursor in lcd
lcd.print("V");
lcd.setCursor(8,0);
lcd.print(Current); // print current
lcd.setCursor(14,0);
lcd.print("A");
lcd.setCursor(0,1);
lcd.print(ReactivePower); //print reactive power
lcd.setCursor(4,1);
lcd.print("VAR");
lcd.setCursor(8,1);
lcd.print("PF=");
lcd.setCursor(12,1);
if(PowerFactor>1) PowerFactor = 1;
lcd.print(PowerFactor); //print powerfactor
delay(100);
}
void response(boolean res)
{
if(res == 1) // if sms is succesfully sent
{
lcd.clear();
lcd.print("Msg Sent"); //print msg sent if sms succesfully sent
delay(1000); //delay for 1 second
}
else if(res == 0) // if sms is notsent
{
lcd.clear();
lcd.print("Msg Not Sent"); //print msg not sent if sms not sent
delay(1000);
}
else
{
lcd.clear();
lcd.print("GSM DAMAGED");
delay(1000);
}
}
70
void SendCurrentPowerFactor()
{
isPf = LOW; //this serve as to limit the number of sms to be sent
if(isPf == LOW && pastPf == HIGH) // same as voltage
{
Sim800l.begin(); //initialize GSM
msg = "Power Factor: "; //msg to be sent
Combination = msg + (String)(PowerFactor); // process in combining two
string
Combination.toCharArray(buffer2,50); //buffer to store string temp and
to convert it to char
text = buffer2;
error = Sim800l.sendSms(number,text); //Send Sms command
response(error); // get sms responce
delay(2000);
Sim800l.end(); //end gsm
}
pastPf = isPf; // set past pf to current value of ispf to limit the number of
message sent to one
}
void SendImprovedPowerFactor()
{
isPf = LOW; // same goes here
ReadParameters();
if(isPf == LOW && pastPf2 == HIGH) // same as voltage
{
Sim800l.begin();
msg = "PowerFactor: ";
Combination = msg + (String)(PowerFactor);
Combination.toCharArray(buffer2,50);
text = buffer2;
error = Sim800l.sendSms(number,text);
response(error);
delay(2000);
Sim800l.end();
}
pastPf2 = isPf; // same goes here
}
void SendOverVoltage() // Function to send OverVoltage
{
isV = LOW;
if(isV == LOW && pastV == HIGH)
{
Sim800l.begin();
msg = "Over Voltage: ";
Combination = msg + (String)Voltage;
71
Combination.toCharArray(buffer1,50);
text = buffer1;
error = Sim800l.sendSms(number,text);
response(error);
delay(2000);
Sim800l.end();
}
pastV = isV;
}
}
void ReactRead()
{
Cap12 = (pow(Voltage,2)*0.004523893);
Cap20 = (pow(Voltage,2)*0.007539822);
Cap40 = (pow(Voltage,2)*0.0150796);
CapAll = Cap12+Cap20+Cap40+Cap40;
CapThree = Cap12+Cap20+Cap40;
CapTwo = Cap12+Cap20;
CapOne = Cap12;
}
void loop() //main loop
{
//first read parameters
Voltage = pzem.voltage(ip); // read Voltage
if(Voltage<0) Voltage =0;
Current = pzem.current(ip); // read Current
if(Current<0) Current = 0;
RealPower = pzem.power(ip); // read active power
PowerFactor = (RealPower/(Voltage*Current));// Equation for calculating
power factor
ReactivePower = sqrt((pow((Voltage*Current),2))-(pow(RealPower,2))); //
equation for reactive
Display(); // call display function
// test if voltage fluctuate
if(Voltage <= 207 && Voltage > 0) // if voltage is low
{
SendLowVoltage();
pastV2 = HIGH;
73
delay(1000);
}
else if(Voltage >= 253)
{
SendOverVoltage();
pastV2 = HIGH;
delay(1000);
}
else if((Voltage<253 && Voltage >207))
{
SendNormalVoltage();
pastV =HIGH; //resetting condition for nxt voltage fluctuation
delay(1000);
}
delay(100);
ReadParameters(); //read parameters again
Display();
delay(1000);
// check for power factor
if((PowerFactor<0.80 && PowerFactor > 0 && ReactivePower> 10)|| Reset
== HIGH) // Check power factor
{
delay(3000);
if(CapState == LOW && PowerFactor < 0.85 && PowerFactor > 0 &&
ReactivePower > 240)
{
SendCurrentPowerFactor(); // send the value of power factor
pastPf = HIGH;
delay(100);
}
ReadParameters();
Display();
delay(2000);
ReactRead();
delay(1000);
if( ReactivePower >= CapAll ) // if all caps needed
{ //2100 VAR compensation
delay(2000);
digitalWrite(cap1,LOW);
digitalWrite(cap2,LOW);
digitalWrite(cap3,LOW);
digitalWrite(cap4,LOW);
Reset = LOW;
CapState = HIGH; //for status purposes
threeCap =LOW;
twoCap =LOW;
74
AllCap = HIGH;
oneCap =LOW;
cap20 = LOW;
cap40 = LOW;
delay(3000);
}
if( ReactivePower < CapAll && ReactivePower >= CapThree )
{
delay(2000);
digitalWrite(cap1,LOW);
digitalWrite(cap2,LOW);
digitalWrite(cap3,LOW);
digitalWrite(cap4,HIGH);
Reset = LOW;
CapState = HIGH;//for status purposes
threeCap =HIGH;
AllCap = LOW;
twoCap =LOW;
oneCap =LOW;
cap20 = LOW;
cap40 = LOW;
delay(3000);
}
if(ReactivePower < Cap40 && ReactivePower >= CapTwo)
{
delay(2000);
digitalWrite(cap1,LOW);
digitalWrite(cap2,LOW);
digitalWrite(cap3,HIGH);
digitalWrite(cap4,HIGH);
Reset = LOW;
CapState = HIGH; //for status purposes
threeCap =LOW;
twoCap =HIGH;
AllCap = LOW;
oneCap =LOW;
cap20 = LOW;
cap40 = LOW;
delay(3000);
}
if(ReactivePower <Cap20 && ReactivePower >= Cap12 && threeCap ==
LOW && cap40 == LOW && cap20 == LOW && AllCap == LOW)
{
delay(2000);
digitalWrite(cap1,LOW);
75
digitalWrite(cap2,HIGH);
digitalWrite(cap3,HIGH);
digitalWrite(cap4,HIGH);
Reset = LOW;
CapState = HIGH;//for status purposes
twoCap =LOW;
AllCap = LOW;
threeCap =LOW;
oneCap =HIGH;
cap20 = LOW;
cap40 = LOW;
delay(3000);
}
// this
if(ReactivePower <CapTwo && ReactivePower >= Cap20)
{
delay(2000);
digitalWrite(cap1,HIGH);
digitalWrite(cap2,LOW);
digitalWrite(cap3,HIGH);
digitalWrite(cap4,HIGH);
Reset = LOW;
CapState = HIGH;//for status purposes
twoCap =LOW;
AllCap = LOW;
threeCap =LOW;
oneCap =LOW;
cap20 = HIGH;
cap40 = LOW;
delay(3000);
}
if(ReactivePower <CapThree && ReactivePower >= Cap40)
{
delay(2000);
digitalWrite(cap1,HIGH);
digitalWrite(cap2,HIGH);
digitalWrite(cap3,LOW);
digitalWrite(cap4,HIGH);
Reset = LOW;
CapState = HIGH;//for status purposes
twoCap =LOW;
AllCap = LOW;
threeCap =LOW;
oneCap =LOW;
cap20 = LOW;
cap40 = HIGH;
76
delay(3000);
}
//this
if(ReactivePower < Cap12)
{
digitalWrite(cap1,HIGH);
digitalWrite(cap2,HIGH);
digitalWrite(cap3,HIGH);
digitalWrite(cap4,HIGH);
CapState = LOW; //for status purposes
AllCap = LOW;
pastPf2 = HIGH;
twoCap =LOW;
threeCap =LOW;
oneCap =LOW;
Reset = HIGH;
cap20 = LOW;
cap40 = LOW;
delay(1000);
}
if(ReactivePower > Cap12 && ReactivePower < Cap20 && oneCap == HIGH)
{
digitalWrite(cap1,HIGH);
digitalWrite(cap2,HIGH);
digitalWrite(cap3,HIGH);
digitalWrite(cap4,HIGH);
CapState = LOW; //for status purposes
AllCap = LOW;
pastPf2 = HIGH;
twoCap =LOW;
threeCap =LOW;
oneCap =LOW;
Reset = HIGH;
cap20 = LOW;
cap40 = LOW;
delay(1000);
}
if(oneCap == HIGH && PowerFactor<= 0.79)
{
digitalWrite(cap1,HIGH);
digitalWrite(cap2,HIGH);
digitalWrite(cap3,HIGH);
digitalWrite(cap4,HIGH);
CapState = LOW; //for status purposes
AllCap = LOW;
77
pastPf2 = HIGH;
twoCap =LOW;
threeCap =LOW;
oneCap =LOW;
Reset = HIGH;
cap20 = LOW;
cap40 = LOW;
delay(2000);
}
}
ReadParameters();
Display();
if((PowerFactor>=0.83 && PowerFactor < 1 && PowerFactor !=0 )&&
CapState == HIGH)
{
SendImprovedPowerFactor();
Reset = LOW;
delay(1000);
}
if(PowerFactor>1 && CapState == HIGH)
{
pastPf = HIGH;
}
else if(PowerFactor>=0.85 && CapState == HIGH)
{
Reset = LOW;
}
if(CapState == HIGH && ReactivePower == 0 && PowerFactor == 0)
{
Reset = HIGH;
ReadParameters();
Display();
}
if(AllCap == HIGH && RealPower<CapAll)
{
digitalWrite(cap1,HIGH);
digitalWrite(cap2,HIGH);
digitalWrite(cap3,HIGH);
digitalWrite(cap4,HIGH);
CapState = LOW;
delay(1000);
}
if( Current == 0 && Voltage == 0 )
{
digitalWrite(cap1,HIGH);
78
digitalWrite(cap2,HIGH);
digitalWrite(cap3,HIGH);
digitalWrite(cap4,HIGH);
CapState = LOW;
pastPf2 = HIGH;
delay(1000);
}
if(CapState == HIGH && PowerFactor < 0.4 && PowerFactor > 0)
{
digitalWrite(cap1,HIGH);
digitalWrite(cap2,HIGH);
digitalWrite(cap3,HIGH);
digitalWrite(cap4,HIGH);
CapState = LOW;
delay(1000);
pastPf2 = HIGH;
Reset = HIGH;
}
if( CapState == HIGH && PowerFactor <= 0 && Current == 0)
{
digitalWrite(cap1,HIGH);
digitalWrite(cap2,HIGH);
digitalWrite(cap3,HIGH);
digitalWrite(cap4,HIGH);
CapState = LOW;
delay(1000);
}
else if(CapState == HIGH && RealPower <Cap12)
{
digitalWrite(cap1,HIGH);
digitalWrite(cap2,HIGH);
digitalWrite(cap3,HIGH);
digitalWrite(cap4,HIGH);
CapState = LOW;
delay(1000);
pastPf2 = HIGH;
}
if(Current == 0 && CapState == HIGH)
{
digitalWrite(cap1,HIGH);
digitalWrite(cap2,HIGH);
digitalWrite(cap3,HIGH);
digitalWrite(cap4,HIGH);
CapState = LOW;
delay(1000);
}
79
if(Current == 0 && CapState == LOW)
{
digitalWrite(cap1,HIGH);
digitalWrite(cap2,HIGH);
digitalWrite(cap3,HIGH);
digitalWrite(cap4,HIGH);
CapState = LOW;
pastPf2 = HIGH;
delay(1000);
}
if( threeCap == HIGH && RealPower < CapThree)
{
digitalWrite(cap1,HIGH);
digitalWrite(cap2,HIGH);
digitalWrite(cap3,HIGH);
digitalWrite(cap4,HIGH);
CapState = LOW;
pastPf2 = HIGH;
delay(1000);
}
if(AllCap == HIGH && PowerFactor<0.85) // just a condition for sending
the value of power factor
{
delay(2000);
ReadParameters();
SendImprovedPowerFactor();
}
if(threeCap == HIGH && CapState == HIGH)
{
delay(2000);
ReadParameters();
SendImprovedPowerFactor();
}
if(twoCap == HIGH && CapState == HIGH )
{
delay(2000);
ReadParameters();
SendImprovedPowerFactor();
}
if(oneCap == HIGH && CapState == HIGH )
{
delay(2000);
ReadParameters();
SendImprovedPowerFactor();
}
if(cap20 == HIGH && CapState == HIGH )
80
{
delay(2000);
ReadParameters();
SendImprovedPowerFactor();
}
if(cap40 == HIGH && CapState == HIGH )
{
delay(2000);
ReadParameters();
SendImprovedPowerFactor();
}
if(PowerFactor > 0 && PowerFactor < 0.83 && CapState == LOW)
{
pastPf = HIGH; // reset sms limit for nxt occurance
}
delay(100);
ReadParameters();
Display();
}
APPENDIX D
81
CONSTRUCTION OF THE SYSTEM
APPENDIX E
82
HOW TO OPERATE THE SYSTEM
APPENDIX F
83
DATA SHEET
PZEM – 004T
GSM SIM800L
ARDUINO UNO
RELAY
84