mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 03:49:13 +03:00
проверка на отсутствие
This commit is contained in:
@@ -367,7 +367,7 @@
|
|||||||
"page": "Сенсоры",
|
"page": "Сенсоры",
|
||||||
"descr": "Частота",
|
"descr": "Частота",
|
||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0x77",
|
"addr": "0xF8",
|
||||||
"num": 28
|
"num": 28
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -209,13 +209,6 @@
|
|||||||
],
|
],
|
||||||
"status": 0
|
"status": 0
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "anydataVlt",
|
|
||||||
"label": "Вольты",
|
|
||||||
"widget": "anydata",
|
|
||||||
"after": "Vlt",
|
|
||||||
"icon": "speedometer"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "nil",
|
"name": "nil",
|
||||||
"label": "Без виджета"
|
"label": "Без виджета"
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#include <SoftwareSerial.h>
|
#include <SoftwareSerial.h>
|
||||||
|
|
||||||
#define PZEM_DEFAULT_ADDR 0xF8
|
#define PZEM_DEFAULT_ADDR 0xF8
|
||||||
@@ -22,13 +21,13 @@ class PZEMSensor {
|
|||||||
PZEMSensor(Stream *serial, uint16_t addr = PZEM_DEFAULT_ADDR);
|
PZEMSensor(Stream *serial, uint16_t addr = PZEM_DEFAULT_ADDR);
|
||||||
|
|
||||||
~PZEMSensor();
|
~PZEMSensor();
|
||||||
PZEM_Info* values();
|
PZEM_Info *values(bool &online);
|
||||||
bool setAddress(uint8_t addr);
|
bool setAddress(uint8_t addr);
|
||||||
uint8_t getAddress();
|
uint8_t getAddress();
|
||||||
bool setPowerAlarm(uint16_t watts);
|
bool setPowerAlarm(uint16_t watts);
|
||||||
bool getPowerAlarm();
|
bool getPowerAlarm();
|
||||||
bool reset();
|
bool reset();
|
||||||
void search();
|
bool search();
|
||||||
// Get most up to date values from device registers and cache them
|
// Get most up to date values from device registers and cache them
|
||||||
bool refresh();
|
bool refresh();
|
||||||
|
|
||||||
|
|||||||
@@ -43,11 +43,13 @@ PZEMSensor::PZEMSensor(Stream *port, uint16_t addr) {
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
PZEM_Info *PZEMSensor::values() {
|
PZEM_Info *PZEMSensor::values(bool &online) {
|
||||||
// Update vales if necessary
|
// Update vales if necessary
|
||||||
if (!refresh()) {
|
if (!refresh()) {
|
||||||
_values = PZEM_Info();
|
_values = PZEM_Info();
|
||||||
|
online = false;
|
||||||
}
|
}
|
||||||
|
online = true;
|
||||||
return &_values;
|
return &_values;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +64,7 @@ PZEM_Info *PZEMSensor::values() {
|
|||||||
* @param[in] check - perform a simple read check after write
|
* @param[in] check - perform a simple read check after write
|
||||||
*
|
*
|
||||||
* @return success
|
* @return success
|
||||||
*/
|
*/
|
||||||
bool PZEMSensor::sendCmd8(uint8_t cmd, uint16_t rAddr, uint16_t val, bool check, uint16_t slave_addr) {
|
bool PZEMSensor::sendCmd8(uint8_t cmd, uint16_t rAddr, uint16_t val, bool check, uint16_t slave_addr) {
|
||||||
uint8_t sendBuffer[8]; // Send buffer
|
uint8_t sendBuffer[8]; // Send buffer
|
||||||
uint8_t respBuffer[8]; // Response buffer (only used when check is true)
|
uint8_t respBuffer[8]; // Response buffer (only used when check is true)
|
||||||
@@ -295,7 +297,8 @@ uint16_t PZEMSensor::CRC16(const uint8_t *data, uint16_t len) {
|
|||||||
return crc;
|
return crc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PZEMSensor::search() {
|
bool PZEMSensor::search() {
|
||||||
|
bool ret = false;
|
||||||
static uint8_t response[7];
|
static uint8_t response[7];
|
||||||
for (uint16_t addr = 0x01; addr <= 0xF8; addr++) {
|
for (uint16_t addr = 0x01; addr <= 0xF8; addr++) {
|
||||||
sendCmd8(CMD_RIR, 0x00, 0x01, false, addr);
|
sendCmd8(CMD_RIR, 0x00, 0x01, false, addr);
|
||||||
@@ -303,8 +306,9 @@ void PZEMSensor::search() {
|
|||||||
// Something went wrong
|
// Something went wrong
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
Serial.print("Device on addr: ");
|
Serial.println("Pzem " + String(addr));
|
||||||
Serial.print(addr);
|
ret = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ lib_deps =
|
|||||||
https://github.com/JonasGMorsch/GY-21.git
|
https://github.com/JonasGMorsch/GY-21.git
|
||||||
ClosedCube HDC1080
|
ClosedCube HDC1080
|
||||||
adafruit/MAX6675 library
|
adafruit/MAX6675 library
|
||||||
|
mandulaj/PZEM-004T-v30
|
||||||
rc-switch @ ^2.6.4
|
rc-switch @ ^2.6.4
|
||||||
robtillaart/SHT2x@^0.1.1
|
robtillaart/SHT2x@^0.1.1
|
||||||
WEMOS SHT3x@1.0.0
|
WEMOS SHT3x@1.0.0
|
||||||
|
|||||||
@@ -20,8 +20,13 @@ class Pzem004v : public IoTItem {
|
|||||||
|
|
||||||
void doByInterval() {
|
void doByInterval() {
|
||||||
if (pzem) {
|
if (pzem) {
|
||||||
value.valD = pzem->values()->voltage;
|
bool online = false;
|
||||||
regEvent(value.valD, "Pzem Voltage");
|
value.valD = pzem->values(online)->voltage;
|
||||||
|
if (online) {
|
||||||
|
regEvent(value.valD, "Pzem V");
|
||||||
|
} else {
|
||||||
|
SerialPrint("E", "Pzem", "V error");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,8 +48,13 @@ class Pzem004a : public IoTItem {
|
|||||||
|
|
||||||
void doByInterval() {
|
void doByInterval() {
|
||||||
if (pzem) {
|
if (pzem) {
|
||||||
value.valD = pzem->values()->current;
|
bool online = false;
|
||||||
regEvent(value.valD, "Pzem Ampere");
|
value.valD = pzem->values(online)->current;
|
||||||
|
if (online) {
|
||||||
|
regEvent(value.valD, "Pzem A");
|
||||||
|
} else {
|
||||||
|
SerialPrint("E", "Pzem", "A error");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,8 +76,13 @@ class Pzem004w : public IoTItem {
|
|||||||
|
|
||||||
void doByInterval() {
|
void doByInterval() {
|
||||||
if (pzem) {
|
if (pzem) {
|
||||||
value.valD = pzem->values()->power;
|
bool online = false;
|
||||||
regEvent(value.valD, "Pzem Watt");
|
value.valD = pzem->values(online)->power;
|
||||||
|
if (online) {
|
||||||
|
regEvent(value.valD, "Pzem W");
|
||||||
|
} else {
|
||||||
|
SerialPrint("E", "Pzem", "W error");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,8 +104,13 @@ class Pzem004wh : public IoTItem {
|
|||||||
|
|
||||||
void doByInterval() {
|
void doByInterval() {
|
||||||
if (pzem) {
|
if (pzem) {
|
||||||
value.valD = pzem->values()->energy;
|
bool online = false;
|
||||||
regEvent(value.valD, "Pzem Watt/hr");
|
value.valD = pzem->values(online)->energy;
|
||||||
|
if (online) {
|
||||||
|
regEvent(value.valD, "Pzem Wh");
|
||||||
|
} else {
|
||||||
|
SerialPrint("E", "Pzem", "Wh error");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,8 +132,13 @@ class Pzem004hz : public IoTItem {
|
|||||||
|
|
||||||
void doByInterval() {
|
void doByInterval() {
|
||||||
if (pzem) {
|
if (pzem) {
|
||||||
value.valD = pzem->values()->freq;
|
bool online = false;
|
||||||
regEvent(value.valD, "Pzem Hz");
|
value.valD = pzem->values(online)->freq;
|
||||||
|
if (online) {
|
||||||
|
regEvent(value.valD, "Pzem Hz");
|
||||||
|
} else {
|
||||||
|
SerialPrint("E", "Pzem", "Hz error");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@
|
|||||||
"page": "Сенсоры",
|
"page": "Сенсоры",
|
||||||
"descr": "Частота",
|
"descr": "Частота",
|
||||||
"int": 15,
|
"int": 15,
|
||||||
"addr": "0x77"
|
"addr": "0xF8"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"about": {
|
"about": {
|
||||||
@@ -81,7 +81,11 @@
|
|||||||
},
|
},
|
||||||
"defActive": true,
|
"defActive": true,
|
||||||
"devices": {
|
"devices": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [
|
||||||
"esp8266_4mb": []
|
"mandulaj/PZEM-004T-v30"
|
||||||
|
],
|
||||||
|
"esp8266_4mb": [
|
||||||
|
"mandulaj/PZEM-004T-v30"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user