mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-27 06:32:19 +03:00
pzem - чтение напряжения
This commit is contained in:
@@ -13,9 +13,11 @@ void* getAPI_Ds18b20(String subtype, String params);
|
||||
void* getAPI_GY21(String subtype, String params);
|
||||
void* getAPI_Hdc1080(String subtype, String params);
|
||||
void* getAPI_Max6675(String subtype, String params);
|
||||
void* getAPI_Pzem004(String subtype, String params);
|
||||
void* getAPI_RCswitch(String subtype, String params);
|
||||
void* getAPI_Sht20(String subtype, String params);
|
||||
void* getAPI_Sht30(String subtype, String params);
|
||||
void* getAPI_SoftUART(String subtype, String params);
|
||||
void* getAPI_Sonar(String subtype, String params);
|
||||
void* getAPI_ButtonIn(String subtype, String params);
|
||||
void* getAPI_ButtonOut(String subtype, String params);
|
||||
@@ -41,9 +43,11 @@ if ((tmpAPI = getAPI_Ds18b20(subtype, params)) != nullptr) return tmpAPI;
|
||||
if ((tmpAPI = getAPI_GY21(subtype, params)) != nullptr) return tmpAPI;
|
||||
if ((tmpAPI = getAPI_Hdc1080(subtype, params)) != nullptr) return tmpAPI;
|
||||
if ((tmpAPI = getAPI_Max6675(subtype, params)) != nullptr) return tmpAPI;
|
||||
if ((tmpAPI = getAPI_Pzem004(subtype, params)) != nullptr) return tmpAPI;
|
||||
if ((tmpAPI = getAPI_RCswitch(subtype, params)) != nullptr) return tmpAPI;
|
||||
if ((tmpAPI = getAPI_Sht20(subtype, params)) != nullptr) return tmpAPI;
|
||||
if ((tmpAPI = getAPI_Sht30(subtype, params)) != nullptr) return tmpAPI;
|
||||
if ((tmpAPI = getAPI_SoftUART(subtype, params)) != nullptr) return tmpAPI;
|
||||
if ((tmpAPI = getAPI_Sonar(subtype, params)) != nullptr) return tmpAPI;
|
||||
if ((tmpAPI = getAPI_ButtonIn(subtype, params)) != nullptr) return tmpAPI;
|
||||
if ((tmpAPI = getAPI_ButtonOut(subtype, params)) != nullptr) return tmpAPI;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
"page": "Сенсоры",
|
||||
"descr": "Напряжение",
|
||||
"int": 15,
|
||||
"addr": "0x77",
|
||||
"round": 1
|
||||
"addr": "0xF8"
|
||||
},
|
||||
{
|
||||
"name": "PZEM 004t Сила тока",
|
||||
@@ -22,8 +21,7 @@
|
||||
"page": "Сенсоры",
|
||||
"descr": "Сила тока",
|
||||
"int": 15,
|
||||
"addr": "0x77",
|
||||
"round": 1
|
||||
"addr": "0xF8"
|
||||
},
|
||||
{
|
||||
"name": "PZEM 004t Мощность",
|
||||
@@ -34,8 +32,7 @@
|
||||
"page": "Сенсоры",
|
||||
"descr": "Мощность",
|
||||
"int": 15,
|
||||
"addr": "0x77",
|
||||
"round": 1
|
||||
"addr": "0xF8"
|
||||
},
|
||||
{
|
||||
"name": "PZEM 004t Энергия",
|
||||
@@ -46,8 +43,7 @@
|
||||
"page": "Сенсоры",
|
||||
"descr": "Энергия",
|
||||
"int": 15,
|
||||
"addr": "0x77",
|
||||
"round": 1
|
||||
"addr": "0xF8"
|
||||
},
|
||||
{
|
||||
"name": "PZEM 004t Частота",
|
||||
@@ -58,8 +54,7 @@
|
||||
"page": "Сенсоры",
|
||||
"descr": "Энергия",
|
||||
"int": 15,
|
||||
"addr": "0x77",
|
||||
"round": 1
|
||||
"addr": "0x77"
|
||||
}
|
||||
],
|
||||
"about": {
|
||||
@@ -67,7 +62,7 @@
|
||||
"authorContact": "https://t.me/Dmitry_Borisenko",
|
||||
"authorGit": "https://github.com/DmitryBorisenko33",
|
||||
"specialThanks": "Serghei Crasnicov @Serghei63",
|
||||
"moduleName": "Bme280",
|
||||
"moduleName": "Pzem004",
|
||||
"moduleVersion": "1.0",
|
||||
"usedRam": 15,
|
||||
"subTypes": [
|
||||
@@ -84,7 +79,7 @@
|
||||
"int": "Количество секунд между опросами датчика"
|
||||
}
|
||||
},
|
||||
"defActive": false,
|
||||
"defActive": true,
|
||||
"devices": {
|
||||
"esp32_4mb": [],
|
||||
"esp8266_4mb": []
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
#include "Global.h"
|
||||
#include "classes/IoTItem.h"
|
||||
#include <Arduino.h>
|
||||
//#include "SoftUART.h"
|
||||
|
||||
#include "modules/sensors/SoftUart/SoftUart.h"
|
||||
|
||||
#ifdef ESP8266
|
||||
SoftwareSerial* myUART = nullptr;
|
||||
@@ -14,6 +15,7 @@ class SoftUART : public IoTItem {
|
||||
private:
|
||||
int tx;
|
||||
int rx;
|
||||
int speed;
|
||||
|
||||
public:
|
||||
SoftUART(String parameters) : IoTItem(parameters) {
|
||||
@@ -36,9 +38,6 @@ class SoftUART : public IoTItem {
|
||||
|
||||
void uartHandle() {
|
||||
if (myUART) {
|
||||
if (!jsonReadBool(configSetupJson, "uart")) {
|
||||
return;
|
||||
}
|
||||
static String incStr;
|
||||
if (myUART->available()) {
|
||||
char inc;
|
||||
|
||||
9
src/modules/sensors/SoftUart/SoftUart.h
Normal file
9
src/modules/sensors/SoftUart/SoftUart.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef ESP8266
|
||||
#include <SoftwareSerial.h>
|
||||
extern SoftwareSerial* myUART;
|
||||
#else
|
||||
#include <HardwareSerial.h>
|
||||
extern HardwareSerial* myUART;
|
||||
#endif
|
||||
@@ -5,6 +5,9 @@
|
||||
"name": "UART",
|
||||
"type": "Reading",
|
||||
"subtype": "SoftUART",
|
||||
"page": "",
|
||||
"descr": "",
|
||||
"widget": "nil",
|
||||
"id": "u",
|
||||
"tx": 15,
|
||||
"rx": 16,
|
||||
@@ -16,21 +19,21 @@
|
||||
"authorContact": "https://t.me/Dmitry_Borisenko",
|
||||
"authorGit": "https://github.com/DmitryBorisenko33",
|
||||
"specialThanks": "Serghei Crasnicov @Serghei63",
|
||||
"moduleName": "Bme280",
|
||||
"moduleName": "SoftUART",
|
||||
"moduleVersion": "1.0",
|
||||
"usedRam": 15,
|
||||
"subTypes": [
|
||||
"SoftUART"
|
||||
],
|
||||
"title": "Софтовый uart для esp8266 или harware uart для esp32",
|
||||
"moduleDesc": "Используется вместе с Pzem004t",
|
||||
"moduleDesc": "Используется вместе с Pzem004t, в последствии будет доработан для связи с arduino платами",
|
||||
"propInfo": {
|
||||
"tx": "TX пин",
|
||||
"rx": "RX пин",
|
||||
"speed": "Скорость UART"
|
||||
}
|
||||
},
|
||||
"defActive": false,
|
||||
"defActive": true,
|
||||
"devices": {
|
||||
"esp32_4mb": [
|
||||
"plerup/espsoftwareserial"
|
||||
|
||||
Reference in New Issue
Block a user