This commit is contained in:
Dmitry Borisenko
2022-09-27 00:57:28 +02:00
parent e688c95c59
commit d426746733
2 changed files with 8 additions and 4 deletions

View File

@@ -14,12 +14,16 @@ class Pzem004v : public IoTItem {
public: public:
Pzem004v(String parameters) : IoTItem(parameters) { Pzem004v(String parameters) : IoTItem(parameters) {
addr = jsonReadStr(parameters, "addr"); addr = jsonReadStr(parameters, "addr");
pzem = new PZEMSensor(myUART, hexStringToUint8(addr)); if (myUART) {
pzem = new PZEMSensor(myUART, hexStringToUint8(addr));
}
} }
void doByInterval() { void doByInterval() {
value.valD = pzem->values()->voltage; if (pzem) {
regEvent(value.valD, "Pzem Voltage"); value.valD = pzem->values()->voltage;
regEvent(value.valD, "Pzem Voltage");
}
} }
~Pzem004v(){}; ~Pzem004v(){};

View File

@@ -27,7 +27,7 @@
"name": "PZEM 004t Мощность", "name": "PZEM 004t Мощность",
"type": "Reading", "type": "Reading",
"subtype": "Pzem004w", "subtype": "Pzem004w",
"id": "A", "id": "W",
"widget": "anydataWt", "widget": "anydataWt",
"page": "Сенсоры", "page": "Сенсоры",
"descr": "Мощность", "descr": "Мощность",