0% found this document useful (0 votes)
5 views2 pages

PZEM004T Power Factor Calculation Code

This document contains Arduino code that utilizes the PZEM004Tv30 and LiquidCrystal libraries to display power factor (PF) readings on an LCD. The program welcomes the user, calculates the PF, and checks if it is below 0.95, adding capacitors sequentially if needed to improve the PF. The LCD displays messages during the calculation and capacitor addition process, updating the PF value accordingly.

Uploaded by

Abhi J
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

PZEM004T Power Factor Calculation Code

This document contains Arduino code that utilizes the PZEM004Tv30 and LiquidCrystal libraries to display power factor (PF) readings on an LCD. The program welcomes the user, calculates the PF, and checks if it is below 0.95, adding capacitors sequentially if needed to improve the PF. The LCD displays messages during the calculation and capacitor addition process, updating the PF value accordingly.

Uploaded by

Abhi J
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

#include <PZEM004Tv30.

h>
#include <LiquidCrystal.h>
const int rs = 7, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

PZEM004Tv30 pzem(11, 12);

void setup() {
[Link](16, 2);

float pf = [Link]();
[Link](4, 0);
[Link]("WELCOME!");
delay(5000);

[Link]();
[Link]("calculating...");
delay(3000);

[Link]();
[Link]("without cap");
[Link](0, 1);
[Link]("PF: "); [Link](pf);
delay(5000);

if (pf < 0.95)


{
digitalWrite(8, HIGH);
pf = [Link]();

[Link]();
[Link]("calculating...");
delay(3000);

[Link]();
[Link]("adding 1 cap");
[Link](0, 1);
[Link]("PF: "); [Link](pf);
delay(3000);
}
if (pf < 0.95)
{
digitalWrite(9, HIGH);
pf = [Link]();

[Link]();
[Link]("calculating...");
delay(3000);

[Link]();
[Link]("adding 2 cap");
[Link](0, 1);
[Link]("PF: "); [Link](pf);
delay(3000);
}
if (pf < 0.95)
{
digitalWrite(10, HIGH);
pf = [Link]();

[Link]();
[Link]("calculating...");
delay(3000);

[Link]();
[Link]("adding 3 cap");
[Link](0, 1);
[Link]("PF: "); [Link](pf);
delay(3000);
}

You might also like