mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-29 15:42:20 +03:00
Убираем нумерацию папок модулей
This commit is contained in:
72
src/modules/sensors/Emon/Emon.cpp
Normal file
72
src/modules/sensors/Emon/Emon.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
/******************************************************************
|
||||
Used Energy Monitoring Library
|
||||
|
||||
https://github.com/openenergymonitor/EmonLib
|
||||
|
||||
adapted for version 4 @Serghei63
|
||||
******************************************************************/
|
||||
|
||||
#include "Global.h"
|
||||
#include "classes/IoTItem.h"
|
||||
#include <map>
|
||||
|
||||
extern IoTGpio IoTgpio;
|
||||
|
||||
#include "EmonLib.h" // Include Emon Library
|
||||
|
||||
EnergyMonitor emon1; // Create an instance
|
||||
|
||||
|
||||
class Energy : public IoTItem {
|
||||
|
||||
private:
|
||||
unsigned int _pinI; // ток
|
||||
unsigned int _calibI; // ток
|
||||
|
||||
public:
|
||||
Energy(String parameters): IoTItem(parameters) {
|
||||
_pinI = jsonReadInt(parameters, "pin_I");
|
||||
_calibI = jsonReadInt(parameters, "calib_I");
|
||||
emon1.current(_pinI, _calibI); // Current: input pin, calibration.
|
||||
}
|
||||
|
||||
void doByInterval() {
|
||||
value.valD = emon1.calcIrms(1480); // Calculate Irms only
|
||||
regEvent(value.valD, "current");
|
||||
}
|
||||
|
||||
~Energy(){};
|
||||
};
|
||||
|
||||
|
||||
class Power : public IoTItem {
|
||||
|
||||
private:
|
||||
unsigned int _pinU; // напряжение
|
||||
unsigned int _calibU; // напряжение
|
||||
|
||||
public:
|
||||
Power(String parameters): IoTItem(parameters) {
|
||||
_pinU = jsonReadInt(parameters, "pin_U");
|
||||
_calibU = jsonReadInt(parameters, "calib_U");
|
||||
emon1.voltage(_pinU, _calibU, 1.7); // Voltage: input pin, calibration, phase_shift
|
||||
}
|
||||
|
||||
void doByInterval() {
|
||||
if (emon1.Irms > 0) emon1.calcVI(10, 1000); // Calculate all. No.of half wavelengths (crossings), time-out при условии, что ток не нулевой
|
||||
value.valD = emon1.Vrms; //extract Vrms into Variable;
|
||||
regEvent(value.valD, "voltage");
|
||||
}
|
||||
|
||||
~Power(){};
|
||||
};
|
||||
|
||||
void* getAPI_Emon(String subtype, String param) {
|
||||
if (subtype == F("I")) {
|
||||
return new Energy(param);
|
||||
} else if (subtype == F("U")) {
|
||||
return new Power(param);
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
60
src/modules/sensors/Emon/modinfo.json
Normal file
60
src/modules/sensors/Emon/modinfo.json
Normal file
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"menuSection": "Сенсоры",
|
||||
|
||||
"configItem": [{
|
||||
"name": "Датчик тока",
|
||||
"type": "Reading",
|
||||
"subtype": "I",
|
||||
"id": "current",
|
||||
"widget": "anydataAmp",
|
||||
"page": "Сенсоры",
|
||||
"descr": "Датчик тока",
|
||||
"int": 10,
|
||||
"pin_I": 34,
|
||||
"calib_I": 111.1,
|
||||
"plus": 0,
|
||||
"multiply": 1
|
||||
},
|
||||
{
|
||||
"name": "Датчик напряжения",
|
||||
"type": "Reading",
|
||||
"subtype": "U",
|
||||
"id": "voltage",
|
||||
"widget": "anydataVlt",
|
||||
"page": "Сенсоры",
|
||||
"descr": "Датчик напряжения",
|
||||
"int": 10,
|
||||
"pin_U": 35,
|
||||
"calib_U": 223.1,
|
||||
"plus": 0,
|
||||
"multiply": 1
|
||||
}],
|
||||
|
||||
"about": {
|
||||
"authorName": "Serghei Crasnicov",
|
||||
"authorContact": "https://t.me/Serghei63",
|
||||
"authorGit": "https://github.com/Serghei63",
|
||||
"specialThanks": "",
|
||||
"moduleName": "Emon",
|
||||
"moduleVersion": "1.0",
|
||||
"moduleDesc": ".",
|
||||
"propInfo": {
|
||||
"pin_U": "",
|
||||
"calib_U": "",
|
||||
"pin_I": "",
|
||||
"calib_I": "",
|
||||
"int": "Количество секунд между опросами датчика."
|
||||
}
|
||||
},
|
||||
|
||||
"defActive": false,
|
||||
|
||||
"devices": {
|
||||
"esp32_4mb": [
|
||||
"openenergymonitor/EmonLib@1.1.0"
|
||||
],
|
||||
"esp8266_4mb": [
|
||||
"openenergymonitor/EmonLib@1.1.0"
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user