-
Notifications
You must be signed in to change notification settings - Fork 0
/
pzem.ino
51 lines (38 loc) · 974 Bytes
/
pzem.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <HardwareSerial.h>
#include <PZEM004Tv30.h>
HardwareSerial S(2);
PZEM004Tv30 pzem(&S);
void setup() {
Serial.begin(115200);
Serial.print("Reset Energy");
pzem.resetEnergy();
//Serial.print("Set address to 0x42");
//pzem.setAddress(0x42);
}
void loop() {
float volt = pzem.voltage();
Serial.print("Voltage: ");
Serial.print(volt);
Serial.println("V");
float cur = pzem.current();
Serial.print("Current: ");
Serial.print(cur);
Serial.println("A");
float powe = pzem.power();
Serial.print("Power: ");
Serial.print(powe);
Serial.println("W");
float ener = pzem.energy();
Serial.print("Energy: ");
Serial.print(ener,3);
Serial.println("kWh");
float freq = pzem.frequency();
Serial.print("Frequency: ");
Serial.print(freq);
Serial.println("Hz");
float pf = pzem.pf();
Serial.print("PF: ");
Serial.println(pf);
Serial.println("\n");
delay(1000);
}