Merge pull request #347 from IoTManagerProject/ver4dev

Ver4dev
This commit is contained in:
Dmitry Borisenko
2023-10-16 19:41:59 +02:00
committed by GitHub
99 changed files with 548 additions and 114 deletions

View File

@@ -25,7 +25,7 @@
"projectProp": {
"platformio": {
"default_envs": "esp8266_4mb",
"comments_default_envs": "choose from: esp8266_4mb or esp32_4mb or esp32cam_4mb or esp32s2_4mb or esp8266_1mb or esp8266_1mb_ota or esp8285_1mb or esp8285_1mb_ota",
"comments_default_envs": "choose from: esp8266_4mb or esp32_4mb or esp32cam_4mb or esp32s2_4mb or esp32_4mb3f or esp8266_1mb or esp8266_1mb_ota or esp8285_1mb or esp8285_1mb_ota",
"envs": [
{
"name": "esp8266_4mb",
@@ -45,6 +45,14 @@
"partitions": "0x8000",
"littlefs": "0x290000"
},
{
"name": "esp32_4mb3f",
"boot_app0": "0xe000",
"bootloader_qio_80m": "0x1000",
"firmware": "0x10000",
"partitions": "0x8000",
"littlefs": "0x310000"
},
{
"name": "esp32cam_4mb",
"boot_app0": "0xe000",
@@ -146,6 +154,10 @@
}
],
"sensors": [
{
"path": "src/modules/exec/Pcf8591",
"active": false
},
{
"path": "src/modules/sensors/A02Distance",
"active": true

Binary file not shown.

Binary file not shown.

View File

@@ -4,12 +4,12 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>IoT Manager 4.5.4</title>
<title>IoT Manager 4.5.5</title>
<link rel="icon" type="image/png" href="/favicon.ico" />
<link rel="stylesheet" href="/build/bundle.css?4541" />
<link rel="stylesheet" href="/build/bundle.css?4550" />
<script defer src="/build/bundle.js?4541"></script>
<script defer src="/build/bundle.js?4550"></script>
</head>
<body></body>

Binary file not shown.

Binary file not shown.

View File

@@ -48,6 +48,10 @@
}
],
"sensors": [
{
"path": "src/modules/exec/Pcf8591",
"active": false
},
{
"path": "src/modules/sensors/A02Distance",
"active": true

View File

@@ -4,12 +4,12 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>IoT Manager 4.5.4</title>
<title>IoT Manager 4.5.5</title>
<link rel="icon" type="image/png" href="/favicon.ico" />
<link rel="stylesheet" href="/build/bundle.css?4541" />
<link rel="stylesheet" href="/build/bundle.css?4550" />
<script defer src="/build/bundle.js?4541"></script>
<script defer src="/build/bundle.js?4550"></script>
</head>
<body></body>

View File

@@ -2,7 +2,7 @@
#include "BuildTime.h"
// Версия прошивки
#define FIRMWARE_VERSION 454
#define FIRMWARE_VERSION 455
#ifdef esp8266_1mb_ota
#define FIRMWARE_NAME "esp8266_1mb_ota"

View File

@@ -65,6 +65,7 @@ class IoTItem {
virtual void setValue(const String& valStr, bool genEvent = true);
String getRoundValue();
void getNetEvent(String& event);
virtual String getMqttExterSub();
// хуки для системных событий (должны начинаться с "on")
virtual void onRegEvent(IoTItem* item);

View File

@@ -25,7 +25,7 @@
"projectProp": {
"platformio": {
"default_envs": "esp8266_4mb",
"comments_default_envs": "choose from: esp8266_4mb or esp32_4mb or esp32cam_4mb or esp32s2_4mb or esp8266_1mb or esp8266_1mb_ota or esp8285_1mb or esp8285_1mb_ota",
"comments_default_envs": "choose from: esp8266_4mb or esp32_4mb or esp32cam_4mb or esp32s2_4mb or esp32_4mb3f or esp8266_1mb or esp8266_1mb_ota or esp8285_1mb or esp8285_1mb_ota",
"envs": [
{
"name": "esp8266_4mb",
@@ -45,6 +45,14 @@
"partitions": "0x8000",
"littlefs": "0x290000"
},
{
"name": "esp32_4mb3f",
"boot_app0": "0xe000",
"bootloader_qio_80m": "0x1000",
"firmware": "0x10000",
"partitions": "0x8000",
"littlefs": "0x310000"
},
{
"name": "esp32cam_4mb",
"boot_app0": "0xe000",
@@ -146,6 +154,10 @@
}
],
"sensors": [
{
"path": "src/modules/exec/Pcf8591",
"active": false
},
{
"path": "src/modules/sensors/A02Distance",
"active": true

View File

@@ -199,6 +199,27 @@ build_src_filter =
+<modules/*.cpp>
${env:esp32_4mb_fromitems.build_src_filter}
[env:esp32_4mb3f]
lib_deps =
${common_env_data.lib_deps_external}
${env:esp32_4mb3f_fromitems.lib_deps}
build_flags = -Desp32_4mb="esp32_4mb"
framework = arduino
board = esp32dev
platform = espressif32 @5.1.1
monitor_filters = esp32_exception_decoder
upload_speed = 921600
monitor_speed = 115200
debug_tool = esp-prog
board_build.partitions = tools/partitions_custom.csv
board_build.filesystem = littlefs
build_src_filter =
+<*.cpp>
+<classes/*.cpp>
+<utils/*.cpp>
+<modules/*.cpp>
${env:esp32_4mb3f_fromitems.build_src_filter}
[env:esp32cam_4mb]
lib_deps =
${common_env_data.lib_deps_external}
@@ -587,6 +608,65 @@ build_src_filter =
+<modules/display/Smi2_m>
+<modules/display/TM16XX>
[env:esp32_4mb3f_fromitems]
lib_deps =
https://github.com/enjoyneering/AHTxx.git
adafruit/Adafruit BME280 Library
adafruit/Adafruit BMP280 Library
beegee-tokyo/DHT sensor library for ESPx
https://github.com/milesburton/Arduino-Temperature-Control-Library
https://github.com/tremaru/iarduino_RTC
robtillaart/SHT2x@^0.1.1
WEMOS SHT3x@1.0.0
plerup/EspSoftwareSerial
gyverlibs/EncButton @ ^2.0
https://github.com/RoboticsBrno/ServoESP32#v1.0.3
adafruit/Adafruit MCP23017 Arduino Library@^2.1.0
adafruit/Adafruit BusIO @ ^1.13.2
dfrobot/DFRobotDFPlayerMini @ ^1.0.5
adafruit/Adafruit BusIO @ ^1.13.2
https://github.com/robotclass/RobotClass_LiquidCrystal_I2C
marcoschwartz/LiquidCrystal_I2C@^1.1.4
https://github.com/maxint-rd/TM16xx
adafruit/Adafruit GFX Library @ ^1.11.5
build_src_filter =
+<modules/virtual/Cron>
+<modules/virtual/Loging>
+<modules/virtual/LogingDaily>
+<modules/virtual/Timer>
+<modules/virtual/Variable>
+<modules/virtual/VariableColor>
+<modules/virtual/VButton>
+<modules/sensors/Acs712>
+<modules/sensors/AhtXX>
+<modules/sensors/AnalogAdc>
+<modules/sensors/Bme280>
+<modules/sensors/Bmp280>
+<modules/sensors/Dht1122>
+<modules/sensors/Ds18b20>
+<modules/sensors/Impulse>
+<modules/sensors/Pzem004t>
+<modules/sensors/RTC>
+<modules/sensors/S8>
+<modules/sensors/Sht20>
+<modules/sensors/Sht30>
+<modules/sensors/Sonar>
+<modules/sensors/UART>
+<modules/exec/ButtonIn>
+<modules/exec/ButtonOut>
+<modules/exec/Buzzer>
+<modules/exec/Enconder>
+<modules/exec/IoTServo>
+<modules/exec/Mcp23017>
+<modules/exec/Mp3>
+<modules/exec/Multitouch>
+<modules/exec/Pcf8574>
+<modules/exec/Pwm32>
+<modules/exec/TelegramLT>
+<modules/display/Lcd2004>
+<modules/display/Smi2_m>
+<modules/display/TM16XX>
[env:esp32cam_4mb_fromitems]
lib_deps =
espressif/esp32-camera @ ^2.0.0

View File

@@ -118,6 +118,15 @@ void mqttSubscribe() {
mqtt.subscribe((mqttPrefix + "/+/+/order/#").c_str());
mqtt.subscribe((mqttPrefix + "/+/+/info").c_str());
}
for (std::list<IoTItem*>::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) {
if ((*it)->getSubtype() == "ExternalMQTT") {
String tmps = (*it)->getMqttExterSub();
if (tmps != ""){
mqtt.subscribe(tmps.c_str());
SerialPrint("i", F("MQTT"), ("subscribed external " + tmps).c_str());
}
}
}
}
void mqttSubscribeExternal(String topic, bool usePrefix) {

View File

@@ -185,6 +185,10 @@ void IoTItem::checkIntFromNet() {
}
}
String IoTItem::getMqttExterSub() {
return "";
}
// хуки для системных событий (должны начинаться с "on")
void IoTItem::onRegEvent(IoTItem* item) {}
void IoTItem::onMqttRecive(String& topic, String& msg) {}

View File

@@ -44,6 +44,7 @@
"defActive": false,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp8266_4mb": [],
"esp8266_1mb": [],

View File

@@ -123,6 +123,10 @@
"https://github.com/robotclass/RobotClass_LiquidCrystal_I2C",
"marcoschwartz/LiquidCrystal_I2C@^1.1.4"
],
"esp32_4mb3f": [
"https://github.com/robotclass/RobotClass_LiquidCrystal_I2C",
"marcoschwartz/LiquidCrystal_I2C@^1.1.4"
],
"esp32cam_4mb": [
"https://github.com/robotclass/RobotClass_LiquidCrystal_I2C",
"marcoschwartz/LiquidCrystal_I2C@^1.1.4"

View File

@@ -39,6 +39,9 @@
"esp32_4mb": [
"https://github.com/avaksru/ESPNexUpload.git"
],
"esp32_4mb3f": [
"https://github.com/avaksru/ESPNexUpload.git"
],
"esp32cam_4mb": [
"https://github.com/avaksru/ESPNexUpload.git"
],

View File

@@ -76,6 +76,9 @@
"esp32_4mb": [
"gyverlibs/GyverOLED @ 1.4"
],
"esp32_4mb3f": [
"gyverlibs/GyverOLED @ 1.4"
],
"esp32_16mb": [
"gyverlibs/GyverOLED @ 1.4"
],

View File

@@ -53,6 +53,7 @@
"defActive": true,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": []
}
}

View File

@@ -107,6 +107,11 @@
"adafruit/Adafruit GFX Library @ ^1.11.5",
"adafruit/Adafruit BusIO @ ^1.13.2"
],
"esp32_4mb3f": [
"https://github.com/maxint-rd/TM16xx",
"adafruit/Adafruit GFX Library @ ^1.11.5",
"adafruit/Adafruit BusIO @ ^1.13.2"
],
"esp32cam_4mb": [
"https://github.com/maxint-rd/TM16xx",
"adafruit/Adafruit GFX Library @ ^1.11.5",

View File

@@ -100,6 +100,9 @@
"esp32_4mb": [
"adafruit/Adafruit NeoPixel@^1.10.6"
],
"esp32_4mb3f": [
"adafruit/Adafruit NeoPixel@^1.10.6"
],
"esp32cam_4mb": [
"adafruit/Adafruit NeoPixel@^1.10.6"
],

View File

@@ -46,6 +46,7 @@
"defActive": true,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp32_16mb": [],
"esp32s2_4mb": [],

View File

@@ -50,6 +50,7 @@
"defActive": true,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp32_16mb": [],
"esp32s2_4mb": [],

View File

@@ -104,6 +104,7 @@
"defActive": true,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp8266_4mb": [],
"esp8266_1mb": [],

View File

@@ -46,6 +46,9 @@
"esp32_4mb": [
"gyverlibs/EncButton @ ^2.0"
],
"esp32_4mb3f": [
"gyverlibs/EncButton @ ^2.0"
],
"esp32cam_4mb": [
"gyverlibs/EncButton @ ^2.0"
],

View File

@@ -35,6 +35,7 @@
"defActive": false,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp32_16mb": [],
"esp32s2_4mb": [],

View File

@@ -50,6 +50,7 @@
"defActive": false,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp32s2_4mb": [],
"esp8266_4mb": [],

View File

@@ -51,6 +51,9 @@
"esp32_4mb": [
"https://github.com/RoboticsBrno/ServoESP32#v1.0.3"
],
"esp32_4mb3f": [
"https://github.com/RoboticsBrno/ServoESP32#v1.0.3"
],
"esp32cam_4mb": [
"https://github.com/RoboticsBrno/ServoESP32#v1.0.3"
],

View File

@@ -40,6 +40,10 @@
"adafruit/Adafruit Mcp23017 Arduino Library@^2.1.0",
"adafruit/Adafruit BusIO @ ^1.13.2"
],
"esp32_4mb3f": [
"adafruit/Adafruit Mcp23017 Arduino Library@^2.1.0",
"adafruit/Adafruit BusIO @ ^1.13.2"
],
"esp32cam_4mb": [
"adafruit/Adafruit Mcp23017 Arduino Library@^2.1.0",
"adafruit/Adafruit BusIO @ ^1.13.2"

View File

@@ -40,6 +40,10 @@
"adafruit/Adafruit MCP23017 Arduino Library@^2.1.0",
"adafruit/Adafruit BusIO @ ^1.13.2"
],
"esp32_4mb3f": [
"adafruit/Adafruit MCP23017 Arduino Library@^2.1.0",
"adafruit/Adafruit BusIO @ ^1.13.2"
],
"esp32cam_4mb": [
"adafruit/Adafruit MCP23017 Arduino Library@^2.1.0",
"adafruit/Adafruit BusIO @ ^1.13.2"

View File

@@ -92,6 +92,9 @@
"esp32_4mb": [
"dfrobot/DFRobotDFPlayerMini @ ^1.0.5"
],
"esp32_4mb4f": [
"dfrobot/DFRobotDFPlayerMini @ ^1.0.5"
],
"esp32cam_4mb": [
"dfrobot/DFRobotDFPlayerMini @ ^1.0.5"
],

View File

@@ -44,6 +44,7 @@
"defActive": true,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp8266_4mb": [],
"esp8266_1mb": [],

View File

@@ -50,6 +50,7 @@
"defActive": false,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": []
}
}

View File

@@ -1,28 +1,23 @@
#include "Global.h"
#include "classes/IoTItem.h"
#include "classes/IoTGpio.h"
#include <Adafruit_BusIO_Register.h>
#include <Adafruit_I2CDevice.h>
#define PCF8574_I2CADDR_DEFAULT 0x20 ///< DS3502 default I2C address
#define PCF8574_I2CADDR_DEFAULT 0x20 ///< DS3502 стандартный I2C адрес
class Adafruit_PCF8574_mod {
public:
Adafruit_PCF8574_mod() {};
Adafruit_PCF8574_mod() : _pinConfig(0xFF) {}; // По умолчанию все пины настроены как входы
bool begin(uint8_t i2c_address = PCF8574_I2CADDR_DEFAULT, TwoWire *wire = &Wire) {
i2c_dev = new Adafruit_I2CDevice(i2c_address, wire);
if (!i2c_dev->begin()) {
return false;
}
return true;
return i2c_dev->begin();
}
bool digitalWriteByte(uint8_t d) {
_writebuf = d;
return i2c_dev->write(&_writebuf, 1);
return updateRegister();
}
uint8_t digitalReadByte(void) {
@@ -32,20 +27,20 @@ class Adafruit_PCF8574_mod {
bool digitalWrite(int pinnum, bool val) {
if (val) {
_writebuf |= 1 << pinnum;
_writebuf |= (1 << pinnum);
} else {
_writebuf &= ~(1 << pinnum);
}
return i2c_dev->write(&_writebuf, 1);
return updateRegister(); // Обновляем регистр после изменения состояния пина
}
bool pinMode(int pinnum, uint8_t val) {
if ((val == INPUT) || (val == INPUT_PULLUP)) {
_writebuf |= 1 << pinnum;
_pinConfig |= (1 << pinnum);
} else {
_writebuf &= ~(1 << pinnum);
_pinConfig &= ~(1 << pinnum);
}
return i2c_dev->write(&_writebuf, 1);
return updateRegister(); // Обновляем регистр после изменения конфигурации пина
}
bool digitalRead(int pinnum) {
@@ -55,6 +50,12 @@ class Adafruit_PCF8574_mod {
private:
uint8_t _readbuf = 0, _writebuf = 0;
uint8_t _pinConfig; // Конфигурация пинов (вход/выход)
bool updateRegister() {
uint8_t outputValue = (_writebuf & ~_pinConfig) | (_pinConfig);
return i2c_dev->write(&outputValue, 1); // Отправляем обновленное значение регистра на устройство
}
Adafruit_I2CDevice *i2c_dev;
};
@@ -66,7 +67,7 @@ class Pcf8574Driver : public IoTGpio {
public:
Pcf8574Driver(int index, String addr) : IoTGpio(index) {
if (!_pcf.begin(hexStringToUint8(addr), &Wire)) {
Serial.println("PCF8574 Init Error.");
Serial.println("Ошибка инициализации PCF8574."); // Переводим на русский
}
}
@@ -85,11 +86,8 @@ class Pcf8574Driver : public IoTGpio {
void digitalInvert(int pin) {
_pcf.digitalWrite(pin, 1 - _pcf.digitalRead(pin));
}
~Pcf8574Driver() {};
};
class Pcf8574 : public IoTItem {
private:
Pcf8574Driver* _driver;
@@ -108,7 +106,7 @@ class Pcf8574 : public IoTItem {
int index;
jsonRead(parameters, "index", index);
if (index > 4) {
Serial.println("Pcf8574 wrong index. Must be 0 - 4");
Serial.println("Неправильный индекс Pcf8574. Должен быть 0 - 4."); // Переводим на русский
return;
}
@@ -122,14 +120,13 @@ class Pcf8574 : public IoTItem {
}
}
//возвращает ссылку на экземпляр класса Pcf8574Driver
IoTGpio* getGpioDriver() {
return _driver;
}
~Pcf8574() {
delete _driver;
};
}
};
void* getAPI_Pcf8574(String subtype, String param) {

View File

@@ -35,6 +35,9 @@
"esp32_4mb": [
"adafruit/Adafruit BusIO @ ^1.13.2"
],
"esp32_4mb3f": [
"adafruit/Adafruit BusIO @ ^1.13.2"
],
"esp32cam_4mb": [
"adafruit/Adafruit BusIO @ ^1.13.2"
],

View File

@@ -0,0 +1,71 @@
#include "Global.h"
#include "classes/IoTItem.h"
#include "Wire.h"
#include <Adafruit_PCF8591.h>
// Make sure that this is set to the value in volts of VCC
#define ADC_REFERENCE_VOLTAGE 3.3
class Pcf8591 : public IoTItem {
int _pin;
bool _isRaw;
bool _isInited = false;
Adafruit_PCF8591 pcf = Adafruit_PCF8591();
public:
Pcf8591(String parameters) : IoTItem(parameters) {
String tmp;
jsonRead(parameters, "pin", tmp);
_pin = tmp.toInt();
jsonRead(parameters, "mode", tmp);
_isRaw = tmp == "raw";
if (!pcf.begin()) {
Serial.println("# Adafruit PCF8591 not found!");
_isInited = false;
} else
_isInited = true;
Serial.println("# Adafruit PCF8591 found");
pcf.enableDAC(true);
Serial.println("AIN0, AIN1, AIN2, AIN3");
}
uint8_t dac_counter = 0;
void doByInterval() {
// Make a triangle wave on the DAC output
pcf.analogWrite(dac_counter++);
if (_isInited) {
if (_isRaw)
value.valD = pcf.analogRead(_pin); // Чтение АЦП нулевого канала (Вольты)
else
value.valD = (int_to_volts(pcf.analogRead(_pin), 8, ADC_REFERENCE_VOLTAGE));
regEvent(value.valD, "PCF8591");
}
}
float int_to_volts(uint16_t dac_value, uint8_t bits, float logic_level) {
return (((float)dac_value / ((1 << bits) - 1)) * logic_level);
}
~Pcf8591(){};
};
void *getAPI_Pcf8591(String subtype, String param) {
if (subtype == F("Pcf8591")) {
return new Pcf8591(param);
} else {
return nullptr;
}
}

View File

@@ -0,0 +1,75 @@
{
"menuSection": "sensors",
"configItem": [
{
"global": 0,
"name": "Расширитель портов PCF8591",
"type": "Reading",
"subtype": "Pcf8591",
"id": "Pcf85",
"widget": "anydataVlt",
"page": "PCF8591",
"descr": "PCF_0",
"pin": "0",
"mode": "volt",
"map": "1,255,1,100",
"plus": 0,
"multiply": 1,
"round": 2,
"int": 7
}
],
"about": {
"authorName": "Serghei Crasnicov",
"authorContact": "https://t.me/Serghei63",
"authorGit": "https://github.com/Serghei63",
"specialThanks": "",
"moduleName": "Pcf8591",
"moduleVersion": "1.0",
"usedRam": {
"esp32_4mb": 15,
"esp8266_4mb": 15
},
"title": "Расширитель 4-х аналоговых портов PCF8591",
"moduleDesc": "Позволяет получить относительную величину напряжения на понижающем трансформаторе.",
"propInfo": {
"pin": "Номер AN, к которому подключен датчик. Допускается 0, 1, 2, 3",
"mode": "Режим работы. volt - вывод в вольтах , raw - значения от 0 до 255",
"int": "Количество секунд между опросами датчика."
}
},
"defActive": false,
"usedLibs": {
"esp32_4mb": [
"https://github.com/adafruit/Adafruit_PCF8591"
],
"esp32_16mb": [
"https://github.com/adafruit/Adafruit_PCF8591"
],
"esp8266_4mb": [
"https://github.com/adafruit/Adafruit_PCF8591"
],
"esp8266_16mb": [
"https://github.com/adafruit/Adafruit_PCF8591"
],
"esp8266_1mb": [
"https://github.com/adafruit/Adafruit_PCF8591"
],
"esp8266_1mb_ota": [
"https://github.com/adafruit/Adafruit_PCF8591"
],
"esp8285_1mb": [
"https://github.com/adafruit/Adafruit_PCF8591"
],
"esp8285_1mb_ota": [
"https://github.com/adafruit/Adafruit_PCF8591"
],
"esp8266_2mb": [
"https://github.com/adafruit/Adafruit_PCF8591"
],
"esp8266_2mb_ota": [
"https://github.com/adafruit/Adafruit_PCF8591"
]
}
}

View File

@@ -45,6 +45,7 @@
"defActive": true,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": []
}
}

View File

@@ -35,6 +35,9 @@
"esp32_4mb": [
"espressif/esp32-camera @ ^2.0.0"
],
"esp32_4mb3f": [
"espressif/esp32-camera @ ^2.0.0"
],
"esp32cam_4mb": [
"espressif/esp32-camera @ ^2.0.0"
]

View File

@@ -33,6 +33,7 @@
"defActive": false,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp8266_4mb": []
}

View File

@@ -58,6 +58,9 @@
"esp32_4mb": [
"CTBot @2.1.9"
],
"esp32_4mb3f": [
"CTBot @2.1.9"
],
"esp32cam_4mb": [
"CTBot @2.1.9"
],

View File

@@ -52,6 +52,7 @@
"defActive": true,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp32_16mb": [],
"esp32s2_4mb": [],

View File

@@ -77,6 +77,9 @@
"esp32_4mb": [
"gyverlibs/FastBot"
],
"esp32_4mb3f": [
"gyverlibs/FastBot"
],
"esp32cam_4mb": [
"gyverlibs/FastBot"
],

View File

@@ -152,6 +152,7 @@ class ThermostatPID : public IoTItem
private:
String _set_id; // заданная температура
String _term_id; // термометр
String _term_rezerv_id; // резервный термометр
float _int, _KP, _KI, _KD, sp, pv,
pv_last = 0, // предыдущая температура
ierr = 0, // интегральная погрешность
@@ -168,6 +169,7 @@ public:
{
jsonRead(parameters, "set_id", _set_id);
jsonRead(parameters, "term_id", _term_id);
jsonRead(parameters, "term_rezerv_id", _term_rezerv_id);
jsonRead(parameters, "int", _int);
jsonRead(parameters, "KP", _KP);
jsonRead(parameters, "KI", _KI);
@@ -237,12 +239,32 @@ protected:
interim = tmp->getValue();
pv = ::atof(interim.c_str());
}
if (pv < -40 && pv > 120 && !pv) // Решаем что ошибка датчика
{
if (_term_rezerv_id != "")
{
tmp = findIoTItem(_term_rezerv_id); // используем резервный
if (tmp)
{
interim = tmp->getValue();
pv = ::atof(interim.c_str());
if (pv < -40 && pv > 120 && !pv)
pv = 0;
}
else
pv = 0;
}
else
pv = 0;
}
if (sp && pv)
{
// value.valD = pid(sp, pv, pv_last, ierr, _int);
// value.valS = (String)(int)value.valD;
regEvent(pid(sp, pv, pv_last, ierr, _int), "ThermostatPID", false, true);
}
else
regEvent(0, "ThermostatPID", false, true);
pv_last = pv;
}

View File

@@ -34,6 +34,7 @@
"map": "1,100,1,100",
"set_id": "",
"term_id": "",
"term_rezerv_id": "",
"rele": "",
"KP": 5.0,
"KI": 50,
@@ -134,6 +135,7 @@
"defActive": false,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp8266_4mb": [],
"esp8266_1mb": [],

View File

@@ -42,6 +42,7 @@
"defActive": true,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp32s2_4mb": [],
"esp8266_4mb": [],

View File

@@ -44,6 +44,9 @@
"esp32_4mb": [
"adafruit/Adafruit ADS1X15 @ ^2.3.0"
],
"esp32_4mb3f": [
"adafruit/Adafruit ADS1X15 @ ^2.3.0"
],
"esp32cam_4mb": [
"adafruit/Adafruit ADS1X15 @ ^2.3.0"
],

View File

@@ -59,6 +59,9 @@
"esp32_4mb": [
"https://github.com/enjoyneering/AHTxx.git"
],
"esp32_4mb3f": [
"https://github.com/enjoyneering/AHTxx.git"
],
"esp32cam_4mb": [
"https://github.com/enjoyneering/AHTxx.git"
],

View File

@@ -42,6 +42,7 @@
"defActive": true,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp8266_4mb": [],
"esp8266_1mb": [],

View File

@@ -37,6 +37,9 @@
"esp32_4mb": [
"BH1750"
],
"esp32_4mb3f": [
"BH1750"
],
"esp32cam_4mb": [
"BH1750"
],

View File

@@ -63,6 +63,10 @@
"https://github.com/h2zero/NimBLE-Arduino.git",
"https://github.com/avaksru/decoder.git"
],
"esp32_4mb3f": [
"https://github.com/h2zero/NimBLE-Arduino.git",
"https://github.com/avaksru/decoder.git"
],
"esp32cam_4mb": [
"https://github.com/h2zero/NimBLE-Arduino.git",
"https://github.com/avaksru/decoder.git"

View File

@@ -83,6 +83,9 @@
"esp32_4mb": [
"adafruit/Adafruit BME280 Library"
],
"esp32_4mb3f": [
"adafruit/Adafruit BME280 Library"
],
"esp32cam_4mb": [
"adafruit/Adafruit BME280 Library"
],

View File

@@ -55,6 +55,9 @@
"esp32_4mb": [
"adafruit/Adafruit BMP280 Library"
],
"esp32_4mb3f": [
"adafruit/Adafruit BMP280 Library"
],
"esp32cam_4mb": [
"adafruit/Adafruit BMP280 Library"
],

View File

@@ -36,6 +36,7 @@
"defActive": false,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp8266_4mb": [],
"esp8266_1mb": [],

View File

@@ -55,6 +55,9 @@
"esp32_4mb": [
"beegee-tokyo/DHT sensor library for ESPx"
],
"esp32_4mb3f": [
"beegee-tokyo/DHT sensor library for ESPx"
],
"esp32cam_4mb": [
"beegee-tokyo/DHT sensor library for ESPx"
],

View File

@@ -42,6 +42,9 @@
"esp32_4mb": [
"https://github.com/milesburton/Arduino-Temperature-Control-Library"
],
"esp32_4mb3f": [
"https://github.com/milesburton/Arduino-Temperature-Control-Library"
],
"esp32cam_4mb": [
"https://github.com/milesburton/Arduino-Temperature-Control-Library"
],

View File

@@ -64,6 +64,10 @@
"https://github.com/jbechter/arduino-onewire-DS2423",
"paulstoffregen/OneWire @ ^2.3.7"
],
"esp32_4mb3f": [
"https://github.com/jbechter/arduino-onewire-DS2423",
"paulstoffregen/OneWire @ ^2.3.7"
],
"esp32cam_4mb": [
"https://github.com/jbechter/arduino-onewire-DS2423",
"paulstoffregen/OneWire @ ^2.3.7"

View File

@@ -62,6 +62,9 @@
"esp32_4mb": [
"openenergymonitor/EmonLib@1.1.0"
],
"esp32_4mb3f": [
"openenergymonitor/EmonLib@1.1.0"
],
"esp32cam_4mb": [
"openenergymonitor/EmonLib@1.1.0"
],

View File

@@ -76,6 +76,7 @@
"defActive": false,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp32s2_4mb": [],
"esp8266_4mb": [],

View File

@@ -15,7 +15,6 @@ private:
bool dataFromNode = false;
String _topic = "";
bool _isJson;
// bool _addPrefix;
bool _debug;
bool sendOk = false;
@@ -32,9 +31,11 @@ public:
jsonRead(parameters, "debug", _debug);
dataFromNode = false;
if (mqttIsConnect())
{
sendOk = true;
mqttSubscribeExternal(_topic);
}
}
char *TimeToString(unsigned long t)
{
static char str[12];
@@ -49,16 +50,15 @@ public:
{
if (msg.indexOf("HELLO") == -1)
{
if (_debug)
{
SerialPrint("i", "onMqttRecive", "Прилетело " + topic + " msg: " + msg);
// SerialPrint("i", "onMqttRecive", "Прилетело " + msg);
}
String dev = selectToMarkerLast(topic, "/");
dev.toUpperCase();
dev.replace(":", "");
if (_topic != topic)
{
if (_debug)
{
SerialPrint("i", "ExternalMQTT", _id + " not equal: " + topic + " msg: " + msg);
}
return;
}
@@ -68,7 +68,7 @@ public:
DeserializationError error = deserializeJson(doc, msg);
if (error)
{
SerialPrint("E", F("onMqttRecive"), error.f_str());
SerialPrint("E", F("ExternalMQTT"), error.f_str());
}
JsonObject jsonObject = doc.as<JsonObject>();
@@ -78,34 +78,34 @@ public:
String val = kv.value();
if (_debug)
{
SerialPrint("i", "onMqttRecive", "Прилетело MAC: " + dev + " key=" + key + " val=" + val);
SerialPrint("i", "ExternalMQTT", "Received MAC: " + dev + " key=" + key + " val=" + val);
}
if (_sensor == key)
{
dataFromNode = true;
_minutesPassed = 0;
setValue(val);
// setNewWidgetAttributes();
}
// Serial.println("Key: " + key);
// Serial.println("Value: " + val);
}
}
else
{
if (_debug)
{
SerialPrint("i", "onMqttRecive", "Прилетело MAC: " + dev + " val=" + msg);
SerialPrint("i", "ExternalMQTT", "Received MAC: " + dev + " val=" + msg);
}
dataFromNode = true;
_minutesPassed = 0;
setValue(msg);
// setNewWidgetAttributes();
}
}
}
String getMqttExterSub()
{
return _topic;
}
void doByInterval()
{
_minutesPassed++;
@@ -144,8 +144,7 @@ public:
if (_minutesPassed >= offline)
{
jsonWriteStr(json, F("info"), F("offline"));
regEvent(NAN, "ExternalMQTT");
SerialPrint("E", "ExternalMQTT", "V error", _id);
SerialPrint("i", "ExternalMQTT", _id + " - offline");
}
}
}
@@ -155,22 +154,6 @@ public:
}
sendSubWidgetsValues(_id, json);
}
/*
IoTValue execute(String command, std::vector<IoTValue> &param)
{
if (command == "mqttSubscribe")
{
if (param.size() == 2)
{
if (!param[0].isDecimal && param[1].isDecimal)
{
mqttSubscribeExternal(param[0].valS, (bool)param[0].valD);
}
}
}
return {};
}
*/
~ExternalMQTT(){};
};

View File

@@ -51,6 +51,7 @@
"defActive": false,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32s2_4mb": [],
"esp32cam_4mb": [],
"esp8266_4mb": [],

View File

@@ -87,6 +87,9 @@
"esp32_4mb": [
"kosme/arduinoFFT@^1.5.6"
],
"esp32_4mb3f": [
"kosme/arduinoFFT@^1.5.6"
],
"esp32cam_4mb": [
"kosme/arduinoFFT@^1.5.6"
],

View File

@@ -52,6 +52,9 @@
"esp32_4mb": [
"https://github.com/JonasGMorsch/GY-21.git"
],
"esp32_4mb3f": [
"https://github.com/JonasGMorsch/GY-21.git"
],
"esp32cam_4mb": [
"https://github.com/JonasGMorsch/GY-21.git"
],

View File

@@ -55,6 +55,9 @@
"esp32_4mb": [
"ClosedCube HDC1080"
],
"esp32_4mb3f": [
"ClosedCube HDC1080"
],
"esp32cam_4mb": [
"ClosedCube HDC1080"
],

View File

@@ -49,6 +49,9 @@
"esp32_4mb": [
"https://github.com/kurimawxx00/hx710B_pressure_sensor"
],
"esp32_4mb3f": [
"https://github.com/kurimawxx00/hx710B_pressure_sensor"
],
"esp32cam_4mb": [
"https://github.com/kurimawxx00/hx710B_pressure_sensor"
],

View File

@@ -64,6 +64,9 @@
"esp32_4mb": [
"GyverHX711@1.2"
],
"esp32_4mb3f": [
"GyverHX711@1.2"
],
"esp32cam_4mb": [
"GyverHX711@1.2"
],

View File

@@ -41,6 +41,7 @@
"defActive": true,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp8266_4mb": [],
"esp8266_1mb": [],

View File

@@ -38,7 +38,7 @@ INA219 *instanceIna219(uint8_t ADDR)
// учитываем, что библиотека может работать с несколькими линиями на разных пинах, поэтому инициируем библиотеку, если линия ранее не использовалась
if (ina219Array.find(ADDR) == ina219Array.end())
{
if (ina219SettingArray.find(ADDR) == ina219SettingArray.end())
if (ina219SettingArray.find(ADDR) != ina219SettingArray.end())
ina219Array[ADDR] = new INA219(ina219SettingArray[ADDR]->shunt, ina219SettingArray[ADDR]->maxV, (uint8_t)ADDR);
else
ina219Array[ADDR] = new INA219(0.1f, 3.2f, (uint8_t)ADDR); // Стандартные значения для модуля INA219 (0.1 Ом, 3.2А, адрес 0x40)
@@ -66,8 +66,7 @@ public:
void doByInterval()
{
value.valD = instanceIna219(_addr)->getVoltage();
regEvent(value.valD, "Ina219voltage");
regEvent(instanceIna219(_addr)->getVoltage(), "Ina219voltage");
}
~Ina219voltage(){};
@@ -90,8 +89,7 @@ public:
}
void doByInterval()
{
value.valD = instanceIna219(_addr)->getShuntVoltage();
regEvent(value.valD, "Ina219shuntvoltage");
regEvent(instanceIna219(_addr)->getShuntVoltage(), "Ina219shuntvoltage");
}
~Ina219shuntvoltage(){};
@@ -114,8 +112,7 @@ public:
}
void doByInterval()
{
value.valD = instanceIna219(_addr)->getCurrent();
regEvent(value.valD, "Ina219curr");
regEvent(instanceIna219(_addr)->getCurrent(), "Ina219curr");
}
~Ina219curr(){};
@@ -138,8 +135,7 @@ public:
}
void doByInterval()
{
value.valD = instanceIna219(_addr)->getPower();
regEvent(value.valD, "Ina219power"); // TODO: найти способ понимания ошибки получения данных
regEvent(instanceIna219(_addr)->getPower(), "Ina219power"); // TODO: найти способ понимания ошибки получения данных
}
~Ina219Power(){};

View File

@@ -122,6 +122,9 @@
"esp32_4mb": [
"https://github.com/GyverLibs/GyverINA"
],
"esp32_4mb3f": [
"https://github.com/GyverLibs/GyverINA"
],
"esp32cam_4mb": [
"https://github.com/GyverLibs/GyverINA"
],

View File

@@ -38,7 +38,7 @@ INA226 *instanceIna226(uint8_t ADDR)
// учитываем, что библиотека может работать с несколькими линиями на разных пинах, поэтому инициируем библиотеку, если линия ранее не использовалась
if (ina226Array.find(ADDR) == ina226Array.end())
{
if (ina226SettingArray.find(ADDR) == ina226SettingArray.end())
if (ina226SettingArray.find(ADDR) != ina226SettingArray.end())
ina226Array[ADDR] = new INA226(ina226SettingArray[ADDR]->shunt, ina226SettingArray[ADDR]->maxV, (uint8_t)ADDR);
else
ina226Array[ADDR] = new INA226(0.1f, 0.8f, (uint8_t)ADDR); // Стандартные значения для модуля INA226 (0.1 Ом, 0.8А, адрес 0x40)
@@ -66,8 +66,7 @@ public:
void doByInterval()
{
value.valD = instanceIna226(_addr)->getVoltage();
regEvent(value.valD, "Ina226voltage");
regEvent(instanceIna226(_addr)->getVoltage(), "Ina226voltage");
}
~Ina226voltage(){};
@@ -90,8 +89,7 @@ public:
}
void doByInterval()
{
value.valD = instanceIna226(_addr)->getShuntVoltage();
regEvent(value.valD, "Ina226shuntvoltage");
regEvent(vinstanceIna226(_addr)->getShuntVoltage(), "Ina226shuntvoltage");
}
~Ina226shuntvoltage(){};
@@ -114,8 +112,7 @@ public:
}
void doByInterval()
{
value.valD = instanceIna226(_addr)->getCurrent();
regEvent(value.valD, "Ina226curr");
regEvent(instanceIna226(_addr)->getCurrent(), "Ina226curr");
}
~Ina226curr(){};
@@ -138,8 +135,7 @@ public:
}
void doByInterval()
{
value.valD = instanceIna226(_addr)->getPower();
regEvent(value.valD, "Ina226power"); // TODO: найти способ понимания ошибки получения данных
regEvent(instanceIna226(_addr)->getPower(), "Ina226power"); // TODO: найти способ понимания ошибки получения данных
}
~Ina226Power(){};

View File

@@ -122,6 +122,9 @@
"esp32_4mb": [
"https://github.com/GyverLibs/GyverINA"
],
"esp32_4mb3f": [
"https://github.com/GyverLibs/GyverINA"
],
"esp32cam_4mb": [
"https://github.com/GyverLibs/GyverINA"
],

View File

@@ -39,6 +39,9 @@
"esp32_4mb": [
"https://github.com/jpliew/Wiegand-NG-Multi-Bit-Wiegand-Library-for-Arduino"
],
"esp32_4mb3f": [
"https://github.com/jpliew/Wiegand-NG-Multi-Bit-Wiegand-Library-for-Arduino"
],
"esp32cam_4mb": [
"https://github.com/jpliew/Wiegand-NG-Multi-Bit-Wiegand-Library-for-Arduino"
],

View File

@@ -41,6 +41,9 @@
"esp32_4mb": [
"adafruit/MAX6675 library"
],
"esp32_4mb3f": [
"adafruit/MAX6675 library"
],
"esp8266_4mb": [
"adafruit/MAX6675 library"
]

View File

@@ -79,6 +79,7 @@
"defActive": false,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32s2_4mb": [
"plerup/EspSoftwareSerial"
],

View File

@@ -51,6 +51,7 @@
"defActive": false,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp8266_4mb": [],
"esp8266_1mb": [],

View File

@@ -128,6 +128,7 @@
"defActive": true,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp8266_4mb": [],
"esp8266_1mb": [],

View File

@@ -64,6 +64,9 @@
"esp32_4mb": [
"rc-switch @ ^2.6.4"
],
"esp32_4mb3f": [
"rc-switch @ ^2.6.4"
],
"esp32cam_4mb": [
"rc-switch @ ^2.6.4"
],

View File

@@ -62,6 +62,9 @@
"esp32_4mb": [
"https://github.com/tremaru/iarduino_RTC"
],
"esp32_4mb3f": [
"https://github.com/tremaru/iarduino_RTC"
],
"esp32cam_4mb": [
"https://github.com/tremaru/iarduino_RTC"
],

View File

@@ -36,6 +36,7 @@
"defActive": true,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp8266_4mb": []
}
}

View File

@@ -74,6 +74,10 @@
"Sensirion I2C SCD4x @0.4.0",
"Sensirion Core @0.6.0"
],
"esp32_4mb3f": [
"Sensirion I2C SCD4x @0.4.0",
"Sensirion Core @0.6.0"
],
"esp32cam_4mb": [
"Sensirion I2C SCD4x @0.4.0",
"Sensirion Core @0.6.0"

View File

@@ -69,6 +69,9 @@
"esp32_4mb": [
"Nova Fitness Sds dust sensors library@1.5.1"
],
"esp32_4mb3f": [
"Nova Fitness Sds dust sensors library@1.5.1"
],
"esp32cam_4mb": [
"Nova Fitness Sds dust sensors library@1.5.1"
],

View File

@@ -51,6 +51,9 @@
"esp32_4mb": [
"sparkfun/SparkFun SGP30 Arduino Library@^1.0.5"
],
"esp32_4mb3f": [
"sparkfun/SparkFun SGP30 Arduino Library@^1.0.5"
],
"esp32cam_4mb": [
"sparkfun/SparkFun SGP30 Arduino Library@^1.0.5"
],

View File

@@ -52,6 +52,9 @@
"esp32_4mb": [
"robtillaart/SHT2x@^0.1.1"
],
"esp32_4mb3f": [
"robtillaart/SHT2x@^0.1.1"
],
"esp8266_4mb": [
"robtillaart/SHT2x@^0.1.1"
],

View File

@@ -52,6 +52,9 @@
"esp32_4mb": [
"WEMOS SHT3x@1.0.0"
],
"esp32_4mb3f": [
"WEMOS SHT3x@1.0.0"
],
"esp32cam_4mb": [
"WEMOS SHT3x@1.0.0"
],

View File

@@ -38,6 +38,7 @@
"defActive": true,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp8266_4mb": [],
"esp8266_1mb": [],

View File

@@ -77,6 +77,9 @@
"esp32_4mb": [
"plerup/EspSoftwareSerial"
],
"esp32_4mb3f": [
"plerup/EspSoftwareSerial"
],
"esp32cam_4mb": [
"plerup/EspSoftwareSerial"
],

View File

@@ -87,6 +87,9 @@
"usedLibs": {
"esp32_4mb": [
"ncmreynolds/ld2410@^0.1.3"
],
"esp32_4mb3f": [
"ncmreynolds/ld2410@^0.1.3"
]
}
}

