-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPzem004t.h
46 lines (38 loc) · 1.1 KB
/
Pzem004t.h
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
//
// Created by daphreak on 07.03.21.
//
#pragma once
#include <PZEM004Tv30.h>
#include <Arduino.h>
namespace hw
{
struct pzem004tvalues
{
float voltage; // Volt 1 2 4
float current; // Ampere 1 3
float power; // Watt 2 3
float energy; // kw/h 3
float frequency; // Hz 1 2 4
float pf; // 4
bool error; // false = ok; true = error
};
class Pzem004t
{
public:
explicit Pzem004t(HardwareSerial* serial1, HardwareSerial* serial2, HardwareSerial* serial3);
virtual ~Pzem004t() = default;
void update();
void resetEnergy();
const pzem004tvalues& values1();
const pzem004tvalues& values2();
const pzem004tvalues& values3();
private:
void updateValues(PZEM004Tv30& pzem, pzem004tvalues& values);
PZEM004Tv30 _pzem1;
PZEM004Tv30 _pzem2;
PZEM004Tv30 _pzem3;
pzem004tvalues _values1;
pzem004tvalues _values2;
pzem004tvalues _values3;
};
}