This commit is contained in:
Dmitry Borisenko
2022-10-07 22:29:12 +02:00
parent b44e7c3ae0
commit 5812d98ff9
8 changed files with 87 additions and 133 deletions

View File

@@ -276,58 +276,7 @@
"num": 20 "num": 20
}, },
{ {
"name": "21. Частотомер на ADC, Частота", "name": "21. GY21 Температура",
"type": "Reading",
"subtype": "FreqMeterF",
"id": "freq",
"widget": "anydataHtz",
"page": "Частотомер",
"descr": "Частота",
"plus": 0,
"multiply": 1,
"round": 1,
"pin-Esp32": 33,
"samples": 512,
"samplingFrequency": 5000,
"int": 5,
"num": 21
},
{
"name": "22. Частотомер на ADC, Процент Пульсации",
"type": "Reading",
"subtype": "FreqMeterPcFl",
"id": "pctFlicker",
"widget": "anydataPct",
"page": "Частотомер",
"descr": "Процент Пульсации",
"plus": 0,
"multiply": 1,
"round": 1,
"pin-Esp32": 33,
"samples": 512,
"samplingFrequency": 5000,
"int": 5,
"num": 22
},
{
"name": "23. Частотомер на ADC, Индекс Пульсации",
"type": "Reading",
"subtype": "FreqMeterFlIn",
"id": "flickerIndex",
"widget": "anydataDef",
"page": "Частотомер",
"descr": "Индекс Пульсации",
"plus": 0,
"multiply": 1,
"round": 10,
"pin-Esp32": 33,
"samples": 512,
"samplingFrequency": 5000,
"int": 5,
"num": 23
},
{
"name": "24. GY21 Температура",
"type": "Reading", "type": "Reading",
"subtype": "GY21t", "subtype": "GY21t",
"id": "tmp4", "id": "tmp4",
@@ -336,10 +285,10 @@
"descr": "Температура", "descr": "Температура",
"round": 1, "round": 1,
"int": 15, "int": 15,
"num": 24 "num": 21
}, },
{ {
"name": "25. GY21 Влажность", "name": "22. GY21 Влажность",
"type": "Reading", "type": "Reading",
"subtype": "GY21h", "subtype": "GY21h",
"id": "Hum4", "id": "Hum4",
@@ -348,10 +297,10 @@
"descr": "Влажность", "descr": "Влажность",
"round": 1, "round": 1,
"int": 15, "int": 15,
"num": 25 "num": 22
}, },
{ {
"name": "26. HDC1080 Температура", "name": "23. HDC1080 Температура",
"type": "Reading", "type": "Reading",
"subtype": "Hdc1080t", "subtype": "Hdc1080t",
"id": "Temp1080", "id": "Temp1080",
@@ -361,10 +310,10 @@
"int": 15, "int": 15,
"addr": "0x40", "addr": "0x40",
"round": 1, "round": 1,
"num": 26 "num": 23
}, },
{ {
"name": "27. HDC1080 Влажность", "name": "24. HDC1080 Влажность",
"type": "Reading", "type": "Reading",
"subtype": "Hdc1080h", "subtype": "Hdc1080h",
"id": "Hum1080", "id": "Hum1080",
@@ -374,10 +323,10 @@
"int": 15, "int": 15,
"addr": "0x40", "addr": "0x40",
"round": 1, "round": 1,
"num": 27 "num": 24
}, },
{ {
"name": "28. MAX6675 Температура", "name": "25. MAX6675 Температура",
"type": "Reading", "type": "Reading",
"subtype": "Max6675t", "subtype": "Max6675t",
"id": "maxtmp", "id": "maxtmp",
@@ -388,10 +337,10 @@
"DO": 12, "DO": 12,
"CS": 13, "CS": 13,
"CLK": 14, "CLK": 14,
"num": 28 "num": 25
}, },
{ {
"name": "29. PZEM 004t Напряжение", "name": "26. PZEM 004t Напряжение",
"type": "Reading", "type": "Reading",
"subtype": "Pzem004v", "subtype": "Pzem004v",
"id": "v", "id": "v",
@@ -401,10 +350,10 @@
"int": 15, "int": 15,
"addr": "0xF8", "addr": "0xF8",
"round": 1, "round": 1,
"num": 29 "num": 26
}, },
{ {
"name": "30. PZEM 004t Сила тока", "name": "27. PZEM 004t Сила тока",
"type": "Reading", "type": "Reading",
"subtype": "Pzem004a", "subtype": "Pzem004a",
"id": "a", "id": "a",
@@ -414,10 +363,10 @@
"int": 15, "int": 15,
"addr": "0xF8", "addr": "0xF8",
"round": 1, "round": 1,
"num": 30 "num": 27
}, },
{ {
"name": "31. PZEM 004t Мощность", "name": "28. PZEM 004t Мощность",
"type": "Reading", "type": "Reading",
"subtype": "Pzem004w", "subtype": "Pzem004w",
"id": "w", "id": "w",
@@ -427,10 +376,10 @@
"int": 15, "int": 15,
"addr": "0xF8", "addr": "0xF8",
"round": 1, "round": 1,
"num": 31 "num": 28
}, },
{ {
"name": "32. PZEM 004t Энергия", "name": "29. PZEM 004t Энергия",
"type": "Reading", "type": "Reading",
"subtype": "Pzem004wh", "subtype": "Pzem004wh",
"id": "wh", "id": "wh",
@@ -440,10 +389,10 @@
"int": 15, "int": 15,
"addr": "0xF8", "addr": "0xF8",
"round": 1, "round": 1,
"num": 32 "num": 29
}, },
{ {
"name": "33. PZEM 004t Частота", "name": "30. PZEM 004t Частота",
"type": "Reading", "type": "Reading",
"subtype": "Pzem004hz", "subtype": "Pzem004hz",
"id": "hz", "id": "hz",
@@ -453,10 +402,10 @@
"int": 15, "int": 15,
"addr": "0xF8", "addr": "0xF8",
"round": 1, "round": 1,
"num": 33 "num": 30
}, },
{ {
"name": "34. PZEM 004t Косинус", "name": "31. PZEM 004t Косинус",
"type": "Reading", "type": "Reading",
"subtype": "Pzem004pf", "subtype": "Pzem004pf",
"id": "pf", "id": "pf",
@@ -466,11 +415,11 @@
"int": 15, "int": 15,
"addr": "0xF8", "addr": "0xF8",
"round": 1, "round": 1,
"num": 34 "num": 31
}, },
{ {
"name": "35. Сканер кнопок 433 MHz", "name": "32. Сканер кнопок 433 MHz",
"num": 35, "num": 32,
"type": "Reading", "type": "Reading",
"subtype": "RCswitch", "subtype": "RCswitch",
"id": "rsw", "id": "rsw",
@@ -479,7 +428,7 @@
"pinTx": 12 "pinTx": 12
}, },
{ {
"name": "36. Sht20 Температура", "name": "33. Sht20 Температура",
"type": "Reading", "type": "Reading",
"subtype": "Sht20t", "subtype": "Sht20t",
"id": "tmp2", "id": "tmp2",
@@ -488,10 +437,10 @@
"descr": "Температура", "descr": "Температура",
"int": 15, "int": 15,
"round": 1, "round": 1,
"num": 36 "num": 33
}, },
{ {
"name": "37. Sht20 Влажность", "name": "34. Sht20 Влажность",
"type": "Reading", "type": "Reading",
"subtype": "Sht20h", "subtype": "Sht20h",
"id": "Hum2", "id": "Hum2",
@@ -500,10 +449,10 @@
"descr": "Влажность", "descr": "Влажность",
"int": 15, "int": 15,
"round": 1, "round": 1,
"num": 37 "num": 34
}, },
{ {
"name": "38. Sht30 Температура", "name": "35. Sht30 Температура",
"type": "Reading", "type": "Reading",
"subtype": "Sht30t", "subtype": "Sht30t",
"id": "tmp30", "id": "tmp30",
@@ -512,10 +461,10 @@
"descr": "SHT30 Температура", "descr": "SHT30 Температура",
"int": 15, "int": 15,
"round": 1, "round": 1,
"num": 38 "num": 35
}, },
{ {
"name": "39. Sht30 Влажность", "name": "36. Sht30 Влажность",
"type": "Reading", "type": "Reading",
"subtype": "Sht30h", "subtype": "Sht30h",
"id": "Hum30", "id": "Hum30",
@@ -524,11 +473,11 @@
"descr": "SHT30 Влажность", "descr": "SHT30 Влажность",
"int": 15, "int": 15,
"round": 1, "round": 1,
"num": 39 "num": 36
}, },
{ {
"name": "40. HC-SR04 Ультразвуковой дальномер", "name": "37. HC-SR04 Ультразвуковой дальномер",
"num": 40, "num": 37,
"type": "Reading", "type": "Reading",
"subtype": "Sonar", "subtype": "Sonar",
"id": "sonar", "id": "sonar",
@@ -540,7 +489,7 @@
"int": 5 "int": 5
}, },
{ {
"name": "41. UART", "name": "38. UART",
"type": "Reading", "type": "Reading",
"subtype": "UART", "subtype": "UART",
"page": "", "page": "",
@@ -550,13 +499,13 @@
"tx": 12, "tx": 12,
"rx": 13, "rx": 13,
"speed": 9600, "speed": 9600,
"num": 41 "num": 38
}, },
{ {
"header": "Исполнительные устройства" "header": "Исполнительные устройства"
}, },
{ {
"name": "42. Кнопка подключенная к пину", "name": "39. Кнопка подключенная к пину",
"type": "Writing", "type": "Writing",
"subtype": "ButtonIn", "subtype": "ButtonIn",
"id": "btn", "id": "btn",
@@ -569,10 +518,10 @@
"pinMode": "INPUT", "pinMode": "INPUT",
"debounceDelay": 50, "debounceDelay": 50,
"fixState": 0, "fixState": 0,
"num": 42 "num": 39
}, },
{ {
"name": "43. Управление пином", "name": "40. Управление пином",
"type": "Writing", "type": "Writing",
"subtype": "ButtonOut", "subtype": "ButtonOut",
"id": "btn", "id": "btn",
@@ -582,10 +531,10 @@
"int": 0, "int": 0,
"inv": 0, "inv": 0,
"pin": 2, "pin": 2,
"num": 43 "num": 40
}, },
{ {
"name": "44. Сервопривод", "name": "41. Сервопривод",
"type": "Writing", "type": "Writing",
"subtype": "IoTServo", "subtype": "IoTServo",
"id": "servo", "id": "servo",
@@ -596,10 +545,10 @@
"pin": 12, "pin": 12,
"apin": -1, "apin": -1,
"amap": "0, 4096, 0, 180", "amap": "0, 4096, 0, 180",
"num": 44 "num": 41
}, },
{ {
"name": "45. Расширитель портов Mcp23017", "name": "42. Расширитель портов Mcp23017",
"type": "Reading", "type": "Reading",
"subtype": "Mcp23017", "subtype": "Mcp23017",
"id": "Mcp", "id": "Mcp",
@@ -609,10 +558,10 @@
"int": "0", "int": "0",
"addr": "0x20", "addr": "0x20",
"index": 1, "index": 1,
"num": 45 "num": 42
}, },
{ {
"name": "46. MP3 плеер", "name": "43. MP3 плеер",
"type": "Reading", "type": "Reading",
"subtype": "Mp3", "subtype": "Mp3",
"id": "mp3", "id": "mp3",
@@ -622,10 +571,10 @@
"int": 1, "int": 1,
"pins": "14,12", "pins": "14,12",
"volume": 20, "volume": 20,
"num": 46 "num": 43
}, },
{ {
"name": "47. Расширитель портов Pcf8574", "name": "44. Расширитель портов Pcf8574",
"type": "Reading", "type": "Reading",
"subtype": "Pcf8574", "subtype": "Pcf8574",
"id": "Pcf", "id": "Pcf",
@@ -635,10 +584,10 @@
"int": "0", "int": "0",
"addr": "0x20", "addr": "0x20",
"index": 1, "index": 1,
"num": 47 "num": 44
}, },
{ {
"name": "48. PWM ESP8266", "name": "45. PWM ESP8266",
"type": "Writing", "type": "Writing",
"subtype": "Pwm8266", "subtype": "Pwm8266",
"id": "pwm", "id": "pwm",
@@ -650,10 +599,10 @@
"freq": 5000, "freq": 5000,
"val": 0, "val": 0,
"apin": -1, "apin": -1,
"num": 48 "num": 45
}, },
{ {
"name": "49. Телеграм-Лайт", "name": "46. Телеграм-Лайт",
"type": "Writing", "type": "Writing",
"subtype": "TelegramLT", "subtype": "TelegramLT",
"id": "tg", "id": "tg",
@@ -662,13 +611,13 @@
"descr": "", "descr": "",
"token": "", "token": "",
"chatID": "", "chatID": "",
"num": 49 "num": 46
}, },
{ {
"header": "Экраны" "header": "Экраны"
}, },
{ {
"name": "50. LCD экран 2004", "name": "47. LCD экран 2004",
"type": "Reading", "type": "Reading",
"subtype": "Lcd2004", "subtype": "Lcd2004",
"id": "Lcd", "id": "Lcd",
@@ -680,10 +629,10 @@
"size": "20,4", "size": "20,4",
"coord": "0,0", "coord": "0,0",
"id2show": "id датчика", "id2show": "id датчика",
"num": 50 "num": 47
}, },
{ {
"name": "51. LCD экран 1602", "name": "48. LCD экран 1602",
"type": "Reading", "type": "Reading",
"subtype": "Lcd2004", "subtype": "Lcd2004",
"id": "Lcd", "id": "Lcd",
@@ -695,6 +644,6 @@
"size": "16,2", "size": "16,2",
"coord": "0,0", "coord": "0,0",
"id2show": "id датчика", "id2show": "id датчика",
"num": 51 "num": 48
} }
] ]