View File

@@ -50,6 +50,7 @@
"defActive": true,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp32_16mb": [],
"esp32s2_4mb": [],

View File

@@ -59,6 +59,7 @@
"defActive": false,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp32s2_4mb": [],
"esp8266_4mb": []

View File

@@ -51,6 +51,7 @@
"defActive": true,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp32_16mb": [],
"esp32s2_4mb": [],

View File

@@ -44,6 +44,7 @@
"defActive": true,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp32_16mb": [],
"esp32s2_4mb": [],

View File

@@ -74,6 +74,7 @@
"defActive": true,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp32_16mb": [],
"esp32s2_4mb": [],

View File

@@ -36,6 +36,7 @@
"defActive": true,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp32_16mb": [],
"esp32s2_4mb": [],

View File

@@ -96,6 +96,7 @@
"defActive": true,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp32_16mb": [],
"esp32s2_4mb": [],

View File

@@ -35,6 +35,7 @@
"defActive": true,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp32_16mb": [],
"esp32s2_4mb": [],

View File

@@ -3,7 +3,7 @@
#include <ArduinoJson.h>
long prevWeatherMillis = millis() - 60001;
StaticJsonDocument<JSON_BUFFER_SIZE * 2> Weatherdoc;
//StaticJsonDocument<JSON_BUFFER_SIZE * 2> Weatherdoc;
extern IoTGpio IoTgpio;
class Weather : public IoTItem
@@ -12,9 +12,9 @@ private:
String _location;
String _param;
// long interval;
DynamicJsonDocument Weatherdoc;
public:
Weather(String parameters) : IoTItem(parameters)
Weather(String parameters) : Weatherdoc(1024), IoTItem(parameters)
{
_location = jsonReadStr(parameters, "location");
_param = jsonReadStr(parameters, "param");

View File

@@ -40,6 +40,7 @@
"defActive": false,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp32_16mb": [],
"esp32s2_4mb": [],

View File

@@ -54,7 +54,7 @@
"param": "Тип текущего Item: temp - температура, humidity - влажность, pressure - давление, speed - скорость ветра, deg - направление ветра, all - процент облачности, sunrise - рассвет, sunset - закат, description - Погодные условия, icon - код иконки, name - город. Если оставить пустым пудет искать и публиковать при изменении в Items с именами wea_temp и т.д. wea_...",
"int": "Интервал запроса погоды в минутах",
"API_key": "API ключ",
"сity": "Название города, через запятую можно уочнить код страны. Наример Moscow или Moscow,ru или Москва. Если город не задан будут использоваться координаты. OWM рекомендует координаты",
"city": "Название города, через запятую можно уочнить код страны. Наример Moscow или Moscow,ru или Москва. Если город не задан будут использоваться координаты. OWM рекомендует координаты",
"lon": "Долгота, при использовании координат, будет автоматически выбран ближайший город",
"lat": "Широта, при использовании координат, будет автоматически выбран ближайший город",
"lang": "Язык используемый в ответах OpenWetaherMap",
@@ -64,6 +64,7 @@
"defActive": false,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32s2_4mb": [],
"esp32_16mb": []
}

