pzem - чтение напряжения

This commit is contained in:
Dmitry Borisenko
2022-09-27 00:52:53 +02:00
parent c091f1b4cc
commit e688c95c59
10 changed files with 150 additions and 53 deletions

View File

@@ -3,7 +3,7 @@
#include "classes/IoTItem.h"
#include "PZEMSensor.h"
//#include "SoftUART.h"
#include "modules/sensors/SoftUart/SoftUart.h"
PZEMSensor* pzem;
@@ -14,11 +14,21 @@ class Pzem004v : public IoTItem {
public:
Pzem004v(String parameters) : IoTItem(parameters) {
addr = jsonReadStr(parameters, "addr");
// pzem = new PZEMSensor(myUART, hexStringToUint8(addr));
pzem = new PZEMSensor(myUART, hexStringToUint8(addr));
}
void doByInterval() {
value.valD = pzem->values()->voltage;
regEvent(value.valD, "Pzem Voltage");
}
~Pzem004v(){};
};
void* getAPI_Pzem004(String subtype, String param) {
if (subtype == F("Pzem004v")) {
return new Pzem004v(param);
} else {
return nullptr;
}
}