View File

@@ -247,7 +247,7 @@ bool WebSocketsServerCore::sendBIN(uint8_t num, const uint8_t * payload, size_t
* @param headerToPayload bool (see sendFrame for more details) * @param headerToPayload bool (see sendFrame for more details)
* @return true if ok * @return true if ok
*/ */
bool WebSocketsServerCore::broadcastBIN(uint8_t * payload, size_t length, bool headerToPayload) { bool WebSocketsServerCore::broadcastBIN(uint8_t * payload, size_t length, bool fin, bool headerToPayload) {
WSclient_t * client; WSclient_t * client;
bool ret = true; bool ret = true;
for(uint8_t i = 0; i < WEBSOCKETS_SERVER_CLIENT_MAX; i++) { for(uint8_t i = 0; i < WEBSOCKETS_SERVER_CLIENT_MAX; i++) {

View File

@@ -68,7 +68,7 @@ class WebSocketsServerCore : protected WebSockets {
bool sendBIN(uint8_t num, uint8_t * payload, size_t length, bool fin = true, bool headerToPayload = false); bool sendBIN(uint8_t num, uint8_t * payload, size_t length, bool fin = true, bool headerToPayload = false);
bool sendBIN(uint8_t num, const uint8_t * payload, size_t length); bool sendBIN(uint8_t num, const uint8_t * payload, size_t length);
bool broadcastBIN(uint8_t * payload, size_t length, bool headerToPayload = false); bool broadcastBIN(uint8_t * payload, size_t length, bool fin = true, bool headerToPayload = false);
bool broadcastBIN(const uint8_t * payload, size_t length); bool broadcastBIN(const uint8_t * payload, size_t length);
bool sendPing(uint8_t num, uint8_t * payload = NULL, size_t length = 0); bool sendPing(uint8_t num, uint8_t * payload = NULL, size_t length = 0);

View File

@@ -90,7 +90,7 @@
}, },
{ {
"path": "src/modules/sensors/FreqMeter", "path": "src/modules/sensors/FreqMeter",
"active": true "active": false
}, },
{ {
"path": "src/modules/sensors/GY21", "path": "src/modules/sensors/GY21",

View File

@@ -9,7 +9,7 @@ board = nodemcuv2
board_build.ldscript = eagle.flash.4m1m.ld board_build.ldscript = eagle.flash.4m1m.ld
platform = espressif8266 @4.0.1 platform = espressif8266 @4.0.1
monitor_filters = esp8266_exception_decoder monitor_filters = esp8266_exception_decoder
upload_speed = 115200 upload_speed = 921600
monitor_speed = 115200 monitor_speed = 115200
board_build.filesystem = littlefs board_build.filesystem = littlefs
build_src_filter = build_src_filter =
@@ -29,6 +29,7 @@ framework = arduino
board = esp32dev board = esp32dev
platform = espressif32 @5.1.1 platform = espressif32 @5.1.1
monitor_filters = esp32_exception_decoder monitor_filters = esp32_exception_decoder
upload_speed = 921600
monitor_speed = 115200 monitor_speed = 115200
debug_tool = esp-prog debug_tool = esp-prog
board_build.filesystem = littlefs board_build.filesystem = littlefs
@@ -56,11 +57,9 @@ lib_deps =
adafruit/Adafruit BMP280 Library adafruit/Adafruit BMP280 Library
beegee-tokyo/DHT sensor library for ESPx beegee-tokyo/DHT sensor library for ESPx
milesburton/DallasTemperature@^3.9.1 milesburton/DallasTemperature@^3.9.1
kosme/arduinoFFT@^1.5.6
https://github.com/JonasGMorsch/GY-21.git https://github.com/JonasGMorsch/GY-21.git
ClosedCube HDC1080 ClosedCube HDC1080
adafruit/MAX6675 library adafruit/MAX6675 library
https://github.com/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
@@ -83,7 +82,6 @@ build_src_filter =
+<modules/sensors/Bmp280> +<modules/sensors/Bmp280>
+<modules/sensors/Dht1122> +<modules/sensors/Dht1122>
+<modules/sensors/Ds18b20> +<modules/sensors/Ds18b20>
+<modules/sensors/FreqMeter>
+<modules/sensors/GY21> +<modules/sensors/GY21>
+<modules/sensors/Hdc1080> +<modules/sensors/Hdc1080>
+<modules/sensors/Max6675> +<modules/sensors/Max6675>

View File

@@ -181,10 +181,10 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
// Страница веб интерфейса dev // Страница веб интерфейса dev
//----------------------------------------------------------------------// //----------------------------------------------------------------------//
if (headerStr == "/dev|") { if (headerStr == "/dev|") {
standWebSocket.sendTXT(num, errorsHeapJson); // standWebSocket.sendTXT(num, errorsHeapJson);
standWebSocket.sendTXT(num, settingsFlashJson); // standWebSocket.sendTXT(num, settingsFlashJson);
sendFileToWs("/config.json", num, 1024); // sendFileToWs("/config.json", num, 1024);
sendFileToWs("/items.json", num, 1024); // sendFileToWs("/items.json", num, 1024);
} }
//----------------------------------------------------------------------// //----------------------------------------------------------------------//
@@ -222,7 +222,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
} }
if (headerStr == "/test|") { if (headerStr == "/test|") {
sendBlobToWsStrHeader("/layout.json", "layout|0000|", num, 1024); sendBlobToWsStrHeader("/items.json", "layout|0000|", num, 2048);
} }
} break; } break;
@@ -264,11 +264,11 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
//публикация статус сообщений (недостаток в том что делаем бродкаст всем клиентам поднятым в свелте!!!) //публикация статус сообщений (недостаток в том что делаем бродкаст всем клиентам поднятым в свелте!!!)
void publishStatusWs(const String& topic, const String& data) { void publishStatusWs(const String& topic, const String& data) {
String path = mqttRootDevice + "/" + topic; // String path = mqttRootDevice + "/" + topic;
String json = "{}"; // String json = "{}";
jsonWriteStr(json, "status", data); // jsonWriteStr(json, "status", data);
jsonWriteStr(json, "topic", path); // jsonWriteStr(json, "topic", path);
standWebSocket.broadcastTXT(json); // standWebSocket.broadcastTXT(json);
} }
//публикация статус сообщений //публикация статус сообщений
@@ -292,9 +292,9 @@ void publishChartWs(int num, String& path) {
//данные которые мы отправляем в сокеты переодически //данные которые мы отправляем в сокеты переодически
void periodicWsSend() { void periodicWsSend() {
standWebSocket.broadcastTXT(devListHeapJson); // standWebSocket.broadcastTXT(devListHeapJson);
standWebSocket.broadcastTXT(ssidListHeapJson); // standWebSocket.broadcastTXT(ssidListHeapJson);
standWebSocket.broadcastTXT(errorsHeapJson); // standWebSocket.broadcastTXT(errorsHeapJson);
} }
#ifdef ESP32 #ifdef ESP32
@@ -427,14 +427,23 @@ void sendBlobToWsStrHeader(const String& filename, const String& header, uint8_t
auto payloadBuf = &frameBuf[headerSize]; auto payloadBuf = &frameBuf[headerSize];
// и сколько осталось места для нее // и сколько осталось места для нее
auto maxPayloadSize = frameSize - headerSize; auto maxPayloadSize = frameSize - headerSize;
int i = 0;
while (file.available()) { while (file.available()) {
// прочитаем кусок в буфер // прочитаем кусок в буфер
size_t payloadSize = file.read(payloadBuf, maxPayloadSize); size_t payloadSize = file.read(payloadBuf, maxPayloadSize);
if (payloadSize) { if (payloadSize) {
// отправим фрейм size_t size = headerSize + payloadSize;
standWebSocket.sendBIN(client_id, frameBuf, headerSize + payloadSize, true); bool fin = false;
if (i == 16) {
fin = true;
} else {
fin = false;
}
SerialPrint("I", "FS", String(size) + " " + String(fin) + " " + String(i));
standWebSocket.sendBIN(client_id, frameBuf, size, fin);
} }
i++;
} }
} }

View File

@@ -12,7 +12,6 @@ void* getAPI_Bme280(String subtype, String params);
void* getAPI_Bmp280(String subtype, String params); void* getAPI_Bmp280(String subtype, String params);
void* getAPI_Dht1122(String subtype, String params); void* getAPI_Dht1122(String subtype, String params);
void* getAPI_Ds18b20(String subtype, String params); void* getAPI_Ds18b20(String subtype, String params);
void* getAPI_FreqMeter(String subtype, String params);
void* getAPI_GY21(String subtype, String params); void* getAPI_GY21(String subtype, String params);
void* getAPI_Hdc1080(String subtype, String params); void* getAPI_Hdc1080(String subtype, String params);
void* getAPI_Max6675(String subtype, String params); void* getAPI_Max6675(String subtype, String params);
@@ -46,7 +45,6 @@ if ((tmpAPI = getAPI_Bme280(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Bmp280(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Bmp280(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Dht1122(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Dht1122(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Ds18b20(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Ds18b20(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_FreqMeter(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_GY21(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_Hdc1080(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Max6675(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Max6675(subtype, params)) != nullptr) return tmpAPI;

View File

@@ -79,7 +79,7 @@
"int": "Количество секунд между опросами датчика." "int": "Количество секунд между опросами датчика."
} }
}, },
"defActive": true, "defActive": false,
"usedLibs": { "usedLibs": {
"esp32_4mb": [ "esp32_4mb": [
"kosme/arduinoFFT@^1.5.6" "kosme/arduinoFFT@^1.5.6"