View File

@@ -4,7 +4,7 @@
#include "NTP.h"
// long prevWeatherMillis = millis() - 60001;
// TODO Зачем так много???
StaticJsonDocument<JSON_BUFFER_SIZE * 2> Weatherdoc1;
// StaticJsonDocument<JSON_BUFFER_SIZE * 2> Weatherdoc1;
extern IoTGpio IoTgpio;
class owmWeather : public IoTItem
@@ -21,17 +21,19 @@ private:
String _lon = "";
String _lang = "";
bool _debug = false;
DynamicJsonDocument Weatherdoc1;
public:
owmWeather(String parameters) : IoTItem(parameters)
owmWeather(String parameters) : Weatherdoc1(1024), IoTItem(parameters)
{
_API_key = jsonReadStr(parameters, "API_key");
// _ID_sity = jsonReadStr(parameters, "ID_sity");
_city = jsonReadStr(parameters, "city");
_lon = jsonReadStr(parameters, "lon");
_lat = jsonReadStr(parameters, "lat");
_lang = jsonReadStr(parameters, "lang");
_param = jsonReadStr(parameters, "param");
if (!jsonRead(parameters, "city", _city))
_city = "";
jsonRead(parameters, "lon", _lon);
jsonRead(parameters, "lat", _lat);
jsonRead(parameters, "lang", _lang);
jsonRead(parameters, "param", _param);
jsonRead(parameters, "debug", _debug);
long interval;
jsonRead(parameters, F("int"), interval); // в минутах
@@ -79,7 +81,8 @@ public:
payload = http.getString();
deserializeJson(Weatherdoc1, payload);
ret += payload;
// ret += payload;
SerialPrint("i", "Weatherdoc1", "memoryUsage: " + String(Weatherdoc1.memoryUsage()));
}
}
else
@@ -181,7 +184,7 @@ public:
}
// проверяем если пришедшее значение отличается от предыдущего регистрируем событие
static void publishNew(String root, String param)
void publishNew(String root, String param)
{
IoTItem *tmp = findIoTItem("wea_" + param);
if (!tmp)