Files
IoTManager/include/items/SensorPower.h
Yuri Trikoz b8a9f9b6b3 pemz
2020-12-13 02:23:04 +03:00

32 lines
801 B
C++

#pragma once
#include "Global.h"
#include "PZEMSensor.h"
class SensorPZEM {
public:
SensorPZEM(SoftwareSerial* serial, uint32_t addr, uint32_t interval, String key) : _lastUpdate{0},
_interval{interval},
_key{key} {
_pzem = new PZEMSensor(serial, addr);
}
~SensorPZEM() {
delete _pzem;
}
void loop(void);
private:
void readSensor(void);
String getDataKey(const char* param_key);
void post(const char* key, const String& value);
private:
PZEMSensor* _pzem;
uint32_t _lastUpdate;
uint32_t _interval;
String _key;
};
extern SensorPZEM* myPowerSensor;