mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -8,6 +8,7 @@
|
||||
"vector": "cpp",
|
||||
"string_view": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"ranges": "cpp"
|
||||
"ranges": "cpp",
|
||||
"thread": "cpp"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -4,12 +4,12 @@
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
|
||||
<title>IoT Manager 4.3.4</title>
|
||||
<title>IoT Manager 4.3.5</title>
|
||||
|
||||
<link rel="icon" type="image/png" href="/favicon.ico" />
|
||||
<link rel="stylesheet" href="/build/bundle.css?434" />
|
||||
<link rel="stylesheet" href="/build/bundle.css?435" />
|
||||
|
||||
<script defer src="/build/bundle.js?434"></script>
|
||||
<script defer src="/build/bundle.js?435"></script>
|
||||
</head>
|
||||
|
||||
<body></body>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"header": "Виртуальные элементы"
|
||||
},
|
||||
{
|
||||
"name": "1. Логирование в график",
|
||||
"name": "1. График",
|
||||
"type": "Writing",
|
||||
"subtype": "Loging",
|
||||
"id": "log",
|
||||
@@ -20,7 +20,20 @@
|
||||
"points": 300
|
||||
},
|
||||
{
|
||||
"name": "2. Таймер",
|
||||
"name": "2. График дневного расхода",
|
||||
"type": "Writing",
|
||||
"subtype": "LogingDaily",
|
||||
"id": "log",
|
||||
"widget": "chart3",
|
||||
"page": "Графики",
|
||||
"descr": "Температура",
|
||||
"num": 2,
|
||||
"int": 1,
|
||||
"logid": "t",
|
||||
"points": 365
|
||||
},
|
||||
{
|
||||
"name": "3. Таймер",
|
||||
"type": "Writing",
|
||||
"subtype": "Timer",
|
||||
"id": "timer",
|
||||
@@ -32,10 +45,10 @@
|
||||
"ticker": 1,
|
||||
"repeat": 1,
|
||||
"needSave": 0,
|
||||
"num": 2
|
||||
"num": 3
|
||||
},
|
||||
{
|
||||
"name": "3. Окно ввода числа (переменная)",
|
||||
"name": "4. Окно ввода числа (переменная)",
|
||||
"type": "Reading",
|
||||
"subtype": "Variable",
|
||||
"id": "value",
|
||||
@@ -44,10 +57,10 @@
|
||||
"descr": "Введите число",
|
||||
"int": "0",
|
||||
"val": "0.0",
|
||||
"num": 3
|
||||
"num": 4
|
||||
},
|
||||
{
|
||||
"name": "4. Окно ввода времени",
|
||||
"name": "5. Окно ввода времени",
|
||||
"type": "Reading",
|
||||
"subtype": "Variable",
|
||||
"id": "time",
|
||||
@@ -56,10 +69,10 @@
|
||||
"descr": "Введите время",
|
||||
"int": "0",
|
||||
"val": "02:00",
|
||||
"num": 4
|
||||
"num": 5
|
||||
},
|
||||
{
|
||||
"name": "5. Окно ввода даты",
|
||||
"name": "6. Окно ввода даты",
|
||||
"type": "Reading",
|
||||
"subtype": "Variable",
|
||||
"id": "time",
|
||||
@@ -68,10 +81,10 @@
|
||||
"descr": "Введите дату",
|
||||
"int": "0",
|
||||
"val": "24.05.2022",
|
||||
"num": 5
|
||||
"num": 6
|
||||
},
|
||||
{
|
||||
"name": "6. Окно ввода текста",
|
||||
"name": "7. Окно ввода текста",
|
||||
"type": "Reading",
|
||||
"subtype": "Variable",
|
||||
"id": "txt",
|
||||
@@ -80,10 +93,10 @@
|
||||
"descr": "Введите текст",
|
||||
"int": "0",
|
||||
"val": "текст",
|
||||
"num": 6
|
||||
"num": 7
|
||||
},
|
||||
{
|
||||
"name": "7. Виртуальная кнопка",
|
||||
"name": "8. Виртуальная кнопка",
|
||||
"type": "Reading",
|
||||
"subtype": "VButton",
|
||||
"id": "vbtn",
|
||||
@@ -92,13 +105,26 @@
|
||||
"descr": "Кнопка",
|
||||
"int": "0",
|
||||
"val": "0",
|
||||
"num": 7
|
||||
"num": 8
|
||||
},
|
||||
{
|
||||
"header": "Сенсоры"
|
||||
},
|
||||
{
|
||||
"name": "8. AHT20 Температура",
|
||||
"name": "9. Acs712 Ток",
|
||||
"type": "Reading",
|
||||
"subtype": "Acs712",
|
||||
"id": "amp",
|
||||
"widget": "anydataAmp",
|
||||
"page": "Сенсоры",
|
||||
"descr": "Ток",
|
||||
"round": 3,
|
||||
"pin": 39,
|
||||
"int": 5,
|
||||
"num": 9
|
||||
},
|
||||
{
|
||||
"name": "10. AHT20 Температура",
|
||||
"type": "Reading",
|
||||
"subtype": "Aht20t",
|
||||
"id": "Temp20",
|
||||
@@ -108,10 +134,10 @@
|
||||
"int": 15,
|
||||
"addr": "0x38",
|
||||
"round": 1,
|
||||
"num": 8
|
||||
"num": 10
|
||||
},
|
||||
{
|
||||
"name": "9. AHT20 Влажность",
|
||||
"name": "11. AHT20 Влажность",
|
||||
"type": "Reading",
|
||||
"subtype": "Aht20h",
|
||||
"id": "Hum20",
|
||||
@@ -121,10 +147,10 @@
|
||||
"int": 15,
|
||||
"addr": "0x38",
|
||||
"round": 1,
|
||||
"num": 9
|
||||
"num": 11
|
||||
},
|
||||
{
|
||||
"name": "10. Аналоговый сенсор",
|
||||
"name": "12. Аналоговый сенсор",
|
||||
"type": "Reading",
|
||||
"subtype": "AnalogAdc",
|
||||
"id": "t",
|
||||
@@ -138,10 +164,10 @@
|
||||
"pin": 0,
|
||||
"int": 15,
|
||||
"avgSteps": 1,
|
||||
"num": 10
|
||||
"num": 12
|
||||
},
|
||||
{
|
||||
"name": "11. BME280 Температура",
|
||||
"name": "13. BME280 Температура",
|
||||
"type": "Reading",
|
||||
"subtype": "Bme280t",
|
||||
"id": "tmp3",
|
||||
@@ -151,10 +177,10 @@
|
||||
"int": 15,
|
||||
"addr": "0x77",
|
||||
"round": 1,
|
||||
"num": 11
|
||||
"num": 13
|
||||
},
|
||||
{
|
||||
"name": "12. BME280 Давление",
|
||||
"name": "14. BME280 Давление",
|
||||
"type": "Reading",
|
||||
"subtype": "Bme280p",
|
||||
"id": "Press3",
|
||||
@@ -164,10 +190,10 @@
|
||||
"int": 15,
|
||||
"addr": "0x77",
|
||||
"round": 1,
|
||||
"num": 12
|
||||
"num": 14
|
||||
},
|
||||
{
|
||||
"name": "13. BME280 Влажность",
|
||||
"name": "15. BME280 Влажность",
|
||||
"type": "Reading",
|
||||
"subtype": "Bme280h",
|
||||
"id": "Hum3",
|
||||
@@ -177,10 +203,10 @@
|
||||
"int": 15,
|
||||
"addr": "0x77",
|
||||
"round": 1,
|
||||
"num": 13
|
||||
"num": 15
|
||||
},
|
||||
{
|
||||
"name": "14. BMP280 Температура",
|
||||
"name": "16. BMP280 Температура",
|
||||
"type": "Reading",
|
||||
"subtype": "Bmp280t",
|
||||
"id": "tmp3",
|
||||
@@ -190,10 +216,10 @@
|
||||
"int": 15,
|
||||
"addr": "0x77",
|
||||
"round": 1,
|
||||
"num": 14
|
||||
"num": 16
|
||||
},
|
||||
{
|
||||
"name": "15. BMP280 Давление",
|
||||
"name": "17. BMP280 Давление",
|
||||
"type": "Reading",
|
||||
"subtype": "Bmp280p",
|
||||
"id": "Press3",
|
||||
@@ -203,10 +229,10 @@
|
||||
"int": 15,
|
||||
"addr": "0x77",
|
||||
"round": 1,
|
||||
"num": 15
|
||||
"num": 17
|
||||
},
|
||||
{
|
||||
"name": "16. DHT11 Температура",
|
||||
"name": "18. DHT11 Температура",
|
||||
"type": "Reading",
|
||||
"subtype": "Dht1122t",
|
||||
"id": "tmp3",
|
||||
@@ -216,10 +242,10 @@
|
||||
"int": 15,
|
||||
"pin": 0,
|
||||
"senstype": "dht11",
|
||||
"num": 16
|
||||
"num": 18
|
||||
},
|
||||
{
|
||||
"name": "17. DHT11 Влажность",
|
||||
"name": "19. DHT11 Влажность",
|
||||
"type": "Reading",
|
||||
"subtype": "Dht1122h",
|
||||
"id": "Hum3",
|
||||
@@ -229,10 +255,10 @@
|
||||
"int": 15,
|
||||
"pin": 0,
|
||||
"senstype": "dht11",
|
||||
"num": 17
|
||||
"num": 19
|
||||
},
|
||||
{
|
||||
"name": "18. DS18B20 Температура",
|
||||
"name": "20. DS18B20 Температура",
|
||||
"type": "Reading",
|
||||
"subtype": "Ds18b20",
|
||||
"id": "dstmp",
|
||||
@@ -244,10 +270,10 @@
|
||||
"index": 0,
|
||||
"addr": "",
|
||||
"round": 1,
|
||||
"num": 18
|
||||
"num": 20
|
||||
},
|
||||
{
|
||||
"name": "19. GY21 Температура",
|
||||
"name": "21. GY21 Температура",
|
||||
"type": "Reading",
|
||||
"subtype": "GY21t",
|
||||
"id": "tmp4",
|
||||
@@ -256,10 +282,10 @@
|
||||
"descr": "Температура",
|
||||
"round": 1,
|
||||
"int": 15,
|
||||
"num": 19
|
||||
"num": 21
|
||||
},
|
||||
{
|
||||
"name": "20. GY21 Влажность",
|
||||
"name": "22. GY21 Влажность",
|
||||
"type": "Reading",
|
||||
"subtype": "GY21h",
|
||||
"id": "Hum4",
|
||||
@@ -268,10 +294,10 @@
|
||||
"descr": "Влажность",
|
||||
"round": 1,
|
||||
"int": 15,
|
||||
"num": 20
|
||||
"num": 22
|
||||
},
|
||||
{
|
||||
"name": "21. HDC1080 Температура",
|
||||
"name": "23. HDC1080 Температура",
|
||||
"type": "Reading",
|
||||
"subtype": "Hdc1080t",
|
||||
"id": "Temp1080",
|
||||
@@ -281,10 +307,10 @@
|
||||
"int": 15,
|
||||
"addr": "0x40",
|
||||
"round": 1,
|
||||
"num": 21
|
||||
"num": 23
|
||||
},
|
||||
{
|
||||
"name": "22. HDC1080 Влажность",
|
||||
"name": "24. HDC1080 Влажность",
|
||||
"type": "Reading",
|
||||
"subtype": "Hdc1080h",
|
||||
"id": "Hum1080",
|
||||
@@ -294,10 +320,10 @@
|
||||
"int": 15,
|
||||
"addr": "0x40",
|
||||
"round": 1,
|
||||
"num": 22
|
||||
"num": 24
|
||||
},
|
||||
{
|
||||
"name": "23. MAX6675 Температура",
|
||||
"name": "25. MAX6675 Температура",
|
||||
"type": "Reading",
|
||||
"subtype": "Max6675t",
|
||||
"id": "maxtmp",
|
||||
@@ -308,71 +334,71 @@
|
||||
"DO": 12,
|
||||
"CS": 13,
|
||||
"CLK": 14,
|
||||
"num": 23
|
||||
"num": 25
|
||||
},
|
||||
{
|
||||
"name": "24. PZEM 004t Напряжение",
|
||||
"name": "26. PZEM 004t Напряжение",
|
||||
"type": "Reading",
|
||||
"subtype": "Pzem004v",
|
||||
"id": "V",
|
||||
"id": "v",
|
||||
"widget": "anydataVlt",
|
||||
"page": "Сенсоры",
|
||||
"descr": "Напряжение",
|
||||
"int": 15,
|
||||
"addr": "0xF8",
|
||||
"num": 24
|
||||
"num": 26
|
||||
},
|
||||
{
|
||||
"name": "25. PZEM 004t Сила тока",
|
||||
"name": "27. PZEM 004t Сила тока",
|
||||
"type": "Reading",
|
||||
"subtype": "Pzem004a",
|
||||
"id": "A",
|
||||
"id": "a",
|
||||
"widget": "anydataAmp",
|
||||
"page": "Сенсоры",
|
||||
"descr": "Сила тока",
|
||||
"int": 15,
|
||||
"addr": "0xF8",
|
||||
"num": 25
|
||||
"num": 27
|
||||
},
|
||||
{
|
||||
"name": "26. PZEM 004t Мощность",
|
||||
"name": "28. PZEM 004t Мощность",
|
||||
"type": "Reading",
|
||||
"subtype": "Pzem004w",
|
||||
"id": "W",
|
||||
"id": "w",
|
||||
"widget": "anydataWt",
|
||||
"page": "Сенсоры",
|
||||
"descr": "Мощность",
|
||||
"int": 15,
|
||||
"addr": "0xF8",
|
||||
"num": 26
|
||||
"num": 28
|
||||
},
|
||||
{
|
||||
"name": "27. PZEM 004t Энергия",
|
||||
"name": "29. PZEM 004t Энергия",
|
||||
"type": "Reading",
|
||||
"subtype": "Pzem004wh",
|
||||
"id": "Wh",
|
||||
"id": "wh",
|
||||
"widget": "anydataWth",
|
||||
"page": "Сенсоры",
|
||||
"descr": "Энергия",
|
||||
"int": 15,
|
||||
"addr": "0xF8",
|
||||
"num": 27
|
||||
"num": 29
|
||||
},
|
||||
{
|
||||
"name": "28. PZEM 004t Частота",
|
||||
"name": "30. PZEM 004t Частота",
|
||||
"type": "Reading",
|
||||
"subtype": "Pzem004hz",
|
||||
"id": "Hz",
|
||||
"id": "hz",
|
||||
"widget": "anydataHtz",
|
||||
"page": "Сенсоры",
|
||||
"descr": "Энергия",
|
||||
"descr": "Частота",
|
||||
"int": 15,
|
||||
"addr": "0x77",
|
||||
"num": 28
|
||||
"addr": "0xF8",
|
||||
"num": 30
|
||||
},
|
||||
{
|
||||
"name": "29. Сканер кнопок 433 MHz",
|
||||
"num": 29,
|
||||
"name": "31. Сканер кнопок 433 MHz",
|
||||
"num": 31,
|
||||
"type": "Reading",
|
||||
"subtype": "RCswitch",
|
||||
"id": "rsw",
|
||||
@@ -381,7 +407,7 @@
|
||||
"pinTx": 12
|
||||
},
|
||||
{
|
||||
"name": "30. Sht20 Температура",
|
||||
"name": "32. Sht20 Температура",
|
||||
"type": "Reading",
|
||||
"subtype": "Sht20t",
|
||||
"id": "tmp2",
|
||||
@@ -390,10 +416,10 @@
|
||||
"descr": "Температура",
|
||||
"int": 15,
|
||||
"round": 1,
|
||||
"num": 30
|
||||
"num": 32
|
||||
},
|
||||
{
|
||||
"name": "31. Sht20 Влажность",
|
||||
"name": "33. Sht20 Влажность",
|
||||
"type": "Reading",
|
||||
"subtype": "Sht20h",
|
||||
"id": "Hum2",
|
||||
@@ -402,10 +428,10 @@
|
||||
"descr": "Влажность",
|
||||
"int": 15,
|
||||
"round": 1,
|
||||
"num": 31
|
||||
"num": 33
|
||||
},
|
||||
{
|
||||
"name": "32. Sht30 Температура",
|
||||
"name": "34. Sht30 Температура",
|
||||
"type": "Reading",
|
||||
"subtype": "Sht30t",
|
||||
"id": "tmp30",
|
||||
@@ -414,10 +440,10 @@
|
||||
"descr": "SHT30 Температура",
|
||||
"int": 15,
|
||||
"round": 1,
|
||||
"num": 32
|
||||
"num": 34
|
||||
},
|
||||
{
|
||||
"name": "33. Sht30 Влажность",
|
||||
"name": "35. Sht30 Влажность",
|
||||
"type": "Reading",
|
||||
"subtype": "Sht30h",
|
||||
"id": "Hum30",
|
||||
@@ -426,11 +452,11 @@
|
||||
"descr": "SHT30 Влажность",
|
||||
"int": 15,
|
||||
"round": 1,
|
||||
"num": 33
|
||||
"num": 35
|
||||
},
|
||||
{
|
||||
"name": "34. HC-SR04 Ультразвуковой дальномер",
|
||||
"num": 34,
|
||||
"name": "36. HC-SR04 Ультразвуковой дальномер",
|
||||
"num": 36,
|
||||
"type": "Reading",
|
||||
"subtype": "Sonar",
|
||||
"id": "sonar",
|
||||
@@ -442,7 +468,7 @@
|
||||
"int": 5
|
||||
},
|
||||
{
|
||||
"name": "35. UART",
|
||||
"name": "37. UART",
|
||||
"type": "Reading",
|
||||
"subtype": "UART",
|
||||
"page": "",
|
||||
@@ -452,13 +478,13 @@
|
||||
"tx": 12,
|
||||
"rx": 13,
|
||||
"speed": 9600,
|
||||
"num": 35
|
||||
"num": 37
|
||||
},
|
||||
{
|
||||
"header": "Исполнительные устройства"
|
||||
},
|
||||
{
|
||||
"name": "36. Кнопка подключенная к пину",
|
||||
"name": "38. Кнопка подключенная к пину",
|
||||
"type": "Writing",
|
||||
"subtype": "ButtonIn",
|
||||
"id": "btn",
|
||||
@@ -471,10 +497,10 @@
|
||||
"pinMode": "INPUT",
|
||||
"debounceDelay": 50,
|
||||
"fixState": 0,
|
||||
"num": 36
|
||||
"num": 38
|
||||
},
|
||||
{
|
||||
"name": "37. Управление пином",
|
||||
"name": "39. Управление пином",
|
||||
"type": "Writing",
|
||||
"subtype": "ButtonOut",
|
||||
"id": "btn",
|
||||
@@ -484,10 +510,10 @@
|
||||
"int": 0,
|
||||
"inv": 0,
|
||||
"pin": 2,
|
||||
"num": 37
|
||||
"num": 39
|
||||
},
|
||||
{
|
||||
"name": "38. Сервопривод",
|
||||
"name": "40. Сервопривод",
|
||||
"type": "Writing",
|
||||
"subtype": "IoTServo",
|
||||
"id": "servo",
|
||||
@@ -498,10 +524,10 @@
|
||||
"pin": 12,
|
||||
"apin": -1,
|
||||
"amap": "0, 4096, 0, 180",
|
||||
"num": 38
|
||||
"num": 40
|
||||
},
|
||||
{
|
||||
"name": "39. Расширитель портов Mcp23017",
|
||||
"name": "41. Расширитель портов Mcp23017",
|
||||
"type": "Reading",
|
||||
"subtype": "Mcp23017",
|
||||
"id": "Mcp",
|
||||
@@ -511,10 +537,10 @@
|
||||
"int": "0",
|
||||
"addr": "0x20",
|
||||
"index": 1,
|
||||
"num": 39
|
||||
"num": 41
|
||||
},
|
||||
{
|
||||
"name": "40. MP3 плеер",
|
||||
"name": "42. MP3 плеер",
|
||||
"type": "Reading",
|
||||
"subtype": "Mp3",
|
||||
"id": "mp3",
|
||||
@@ -524,10 +550,10 @@
|
||||
"int": 1,
|
||||
"pins": "14,12",
|
||||
"volume": 20,
|
||||
"num": 40
|
||||
"num": 42
|
||||
},
|
||||
{
|
||||
"name": "41. PWM ESP8266",
|
||||
"name": "43. PWM ESP8266",
|
||||
"type": "Writing",
|
||||
"subtype": "Pwm8266",
|
||||
"id": "pwm",
|
||||
@@ -539,10 +565,10 @@
|
||||
"freq": 5000,
|
||||
"val": 0,
|
||||
"apin": -1,
|
||||
"num": 41
|
||||
"num": 43
|
||||
},
|
||||
{
|
||||
"name": "42. Телеграм-Лайт",
|
||||
"name": "44. Телеграм-Лайт",
|
||||
"type": "Writing",
|
||||
"subtype": "TelegramLT",
|
||||
"id": "tg",
|
||||
@@ -551,13 +577,13 @@
|
||||
"descr": "",
|
||||
"token": "",
|
||||
"chatID": "",
|
||||
"num": 42
|
||||
"num": 44
|
||||
},
|
||||
{
|
||||
"header": "Экраны"
|
||||
},
|
||||
{
|
||||
"name": "43. LCD экран 2004",
|
||||
"name": "45. LCD экран 2004",
|
||||
"type": "Reading",
|
||||
"subtype": "Lcd2004",
|
||||
"id": "Lcd",
|
||||
@@ -569,10 +595,10 @@
|
||||
"size": "20,4",
|
||||
"coord": "0,0",
|
||||
"id2show": "id датчика",
|
||||
"num": 43
|
||||
"num": 45
|
||||
},
|
||||
{
|
||||
"name": "44. LCD экран 1602",
|
||||
"name": "46. LCD экран 1602",
|
||||
"type": "Reading",
|
||||
"subtype": "Lcd2004",
|
||||
"id": "Lcd",
|
||||
@@ -584,6 +610,6 @@
|
||||
"size": "16,2",
|
||||
"coord": "0,0",
|
||||
"id2show": "id датчика",
|
||||
"num": 44
|
||||
"num": 46
|
||||
}
|
||||
]
|
||||
@@ -47,7 +47,7 @@
|
||||
"name": "anydataWth",
|
||||
"label": "Энергия",
|
||||
"widget": "anydata",
|
||||
"after": "Wt/hr",
|
||||
"after": "kWt/Hr",
|
||||
"icon": "speedometer"
|
||||
},
|
||||
{
|
||||
@@ -103,34 +103,27 @@
|
||||
},
|
||||
{
|
||||
"name": "chart1",
|
||||
"label": "График1",
|
||||
"label": "График без точек",
|
||||
"widget": "chart",
|
||||
"dateFormat": "HH:mm",
|
||||
"maxCount": 255,
|
||||
"maxCount": 86400,
|
||||
"pointRadius": 0
|
||||
},
|
||||
{
|
||||
"name": "chart2",
|
||||
"label": "График2",
|
||||
"label": "График с точками",
|
||||
"widget": "chart",
|
||||
"maxCount": 255,
|
||||
"maxCount": 86400,
|
||||
"dateFormat": "HH:mm"
|
||||
},
|
||||
{
|
||||
"name": "chart3",
|
||||
"label": "График3",
|
||||
"label": "График Дневной",
|
||||
"widget": "chart",
|
||||
"dateFormat": "DD.MM.YYYY",
|
||||
"maxCount": 255,
|
||||
"maxCount": 86400,
|
||||
"type": "bar"
|
||||
},
|
||||
{
|
||||
"name": "chart4",
|
||||
"label": "График4",
|
||||
"widget": "chart",
|
||||
"maxCount": 255,
|
||||
"dateFormat": "DD.MM.YYYY"
|
||||
},
|
||||
{
|
||||
"name": "fillgauge",
|
||||
"label": "Бочка",
|
||||
@@ -210,10 +203,10 @@
|
||||
"status": 0
|
||||
},
|
||||
{
|
||||
"name": "anydataVlt",
|
||||
"label": "Вольты",
|
||||
"name": "anydataPpm",
|
||||
"label": "PPM",
|
||||
"widget": "anydata",
|
||||
"after": "Vlt",
|
||||
"after": "ppm",
|
||||
"icon": "speedometer"
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
//Версия прошивки
|
||||
#define FIRMWARE_VERSION 426
|
||||
#define FIRMWARE_VERSION 427
|
||||
|
||||
#ifdef esp8266_4mb
|
||||
#define FIRMWARE_NAME "esp8266_4mb"
|
||||
|
||||
@@ -10,5 +10,6 @@ extern void handleFileUpload();
|
||||
extern void handleFileDelete();
|
||||
extern void handleFileCreate();
|
||||
extern void handleFileList();
|
||||
void printDirectory(File dir, String& out);
|
||||
//#endif
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include <SoftwareSerial.h>
|
||||
|
||||
#define PZEM_DEFAULT_ADDR 0xF8
|
||||
@@ -22,13 +21,13 @@ class PZEMSensor {
|
||||
PZEMSensor(Stream *serial, uint16_t addr = PZEM_DEFAULT_ADDR);
|
||||
|
||||
~PZEMSensor();
|
||||
PZEM_Info* values();
|
||||
PZEM_Info *values(bool &online);
|
||||
bool setAddress(uint8_t addr);
|
||||
uint8_t getAddress();
|
||||
bool setPowerAlarm(uint16_t watts);
|
||||
bool getPowerAlarm();
|
||||
bool reset();
|
||||
void search();
|
||||
bool search();
|
||||
// Get most up to date values from device registers and cache them
|
||||
bool refresh();
|
||||
|
||||
|
||||
@@ -43,10 +43,13 @@ PZEMSensor::PZEMSensor(Stream *port, uint16_t addr) {
|
||||
init();
|
||||
}
|
||||
|
||||
PZEM_Info *PZEMSensor::values() {
|
||||
PZEM_Info *PZEMSensor::values(bool &online) {
|
||||
// Update vales if necessary
|
||||
if (!refresh()) {
|
||||
_values = PZEM_Info();
|
||||
online = false;
|
||||
} else {
|
||||
online = true;
|
||||
}
|
||||
return &_values;
|
||||
}
|
||||
@@ -62,7 +65,7 @@ PZEM_Info *PZEMSensor::values() {
|
||||
* @param[in] check - perform a simple read check after write
|
||||
*
|
||||
* @return success
|
||||
*/
|
||||
*/
|
||||
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 respBuffer[8]; // Response buffer (only used when check is true)
|
||||
@@ -295,7 +298,8 @@ uint16_t PZEMSensor::CRC16(const uint8_t *data, uint16_t len) {
|
||||
return crc;
|
||||
}
|
||||
|
||||
void PZEMSensor::search() {
|
||||
bool PZEMSensor::search() {
|
||||
bool ret = false;
|
||||
static uint8_t response[7];
|
||||
for (uint16_t addr = 0x01; addr <= 0xF8; addr++) {
|
||||
sendCmd8(CMD_RIR, 0x00, 0x01, false, addr);
|
||||
@@ -303,8 +307,9 @@ void PZEMSensor::search() {
|
||||
// Something went wrong
|
||||
continue;
|
||||
} else {
|
||||
Serial.print("Device on addr: ");
|
||||
Serial.print(addr);
|
||||
Serial.println("Pzem " + String(addr));
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,11 @@
|
||||
"modules": {
|
||||
"Виртуальные элементы": [
|
||||
{
|
||||
"path": "src\\modules\\virtual\\Logging",
|
||||
"path": "src\\modules\\virtual\\Loging",
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"path": "src\\modules\\virtual\\LogingDaily",
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
@@ -45,6 +49,10 @@
|
||||
}
|
||||
],
|
||||
"Сенсоры": [
|
||||
{
|
||||
"path": "src\\modules\\sensors\\Acs712",
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"path": "src\\modules\\sensors\\Ads1115",
|
||||
"active": false
|
||||
|
||||
@@ -61,6 +61,7 @@ lib_deps =
|
||||
https://github.com/JonasGMorsch/GY-21.git
|
||||
ClosedCube HDC1080
|
||||
adafruit/MAX6675 library
|
||||
mandulaj/PZEM-004T-v30
|
||||
rc-switch @ ^2.6.4
|
||||
robtillaart/SHT2x@^0.1.1
|
||||
WEMOS SHT3x@1.0.0
|
||||
@@ -70,10 +71,12 @@ lib_deps =
|
||||
dfrobot/DFRobotDFPlayerMini @ ^1.0.5
|
||||
marcoschwartz/LiquidCrystal_I2C@^1.1.4
|
||||
build_src_filter =
|
||||
+<modules\virtual\Logging>
|
||||
+<modules\virtual\Loging>
|
||||
+<modules\virtual\LogingDaily>
|
||||
+<modules\virtual\Timer>
|
||||
+<modules\virtual\Variable>
|
||||
+<modules\virtual\VButton>
|
||||
+<modules\sensors\Acs712>
|
||||
+<modules\sensors\Aht20>
|
||||
+<modules\sensors\AnalogAdc>
|
||||
+<modules\sensors\Bme280>
|
||||
|
||||
@@ -80,6 +80,12 @@ void setup() {
|
||||
|
||||
// test
|
||||
Serial.println("-------test start--------");
|
||||
|
||||
// File dir = FileFS.open("/", "r");
|
||||
// String out;
|
||||
// printDirectory(dir, out);
|
||||
// Serial.println(out);
|
||||
|
||||
//=======проверка очереди из структур=================
|
||||
|
||||
// myDB = new IoTDB;
|
||||
|
||||
@@ -134,9 +134,10 @@ void mqttCallback(char* topic, uint8_t* payload, size_t length) {
|
||||
publishWidgets();
|
||||
publishState();
|
||||
|
||||
//обращение к логированию из ядра
|
||||
//отправка данных графиков
|
||||
for (std::list<IoTItem*>::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) {
|
||||
if ((*it)->getSubtype() == "Loging") {
|
||||
if ((*it)->getSubtype() == "Loging" || "LogingDaily") {
|
||||
(*it)->setPublishDestination(TO_MQTT);
|
||||
(*it)->publishValue();
|
||||
}
|
||||
|
||||
@@ -11,42 +11,36 @@ void standWebServerInit() {
|
||||
HTTP.serveStatic("/bundle.css.gz", FileFS, "/", "max-age=31536000"); // кеширование на 1 год
|
||||
HTTP.serveStatic("/favicon.png", FileFS, "/", "max-age=31536000"); // кеширование на 1 год
|
||||
|
||||
HTTP.on("/devicelist.json", HTTP_GET, []() {
|
||||
HTTP.send(200, "application/json", devListHeapJson);
|
||||
});
|
||||
|
||||
HTTP.on("/settings.h.json", HTTP_GET, []() {
|
||||
HTTP.send(200, "application/json", settingsFlashJson);
|
||||
});
|
||||
|
||||
HTTP.on("/settings.f.json", HTTP_GET, []() {
|
||||
HTTP.send(200, "application/json", readFile(F("settings.json"), 20000));
|
||||
});
|
||||
|
||||
HTTP.on("/params.json", HTTP_GET, []() {
|
||||
String json = getParamsJson();
|
||||
HTTP.send(200, "application/json", json);
|
||||
});
|
||||
|
||||
HTTP.on("/errors.json", HTTP_GET, []() {
|
||||
HTTP.send(200, "application/json", errorsHeapJson);
|
||||
});
|
||||
|
||||
HTTP.on("/config.json", HTTP_GET, []() {
|
||||
HTTP.send(200, "application/json", readFile(F("config.json"), 20000));
|
||||
});
|
||||
|
||||
HTTP.on("/layout.json", HTTP_GET, []() {
|
||||
HTTP.send(200, "application/json", readFile(F("layout.json"), 20000));
|
||||
});
|
||||
|
||||
HTTP.on("/restart", HTTP_GET, []() {
|
||||
// ESP.restart();
|
||||
HTTP.send(200, "text/plain", "ok");
|
||||
});
|
||||
// HTTP.on("/devicelist.json", HTTP_GET, []() {
|
||||
// HTTP.send(200, "application/json", devListHeapJson);
|
||||
// });
|
||||
// HTTP.on("/settings.h.json", HTTP_GET, []() {
|
||||
// HTTP.send(200, "application/json", settingsFlashJson);
|
||||
// });
|
||||
// HTTP.on("/settings.f.json", HTTP_GET, []() {
|
||||
// HTTP.send(200, "application/json", readFile(F("settings.json"), 20000));
|
||||
// });
|
||||
// HTTP.on("/params.json", HTTP_GET, []() {
|
||||
// String json = getParamsJson();
|
||||
// HTTP.send(200, "application/json", json);
|
||||
// });
|
||||
// HTTP.on("/errors.json", HTTP_GET, []() {
|
||||
// HTTP.send(200, "application/json", errorsHeapJson);
|
||||
// });
|
||||
// HTTP.on("/config.json", HTTP_GET, []() {
|
||||
// HTTP.send(200, "application/json", readFile(F("config.json"), 20000));
|
||||
// });
|
||||
// HTTP.on("/layout.json", HTTP_GET, []() {
|
||||
// HTTP.send(200, "application/json", readFile(F("layout.json"), 20000));
|
||||
// });
|
||||
// HTTP.on("/restart", HTTP_GET, []() {
|
||||
// // ESP.restart();
|
||||
// HTTP.send(200, "text/plain", "ok");
|
||||
// });
|
||||
|
||||
// Добавляем функцию Update для перезаписи прошивки по WiFi при 1М(256K FileFS) и выше
|
||||
// httpUpdater.setup(&HTTP);
|
||||
|
||||
// Запускаем HTTP сервер
|
||||
HTTP.begin();
|
||||
|
||||
@@ -95,7 +89,6 @@ void standWebServerInit() {
|
||||
HTTP.send(200, "text/plain", "");
|
||||
},
|
||||
handleFileUpload);
|
||||
//#endif
|
||||
|
||||
// called when the url is not defined here
|
||||
HTTP.onNotFound([]() {
|
||||
@@ -155,7 +148,6 @@ String getContentType(String filename) {
|
||||
return "text/plain";
|
||||
}
|
||||
|
||||
//#ifdef REST_FILE_OPERATIONS
|
||||
// Здесь функции для работы с файловой системой
|
||||
void handleFileUpload() {
|
||||
if (HTTP.uri() != "/edit") return;
|
||||
@@ -205,10 +197,6 @@ void handleFileCreate() {
|
||||
}
|
||||
|
||||
void handleFileList() {
|
||||
if (!HTTP.hasArg("list")) {
|
||||
HTTP.send(500, "text/plain", "BAD ARGS");
|
||||
return;
|
||||
}
|
||||
File dir = FileFS.open("/", "r");
|
||||
String output = "[";
|
||||
File entry;
|
||||
@@ -226,5 +214,22 @@ void handleFileList() {
|
||||
Serial.println(output);
|
||||
HTTP.send(200, "text/json", output);
|
||||
}
|
||||
//#endif
|
||||
|
||||
void printDirectory(File dir, String& out) {
|
||||
while (true) {
|
||||
File entry = dir.openNextFile();
|
||||
if (!entry) {
|
||||
break;
|
||||
}
|
||||
if (entry.isDirectory()) {
|
||||
out += entry.name();
|
||||
out += "/";
|
||||
printDirectory(entry, out);
|
||||
} else {
|
||||
out += entry.name();
|
||||
out += "\r\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -73,13 +73,14 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
|
||||
|
||||
//отвечаем на запрос графиков
|
||||
if (headerStr == "/charts|") {
|
||||
//обращение к логированию из ядра
|
||||
//отправка данных графиков только в выбранный сокет
|
||||
for (std::list<IoTItem*>::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) {
|
||||
//сбрасываем даты графиков
|
||||
// if ((*it)->getID().endsWith("-date")) {
|
||||
// (*it)->setTodayDate();
|
||||
//}
|
||||
if ((*it)->getSubtype() == "Loging") {
|
||||
if ((*it)->getSubtype() == "Loging" || "LogingDaily") {
|
||||
(*it)->setPublishDestination(TO_WS, num);
|
||||
(*it)->publishValue();
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ void IoTItem::regEvent(String value, String consoleInfo = "") {
|
||||
publishStatusMqtt(_id, value);
|
||||
|
||||
publishStatusWs(_id, value);
|
||||
SerialPrint("i", "Sensor " + consoleInfo, "'" + _id + "' data: " + value + "'");
|
||||
SerialPrint("i", "Sensor", consoleInfo + " '" + _id + "' data: " + value + "'");
|
||||
|
||||
// проверка если global установлен то шлем всем о событии
|
||||
// if (_global) {
|
||||
@@ -150,8 +150,6 @@ bool IoTItem::isGpioDriver() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//сетевое общение====================================================================================================================================
|
||||
|
||||
externalVariable::externalVariable(String parameters) : IoTItem(parameters) {
|
||||
|
||||
@@ -205,11 +205,11 @@ class BinaryExprAST : public ExprAST {
|
||||
|
||||
if (!lhs->isDecimal || !rhs->isDecimal) {
|
||||
if (lhs->isDecimal)
|
||||
lhsStr = lhs->valD;
|
||||
lhsStr = (String)lhs->valD;
|
||||
else
|
||||
lhsStr = lhs->valS;
|
||||
if (rhs->isDecimal)
|
||||
rhsStr = rhs->valD;
|
||||
rhsStr = (String)rhs->valD;
|
||||
else
|
||||
rhsStr = rhs->valS;
|
||||
switch (Op) {
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#include "ESPConfiguration.h"
|
||||
|
||||
void* getAPI_Loging(String subtype, String params);
|
||||
void* getAPI_LogingDaily(String subtype, String params);
|
||||
void* getAPI_Timer(String subtype, String params);
|
||||
void* getAPI_Variable(String subtype, String params);
|
||||
void* getAPI_VButton(String subtype, String params);
|
||||
void* getAPI_Acs712(String subtype, String params);
|
||||
void* getAPI_Aht20(String subtype, String params);
|
||||
void* getAPI_AnalogAdc(String subtype, String params);
|
||||
void* getAPI_Bme280(String subtype, String params);
|
||||
@@ -31,9 +33,11 @@ void* getAPI_Lcd2004(String subtype, String params);
|
||||
void* getAPI(String subtype, String params) {
|
||||
void* tmpAPI;
|
||||
if ((tmpAPI = getAPI_Loging(subtype, params)) != nullptr) return tmpAPI;
|
||||
if ((tmpAPI = getAPI_LogingDaily(subtype, params)) != nullptr) return tmpAPI;
|
||||
if ((tmpAPI = getAPI_Timer(subtype, params)) != nullptr) return tmpAPI;
|
||||
if ((tmpAPI = getAPI_Variable(subtype, params)) != nullptr) return tmpAPI;
|
||||
if ((tmpAPI = getAPI_VButton(subtype, params)) != nullptr) return tmpAPI;
|
||||
if ((tmpAPI = getAPI_Acs712(subtype, params)) != nullptr) return tmpAPI;
|
||||
if ((tmpAPI = getAPI_Aht20(subtype, params)) != nullptr) return tmpAPI;
|
||||
if ((tmpAPI = getAPI_AnalogAdc(subtype, params)) != nullptr) return tmpAPI;
|
||||
if ((tmpAPI = getAPI_Bme280(subtype, params)) != nullptr) return tmpAPI;
|
||||
|
||||
76
src/modules/sensors/Acs712/Acs712.cpp
Normal file
76
src/modules/sensors/Acs712/Acs712.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
#include "Global.h"
|
||||
#include "classes/IoTItem.h"
|
||||
|
||||
extern IoTGpio IoTgpio;
|
||||
|
||||
class Acs712 : public IoTItem
|
||||
{
|
||||
private:
|
||||
unsigned int _pin;
|
||||
const unsigned long _sampleTime = 100000UL; // sample over 100ms, it is an exact number of cycles for both 50Hz and 60Hz mains
|
||||
const unsigned long _numSamples = 250UL; // choose the number of samples to divide sampleTime exactly, but low enough for the ADC to keep up
|
||||
const unsigned long _sampleInterval = _sampleTime / _numSamples; // the sampling interval, must be longer than then ADC conversion time
|
||||
int _adc_zero1; //Переменная автоматической калибровки
|
||||
|
||||
public:
|
||||
|
||||
Acs712(String parameters) : IoTItem(parameters)
|
||||
{
|
||||
String tmp;
|
||||
jsonRead(parameters, "pin", tmp);
|
||||
_pin = tmp.toInt();
|
||||
_adc_zero1 = determineVQ(_pin);
|
||||
}
|
||||
|
||||
void doByInterval()
|
||||
{
|
||||
|
||||
unsigned long currentAcc = 0;
|
||||
unsigned int count = 0;
|
||||
unsigned long prevMicros = micros() - _sampleInterval;
|
||||
while (count < _numSamples)
|
||||
{
|
||||
if (micros() - prevMicros >= _sampleInterval)
|
||||
{
|
||||
int adc_raw = IoTgpio.analogRead(_pin) - _adc_zero1;
|
||||
currentAcc += (unsigned long)(adc_raw * adc_raw);
|
||||
++count;
|
||||
prevMicros += _sampleInterval;
|
||||
}
|
||||
}
|
||||
#ifdef ESP32
|
||||
value.valD = int(sqrt((float)currentAcc / (float)_numSamples) * (75.7576 / 4095.0));
|
||||
#else
|
||||
value.valD = int(sqrt((float)currentAcc / (float)_numSamples) * (75.7576 / 1023.0));
|
||||
#endif
|
||||
regEvent(value.valD, "Acs712");
|
||||
}
|
||||
|
||||
int determineVQ(int PIN)
|
||||
{
|
||||
long VQ = 0;
|
||||
// read 5000 samples to stabilise value
|
||||
for (int i = 0; i < 5000; i++)
|
||||
{
|
||||
VQ += IoTgpio.analogRead(PIN);
|
||||
//delay(1); // depends on sampling (on filter capacitor), can be 1/80000 (80kHz) max.
|
||||
}
|
||||
VQ /= 5000;
|
||||
return int(VQ);
|
||||
}
|
||||
|
||||
|
||||
~Acs712(){};
|
||||
};
|
||||
|
||||
void *getAPI_Acs712(String subtype, String param)
|
||||
{
|
||||
if (subtype == F("Acs712"))
|
||||
{
|
||||
return new Acs712(param);
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
36
src/modules/sensors/Acs712/modinfo.json
Normal file
36
src/modules/sensors/Acs712/modinfo.json
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"menuSection": "Сенсоры",
|
||||
"configItem": [
|
||||
{
|
||||
"name": "Acs712 Ток",
|
||||
"type": "Reading",
|
||||
"subtype": "Acs712",
|
||||
"id": "amp",
|
||||
"widget": "anydataAmp",
|
||||
"page": "Сенсоры",
|
||||
"descr": "Ток",
|
||||
"round": 3,
|
||||
"pin": 39,
|
||||
"int": 5
|
||||
}
|
||||
],
|
||||
"about": {
|
||||
"authorName": "Yuriy Kuneev",
|
||||
"authorContact": "https://t.me/Kuneev07",
|
||||
"authorGit": "",
|
||||
"exampleURL": "https://iotmanager.org/wiki",
|
||||
"specialThanks": "",
|
||||
"moduleName": "Acs712",
|
||||
"moduleVersion": "1.0",
|
||||
"moduleDesc": "Позволяет получить текущее значение тока на аналоговом пине с помощью модуля Acs712.",
|
||||
"propInfo": {
|
||||
"pin": "Аналоговый GPIO номер, к которому подключен датчик.",
|
||||
"int": "Количество секунд между опросами датчика."
|
||||
}
|
||||
},
|
||||
"defActive": true,
|
||||
"devices": {
|
||||
"esp32_4mb": [],
|
||||
"esp8266_4mb": []
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@
|
||||
"menuSection": "Сенсоры",
|
||||
"configItem": [
|
||||
{
|
||||
"name": "MHZ-19 CO2 (UART)",
|
||||
"name": "MHZ-19 CO2 UART",
|
||||
"type": "Reading",
|
||||
"subtype": "Mhz19uart",
|
||||
"id": "co2uart",
|
||||
@@ -12,7 +12,7 @@
|
||||
"plus": 0,
|
||||
"multiply": 1,
|
||||
"round": 1,
|
||||
"pin": 0,
|
||||
"warmUp": 120,
|
||||
"rxPin": 13,
|
||||
"txPin": 12,
|
||||
"int": 15,
|
||||
@@ -20,7 +20,7 @@
|
||||
"ABC": 1
|
||||
},
|
||||
{
|
||||
"name": "MHZ-19 CO2 (PWM)",
|
||||
"name": "MHZ-19 CO2 PWM",
|
||||
"type": "Reading",
|
||||
"subtype": "Mhz19pwm",
|
||||
"id": "co2pwm",
|
||||
@@ -30,11 +30,13 @@
|
||||
"plus": 0,
|
||||
"multiply": 1,
|
||||
"round": 1,
|
||||
"warmUp": 120,
|
||||
"pin": 15,
|
||||
"maxRetriesNotAvailable": 10,
|
||||
"int": 300
|
||||
},
|
||||
{
|
||||
"name": "Cенсор температуры от MHZ-19 UART",
|
||||
"name": "MHZ-19 Температура UART",
|
||||
"type": "Reading",
|
||||
"subtype": "Mhz19temp",
|
||||
"id": "Mhz19temp",
|
||||
@@ -46,64 +48,28 @@
|
||||
"round": 1,
|
||||
"rxPin": 13,
|
||||
"txPin": 12,
|
||||
"ABC": 1,
|
||||
"int": 30
|
||||
},
|
||||
{
|
||||
"name": "Рабочий диапазон от MHZ-19 UART",
|
||||
"type": "Reading",
|
||||
"subtype": "Mhz19range",
|
||||
"id": "Mhz19range",
|
||||
"widget": "anydataPpm",
|
||||
"page": "Сенсоры",
|
||||
"descr": "Диапазон",
|
||||
"plus": 0,
|
||||
"multiply": 1,
|
||||
"round": 1,
|
||||
"rxPin": 13,
|
||||
"txPin": 12,
|
||||
"range": 5000,
|
||||
"ABC": 1,
|
||||
"int": 30
|
||||
},
|
||||
{
|
||||
"name": "Автокалибровка от MHZ-19 UART",
|
||||
"type": "Reading",
|
||||
"subtype": "Mhz19ABC",
|
||||
"id": "Mhz19ABC",
|
||||
"widget": "anydataDef",
|
||||
"page": "Сенсоры",
|
||||
"descr": "ABC",
|
||||
"rxPin": 13,
|
||||
"txPin": 12,
|
||||
"range": 5000,
|
||||
"ABC": 1,
|
||||
"int": 30
|
||||
}
|
||||
],
|
||||
"about": {
|
||||
"authorName": "Alex K",
|
||||
"authorContact": "https://t.me/cmche",
|
||||
"authorGit": "",
|
||||
"authorGit": "https://github.com/CHE77/Mhz19forIotManager",
|
||||
"specialThanks": "",
|
||||
"moduleName": "Mhz19",
|
||||
"moduleVersion": "1.0",
|
||||
"usedRam": 15,
|
||||
"subTypes": [
|
||||
"Mhz19uart",
|
||||
"Mhz19pwm",
|
||||
"Mhz19temp",
|
||||
"Mhz19range",
|
||||
"Mhz19ABC"
|
||||
],
|
||||
"title": "Датчик температуры и CO2 с Mhz19",
|
||||
"moduleDesc": "Позволяет получить значения температуры и CO2 с Mhz19.",
|
||||
"moduleVersion": "2.0 - можно переназначать пины",
|
||||
"moduleDesc": "Позволяет получить значения уровня концетрации CO2 с Mhz19 по UART и/или ШИМ. Замер по ШИМ может производить 1-2 сек. задержки",
|
||||
"propInfo": {
|
||||
"plus": "поправочный коэффиент +c",
|
||||
"multiply": "поправочный коэффиент k*",
|
||||
"round": "округление",
|
||||
"int": "Количество секунд между опросами датчика.",
|
||||
"rxPin": "",
|
||||
"txPin": "",
|
||||
"range": "",
|
||||
"ABC": ""
|
||||
"rxPin": "Esp8266: GPIO 13 - D7, ESP32: GPIO 19 - RX1, > MHZ19: TXD зеленый провод",
|
||||
"txPin": "Esp8266: GPIO 12 - D6, ESP32: GPIO 18 - TX1, > MHZ19: RXD синий провод",
|
||||
"range": "Шкала по умолчанию 0-5000ppm. Также можно выбрать 2000",
|
||||
"ABC": "Автокалибровка. По умолчанию включена. Раз в сутки на 20 мин. надо выставлять на свежий воздух.",
|
||||
"pin": "пин получения значений по ШИМ. Esp8266: GPIO 15 - D8, ESP32: GPIO 21, > MHZ19: PWM желтый провод",
|
||||
"maxRetriesNotAvailable": "Максимальное количество попыток опроса сенсора по ШИМ. (может задерживать контроллер)"
|
||||
}
|
||||
},
|
||||
"defActive": false,
|
||||
|
||||
@@ -5,11 +5,10 @@
|
||||
#include "PZEMSensor.h"
|
||||
#include "modules/sensors/UART/Uart.h"
|
||||
|
||||
PZEMSensor* pzem;
|
||||
|
||||
class Pzem004v : public IoTItem {
|
||||
private:
|
||||
String addr;
|
||||
PZEMSensor* pzem;
|
||||
|
||||
public:
|
||||
Pzem004v(String parameters) : IoTItem(parameters) {
|
||||
@@ -21,17 +20,147 @@ class Pzem004v : public IoTItem {
|
||||
|
||||
void doByInterval() {
|
||||
if (pzem) {
|
||||
value.valD = pzem->values()->voltage;
|
||||
regEvent(value.valD, "Pzem Voltage");
|
||||
bool online = false;
|
||||
value.valD = pzem->values(online)->voltage;
|
||||
if (online) {
|
||||
regEvent(value.valD, "Pzem V");
|
||||
} else {
|
||||
regEvent(NAN, "Pzem V");
|
||||
SerialPrint("E", "Pzem", "V error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~Pzem004v(){};
|
||||
};
|
||||
|
||||
class Pzem004a : public IoTItem {
|
||||
private:
|
||||
String addr;
|
||||
PZEMSensor* pzem;
|
||||
|
||||
public:
|
||||
Pzem004a(String parameters) : IoTItem(parameters) {
|
||||
addr = jsonReadStr(parameters, "addr");
|
||||
if (myUART) {
|
||||
pzem = new PZEMSensor(myUART, hexStringToUint8(addr));
|
||||
}
|
||||
}
|
||||
|
||||
void doByInterval() {
|
||||
if (pzem) {
|
||||
bool online = false;
|
||||
value.valD = pzem->values(online)->current;
|
||||
if (online) {
|
||||
regEvent(value.valD, "Pzem A");
|
||||
} else {
|
||||
regEvent(NAN, "Pzem A");
|
||||
SerialPrint("E", "Pzem", "A error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~Pzem004a(){};
|
||||
};
|
||||
|
||||
class Pzem004w : public IoTItem {
|
||||
private:
|
||||
String addr;
|
||||
PZEMSensor* pzem;
|
||||
|
||||
public:
|
||||
Pzem004w(String parameters) : IoTItem(parameters) {
|
||||
addr = jsonReadStr(parameters, "addr");
|
||||
if (myUART) {
|
||||
pzem = new PZEMSensor(myUART, hexStringToUint8(addr));
|
||||
}
|
||||
}
|
||||
|
||||
void doByInterval() {
|
||||
if (pzem) {
|
||||
bool online = false;
|
||||
value.valD = pzem->values(online)->power;
|
||||
if (online) {
|
||||
regEvent(value.valD, "Pzem W");
|
||||
} else {
|
||||
regEvent(NAN, "Pzem W");
|
||||
SerialPrint("E", "Pzem", "W error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~Pzem004w(){};
|
||||
};
|
||||
|
||||
class Pzem004wh : public IoTItem {
|
||||
private:
|
||||
String addr;
|
||||
PZEMSensor* pzem;
|
||||
|
||||
public:
|
||||
Pzem004wh(String parameters) : IoTItem(parameters) {
|
||||
addr = jsonReadStr(parameters, "addr");
|
||||
if (myUART) {
|
||||
pzem = new PZEMSensor(myUART, hexStringToUint8(addr));
|
||||
}
|
||||
}
|
||||
|
||||
void doByInterval() {
|
||||
if (pzem) {
|
||||
bool online = false;
|
||||
value.valD = pzem->values(online)->energy;
|
||||
if (online) {
|
||||
regEvent(value.valD, "Pzem Wh");
|
||||
} else {
|
||||
regEvent(NAN, "Pzem Wh");
|
||||
SerialPrint("E", "Pzem", "Wh error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~Pzem004wh(){};
|
||||
};
|
||||
|
||||
class Pzem004hz : public IoTItem {
|
||||
private:
|
||||
String addr;
|
||||
PZEMSensor* pzem;
|
||||
|
||||
public:
|
||||
Pzem004hz(String parameters) : IoTItem(parameters) {
|
||||
addr = jsonReadStr(parameters, "addr");
|
||||
if (myUART) {
|
||||
pzem = new PZEMSensor(myUART, hexStringToUint8(addr));
|
||||
}
|
||||
}
|
||||
|
||||
void doByInterval() {
|
||||
if (pzem) {
|
||||
bool online = false;
|
||||
value.valD = pzem->values(online)->freq;
|
||||
if (online) {
|
||||
regEvent(value.valD, "Pzem Hz");
|
||||
} else {
|
||||
regEvent(NAN, "Pzem Hz");
|
||||
SerialPrint("E", "Pzem", "Hz error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~Pzem004hz(){};
|
||||
};
|
||||
|
||||
void* getAPI_Pzem004(String subtype, String param) {
|
||||
if (subtype == F("Pzem004v")) {
|
||||
return new Pzem004v(param);
|
||||
} else if (subtype == F("Pzem004a")) {
|
||||
return new Pzem004a(param);
|
||||
} else if (subtype == F("Pzem004w")) {
|
||||
return new Pzem004w(param);
|
||||
} else if (subtype == F("Pzem004wh")) {
|
||||
return new Pzem004wh(param);
|
||||
} else if (subtype == F("Pzem004hz")) {
|
||||
return new Pzem004hz(param);
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"name": "PZEM 004t Напряжение",
|
||||
"type": "Reading",
|
||||
"subtype": "Pzem004v",
|
||||
"id": "V",
|
||||
"id": "v",
|
||||
"widget": "anydataVlt",
|
||||
"page": "Сенсоры",
|
||||
"descr": "Напряжение",
|
||||
@@ -16,7 +16,7 @@
|
||||
"name": "PZEM 004t Сила тока",
|
||||
"type": "Reading",
|
||||
"subtype": "Pzem004a",
|
||||
"id": "A",
|
||||
"id": "a",
|
||||
"widget": "anydataAmp",
|
||||
"page": "Сенсоры",
|
||||
"descr": "Сила тока",
|
||||
@@ -27,7 +27,7 @@
|
||||
"name": "PZEM 004t Мощность",
|
||||
"type": "Reading",
|
||||
"subtype": "Pzem004w",
|
||||
"id": "W",
|
||||
"id": "w",
|
||||
"widget": "anydataWt",
|
||||
"page": "Сенсоры",
|
||||
"descr": "Мощность",
|
||||
@@ -38,7 +38,7 @@
|
||||
"name": "PZEM 004t Энергия",
|
||||
"type": "Reading",
|
||||
"subtype": "Pzem004wh",
|
||||
"id": "Wh",
|
||||
"id": "wh",
|
||||
"widget": "anydataWth",
|
||||
"page": "Сенсоры",
|
||||
"descr": "Энергия",
|
||||
@@ -49,12 +49,12 @@
|
||||
"name": "PZEM 004t Частота",
|
||||
"type": "Reading",
|
||||
"subtype": "Pzem004hz",
|
||||
"id": "Hz",
|
||||
"id": "hz",
|
||||
"widget": "anydataHtz",
|
||||
"page": "Сенсоры",
|
||||
"descr": "Энергия",
|
||||
"descr": "Частота",
|
||||
"int": 15,
|
||||
"addr": "0x77"
|
||||
"addr": "0xF8"
|
||||
}
|
||||
],
|
||||
"about": {
|
||||
@@ -72,16 +72,20 @@
|
||||
"Pzem004wh",
|
||||
"Pzem004hz"
|
||||
],
|
||||
"title": "Счетчик электроэнергии PZEM 004t версии 3.0 (с модбасом)",
|
||||
"title": "Счетчик электроэнергии PZEM 004 t версии 3.0 (с модбасом). Возможно подключение трех счетчиков к одной esp для трехфазных сетей. Для этого нужно настроить разные адреса modbus в платах pzem",
|
||||
"moduleDesc": "Считает потраченную электроэнергию, измеряет напряжение, частоту, силу тока и прочие параметры",
|
||||
"propInfo": {
|
||||
"addr": "Адрес modbus",
|
||||
"int": "Количество секунд между опросами датчика"
|
||||
"int": "Количество секунд между опросами датчика. Желателно устанавливать разные интервалы для параметров что бы опросы происходили в разное время."
|
||||
}
|
||||
},
|
||||
"defActive": true,
|
||||
"devices": {
|
||||
"esp32_4mb": [],
|
||||
"esp8266_4mb": []
|
||||
"esp32_4mb": [
|
||||
"mandulaj/PZEM-004T-v30"
|
||||
],
|
||||
"esp8266_4mb": [
|
||||
"mandulaj/PZEM-004T-v30"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -14,55 +14,86 @@ extern IoTGpio IoTgpio;
|
||||
|
||||
#include "SdsDustSensor.h"
|
||||
|
||||
//встроена в ядро для 8266, для 32 по этому же имени обращаемся к другой библиотеке plerup/EspSoftwareSerial
|
||||
#include <SoftwareSerial.h>
|
||||
//#define __DEBUG_SDS_DUST_SENSOR__
|
||||
|
||||
int rxPinSDS; // Esp8266: 14/D5 – подключаем к Tx сенсора
|
||||
int txPinSDS; // Esp8266: 16/D0 – подключаем к Rx сенсора
|
||||
|
||||
// SdsDustSensor sds(rxPinSDS, txPinSDS);
|
||||
SdsDustSensor *sds = nullptr;
|
||||
|
||||
// to do убрать глобальный экземпляр
|
||||
#ifdef ESP8266
|
||||
int rxPinSDS = 13; // D7 – подключаем к Tx сенсора
|
||||
int txPinSDS = 12; // D6 – подключаем к Rx сенсора
|
||||
SdsDustSensor sds(rxPinSDS, txPinSDS);
|
||||
#endif
|
||||
#ifdef ESP32
|
||||
#include <HardwareSerial.h>
|
||||
HardwareSerial sdsSerial(2);
|
||||
SdsDustSensor sds(sdsSerial);
|
||||
// SdsDustSensor sds(sdsSerial);
|
||||
#endif
|
||||
|
||||
unsigned int warmUp;
|
||||
unsigned int period;
|
||||
int retryDelayMs = 5;
|
||||
int maxRetriesNotAvailable = 100;
|
||||
unsigned int purge = 30;
|
||||
unsigned int interval = 300;
|
||||
unsigned int purgeDelay = 270;
|
||||
unsigned int continuous = 0;
|
||||
bool startUp = true;
|
||||
|
||||
TickerScheduler ts_sds(2);
|
||||
|
||||
enum TimerTask_t_sds
|
||||
{
|
||||
WAKEUP,
|
||||
PRINT
|
||||
};
|
||||
|
||||
int firstSensor = 0;
|
||||
bool SDS011_init_flag = true;
|
||||
void SDS011_init();
|
||||
float Sds011request(int sensorID);
|
||||
void Sds011request(int sensorID);
|
||||
|
||||
IoTItem *item_Sds011_25 = nullptr; // pointer
|
||||
IoTItem *item_Sds011_10 = nullptr;
|
||||
|
||||
//Это файл сенсора, в нем осуществляется чтение сенсора.
|
||||
//для добавления сенсора вам нужно скопировать этот файл и заменить в нем текст AnalogAdc на название вашего сенсора
|
||||
//Название должно быть уникальным, коротким и отражать суть сенсора.
|
||||
|
||||
class Sds011_25 : public IoTItem {
|
||||
private:
|
||||
class Sds011_25 : public IoTItem
|
||||
{
|
||||
private:
|
||||
//=======================================================================================================
|
||||
// Секция переменных.
|
||||
//Это секция где Вы можете объявлять переменные и объекты arduino библиотек, что бы
|
||||
//впоследствии использовать их в loop и setup
|
||||
// unsigned int _pin;
|
||||
|
||||
public:
|
||||
public:
|
||||
//=======================================================================================================
|
||||
// setup()
|
||||
//это аналог setup из arduino. Здесь вы можете выполнять методы инициализации сенсора.
|
||||
//Такие как ...begin и подставлять в них параметры полученные из web интерфейса.
|
||||
//Все параметры хранятся в перемененной parameters, вы можете прочитать любой параметр используя jsonRead функции:
|
||||
// jsonReadStr, jsonReadBool, jsonReadInt
|
||||
Sds011_25(String parameters) : IoTItem(parameters) {
|
||||
// _pin = jsonReadInt(parameters, "pin");
|
||||
#ifdef ESP8266
|
||||
Sds011_25(String parameters) : IoTItem(parameters)
|
||||
{
|
||||
item_Sds011_25 = this;
|
||||
|
||||
rxPinSDS = jsonReadInt(parameters, "rxPin");
|
||||
txPinSDS = jsonReadInt(parameters, "txPin");
|
||||
#endif
|
||||
warmUp = jsonReadInt(parameters, "warmUp"); // сек. пробужнение должен быть больше
|
||||
period = jsonReadInt(parameters, "period"); // сек. время зарогрева/продувки, затем идут замеры
|
||||
|
||||
purge = jsonReadInt(parameters, "purge"); // сек. пробужнение должен быть больше
|
||||
interval = jsonReadInt(parameters, "int"); // сек. время зарогрева/продувки, затем идут замеры
|
||||
continuous = jsonReadInt(parameters, "continuousMode"); // сек. время зарогрева/продувки, затем идут замеры
|
||||
maxRetriesNotAvailable = jsonReadInt(parameters, "maxRetriesNotAvailable"); // сек. время зарогрева/продувки, затем идут замеры
|
||||
retryDelayMs = jsonReadInt(parameters, "retryDelayMs"); // сек. время зарогрева/продувки, затем идут замеры
|
||||
if (continuous)
|
||||
{
|
||||
SerialPrint("i", "Sensor Sds011", "Continuous mode");
|
||||
ts_sds.remove(PRINT);
|
||||
ts_sds.remove(WAKEUP);
|
||||
}
|
||||
purgeDelay = interval - purge;
|
||||
|
||||
SDS011_init();
|
||||
firstSensor = 0;
|
||||
}
|
||||
//=======================================================================================================
|
||||
// doByInterval()
|
||||
@@ -72,41 +103,70 @@ class Sds011_25 : public IoTItem {
|
||||
//если у сенсора несколько величин то делайте несколько regEvent
|
||||
//не используйте delay - помните, что данный loop общий для всех модулей. Если у вас планируется длительная операция, постарайтесь разбить ее на порции
|
||||
//и выполнить за несколько тактов
|
||||
void doByInterval() {
|
||||
void doByInterval()
|
||||
{
|
||||
SDS011_init();
|
||||
Serial.println("request from 25");
|
||||
value.valD = Sds011request(25);
|
||||
|
||||
regEvent(value.valD, "Sds011_25"); //обязательный вызов хотяб один
|
||||
// SerialPrint("i", "Sensor Sds011", "Request for 2.5");
|
||||
Sds011request(25);
|
||||
// value.valD = Sds011request(25);
|
||||
// regEvent(value.valD, "Sds011_25"); //обязательный вызов хотяб один
|
||||
}
|
||||
|
||||
~Sds011_25(){};
|
||||
};
|
||||
|
||||
//////////////////////////////////// for PM 10//=
|
||||
|
||||
class Sds011_10 : public IoTItem {
|
||||
private:
|
||||
class Sds011_10 : public IoTItem
|
||||
{
|
||||
private:
|
||||
//=======================================================================================================
|
||||
// Секция переменных.
|
||||
//Это секция где Вы можете объявлять переменные и объекты arduino библиотек, что бы
|
||||
//впоследствии использовать их в loop и setup
|
||||
|
||||
public:
|
||||
public:
|
||||
//=======================================================================================================
|
||||
// setup()
|
||||
//это аналог setup из arduino. Здесь вы можете выполнять методы инициализации сенсора.
|
||||
//Такие как ...begin и подставлять в них параметры полученные из web интерфейса.
|
||||
//Все параметры хранятся в перемененной parameters, вы можете прочитать любой параметр используя jsonRead функции:
|
||||
// jsonReadStr, jsonReadBool, jsonReadInt
|
||||
Sds011_10(String parameters) : IoTItem(parameters) {
|
||||
// _pin = jsonReadInt(parameters, "pin");
|
||||
#ifdef ESP8266
|
||||
|
||||
Sds011_10(String parameters) : IoTItem(parameters)
|
||||
{
|
||||
item_Sds011_10 = this;
|
||||
|
||||
rxPinSDS = jsonReadInt(parameters, "rxPin");
|
||||
txPinSDS = jsonReadInt(parameters, "txPin");
|
||||
#endif
|
||||
warmUp = jsonReadInt(parameters, "warmUp"); // сек. пробужнение должен быть больше
|
||||
period = jsonReadInt(parameters, "period"); // сек. время зарогрева/продувки, затем идут замеры
|
||||
|
||||
purge = jsonReadInt(parameters, "purge"); // сек. пробужнение должен быть больше
|
||||
interval = jsonReadInt(parameters, "int"); // сек. время зарогрева/продувки, затем идут замеры
|
||||
continuous = jsonReadInt(parameters, "continuousMode"); // сек. время зарогрева/продувки, затем идут замеры
|
||||
if (continuous)
|
||||
{
|
||||
SerialPrint("i", "Sensor Sds011", "Continuous mode");
|
||||
ts_sds.remove(PRINT);
|
||||
ts_sds.remove(WAKEUP);
|
||||
}
|
||||
else
|
||||
{
|
||||
SerialPrint("i", "Sensor Sds011", "WakeUp mode");
|
||||
}
|
||||
purgeDelay = interval - purge;
|
||||
SDS011_init();
|
||||
firstSensor = 0;
|
||||
}
|
||||
|
||||
//луп выполняющий переодическое дерганье
|
||||
void loop()
|
||||
{
|
||||
ts_sds.update();
|
||||
if (enableDoByInt)
|
||||
{
|
||||
currentMillis = millis();
|
||||
difference = currentMillis - prevMillis;
|
||||
if (difference >= _interval)
|
||||
{
|
||||
prevMillis = millis();
|
||||
this->doByInterval();
|
||||
}
|
||||
}
|
||||
}
|
||||
//=======================================================================================================
|
||||
// doByInterval()
|
||||
@@ -117,12 +177,13 @@ class Sds011_10 : public IoTItem {
|
||||
//не используйте delay - помните, что данный loop общий для всех модулей. Если у вас планируется длительная операция, постарайтесь разбить ее на порции
|
||||
//и выполнить за несколько тактов
|
||||
|
||||
void doByInterval() {
|
||||
void doByInterval()
|
||||
{
|
||||
SDS011_init();
|
||||
Serial.println("request from 10");
|
||||
value.valD = Sds011request(10);
|
||||
|
||||
regEvent(value.valD, "Sds011_10"); //обязательный вызов хотяб один
|
||||
// SerialPrint("i", "Sensor Sds011", "Request for 10ppm");
|
||||
Sds011request(10);
|
||||
// value.valD = Sds011request(10);
|
||||
// regEvent(value.valD, "Sds011_10"); //обязательный вызов хотяб один
|
||||
}
|
||||
~Sds011_10(){};
|
||||
};
|
||||
@@ -130,71 +191,148 @@ class Sds011_10 : public IoTItem {
|
||||
//после замены названия сенсора, на функцию можно не обращать внимания
|
||||
//если сенсор предполагает использование общего объекта библиотеки для нескольких экземпляров сенсора, то в данной функции необходимо предусмотреть
|
||||
//создание и контроль соответствующих глобальных переменных
|
||||
void* getAPI_Sds011(String subtype, String param) {
|
||||
if (subtype == F("Sds011_25")) {
|
||||
void *getAPI_Sds011(String subtype, String param)
|
||||
{
|
||||
if (subtype == F("Sds011_25"))
|
||||
{
|
||||
return new Sds011_25(param);
|
||||
} else if (subtype == F("Sds011_10")) {
|
||||
}
|
||||
else if (subtype == F("Sds011_10"))
|
||||
{
|
||||
return new Sds011_10(param);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
float Sds011request(int sensorID) {
|
||||
float reply = 0;
|
||||
static int a = 0;
|
||||
static float pm25 = 0;
|
||||
static float pm10 = 0;
|
||||
static int startMillis = millis();
|
||||
void Sds011request(int sensorID)
|
||||
{
|
||||
float pm25 = 0;
|
||||
float pm10 = 0;
|
||||
|
||||
if (a == 0) {
|
||||
Serial.print("SDS011 ... warmUp = ");
|
||||
Serial.print(warmUp);
|
||||
Serial.print(" period = ");
|
||||
Serial.println(period);
|
||||
sds.wakeup();
|
||||
startMillis = millis();
|
||||
a = a + 1;
|
||||
}
|
||||
if (a == 1 && millis() >= (startMillis + warmUp * 1000)) {
|
||||
PmResult pm = sds.readPm();
|
||||
if (pm.isOk()) {
|
||||
if (firstSensor == 0)
|
||||
firstSensor = sensorID;
|
||||
|
||||
if (firstSensor == sensorID)
|
||||
{
|
||||
if (!continuous)
|
||||
{
|
||||
ts_sds.remove(PRINT);
|
||||
ts_sds.remove(WAKEUP);
|
||||
}
|
||||
|
||||
PmResult pm = sds->readPm();
|
||||
// SerialPrint("i", "Sensor Sds011", "sds.readPm()");
|
||||
if (pm.isOk())
|
||||
{
|
||||
pm25 = pm.pm25;
|
||||
pm10 = pm.pm10;
|
||||
Serial.print("PM2.5 = ");
|
||||
Serial.print(pm25);
|
||||
Serial.print(" PM10 = ");
|
||||
Serial.println(pm10);
|
||||
a = a + 1;
|
||||
sds.sleep();
|
||||
} else {
|
||||
Serial.print("Could not read values from sensor 25, reason: ");
|
||||
Serial.println(pm.statusToString());
|
||||
a = a + 1;
|
||||
// SerialPrint("i", "Sensor Sds011", pm.toString());
|
||||
|
||||
if (item_Sds011_25 && pm25)
|
||||
{
|
||||
item_Sds011_25->value.valD = pm25;
|
||||
item_Sds011_25->regEvent(item_Sds011_25->value.valD, "Sds011_25");
|
||||
}
|
||||
|
||||
if (item_Sds011_10 && pm10)
|
||||
{
|
||||
item_Sds011_10->value.valD = pm10;
|
||||
item_Sds011_10->regEvent(item_Sds011_10->value.valD, "Sds011_10");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
String msg = "Could not read values from sensor. Reason: " + pm.statusToString();
|
||||
SerialPrint("E", "Sensor Sds011", msg);
|
||||
SDS011_init_flag = true;
|
||||
}
|
||||
|
||||
if (!continuous)
|
||||
{
|
||||
sds->sleep();
|
||||
SerialPrint("i", "Sensor Sds011", "sleep");
|
||||
String msg = "wakeUp planned in " + String(purgeDelay) + " seconds";
|
||||
SerialPrint("i", "Sensor Sds011", msg);
|
||||
ts_sds.add(
|
||||
PRINT, purgeDelay * 1000, [](void *)
|
||||
{ SerialPrint("i", "Sensor Sds011", "delayed wakeUp"); },
|
||||
nullptr, false);
|
||||
ts_sds.add(
|
||||
WAKEUP, purgeDelay * 1000, [](void *)
|
||||
{ sds->wakeup(); },
|
||||
nullptr, false);
|
||||
}
|
||||
}
|
||||
if (a > 1 && millis() >= (startMillis + period * 1000)) {
|
||||
Serial.println("end of period for pm25");
|
||||
a = 0;
|
||||
else
|
||||
{
|
||||
//пропускаем вызов от второго сенсора
|
||||
}
|
||||
if (sensorID == 25) {
|
||||
reply = pm25;
|
||||
}
|
||||
if (sensorID == 10) {
|
||||
reply = pm10;
|
||||
}
|
||||
return reply;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void SDS011_init() {
|
||||
if (SDS011_init_flag) {
|
||||
sds.begin();
|
||||
Serial.println(sds.queryFirmwareVersion().toString()); // prints firmware version
|
||||
// Serial.println(sds.setActiveReportingMode().toString()); //
|
||||
String ReportingMode = sds.setActiveReportingMode().toString();
|
||||
Serial.println(ReportingMode);
|
||||
if (ReportingMode == "Mode: active") {
|
||||
void SDS011_init()
|
||||
{
|
||||
if (SDS011_init_flag)
|
||||
{
|
||||
|
||||
#ifdef ESP8266
|
||||
|
||||
if (!sds)
|
||||
{
|
||||
Serial.println("no sds, creating");
|
||||
sds = new SdsDustSensor(rxPinSDS, txPinSDS, retryDelayMs, maxRetriesNotAvailable);
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("sds already created");
|
||||
}
|
||||
|
||||
sds->begin(9600);
|
||||
delay(200); //
|
||||
#endif
|
||||
|
||||
#ifdef ESP32
|
||||
sdsSerial.begin(9600, SERIAL_8N1, rxPinSDS, txPinSDS);
|
||||
delay(200);
|
||||
if (!sds)
|
||||
{
|
||||
Serial.println("no sds, creating");
|
||||
sds = new SdsDustSensor(sdsSerial, retryDelayMs, maxRetriesNotAvailable);
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("sds already created");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (startUp)
|
||||
{
|
||||
sds->wakeup();
|
||||
SerialPrint("i", "Sensor Sds011", "wakeup on startUp"); // уже начинаем продувку
|
||||
startUp = false;
|
||||
}
|
||||
String msg = sds->queryFirmwareVersion().toString(); //
|
||||
SerialPrint("i", "Sensor Sds011", msg);
|
||||
String ReportingMode = sds->setActiveReportingMode().toString();
|
||||
|
||||
if (ReportingMode == "Mode: active")
|
||||
{
|
||||
SerialPrint("i", "Sensor Sds011", ReportingMode);
|
||||
SDS011_init_flag = false;
|
||||
if (continuous)
|
||||
{
|
||||
sds->wakeup();
|
||||
SerialPrint("i", "Sensor Sds011", "wakeUp if continuous");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportingMode += " - check wiring!";
|
||||
SerialPrint("E", "Sensor Sds011", ReportingMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"menuSection": "Сенсоры",
|
||||
"configItem": [
|
||||
{
|
||||
"name": "SDS011 PM25 Датчик пыли",
|
||||
"name": "SDS011 PM25 Пыль",
|
||||
"type": "Reading",
|
||||
"subtype": "Sds011_25",
|
||||
"id": "pmuart25",
|
||||
@@ -12,14 +12,16 @@
|
||||
"plus": 0,
|
||||
"multiply": 1,
|
||||
"round": 10,
|
||||
"rxPin": 13,
|
||||
"txPin": 12,
|
||||
"int": 15,
|
||||
"warmUp": 30,
|
||||
"period": 300
|
||||
"rxPin": 14,
|
||||
"txPin": 16,
|
||||
"int": 270,
|
||||
"purge": 30,
|
||||
"continuousMode": 0,
|
||||
"maxRetriesNotAvailable": 100,
|
||||
"retryDelayMs": 5
|
||||
},
|
||||
{
|
||||
"name": "SDS011 PM10 Датчик пыли",
|
||||
"name": "SDS011 PM10 Пыль",
|
||||
"type": "Reading",
|
||||
"subtype": "Sds011_10",
|
||||
"id": "pmuart10",
|
||||
@@ -29,33 +31,34 @@
|
||||
"plus": 0,
|
||||
"multiply": 1,
|
||||
"round": 10,
|
||||
"rxPin": 13,
|
||||
"txPin": 12,
|
||||
"int": 15,
|
||||
"warmUp": 30,
|
||||
"period": 300
|
||||
"rxPin": 14,
|
||||
"txPin": 16,
|
||||
"int": 270,
|
||||
"purge": 30,
|
||||
"continuousMode": 0,
|
||||
"maxRetriesNotAvailable": 100,
|
||||
"retryDelayMs": 5
|
||||
}
|
||||
],
|
||||
"about": {
|
||||
"authorName": "Alex K",
|
||||
"authorContact": "https://t.me/cmche",
|
||||
"authorGit": "",
|
||||
"authorGit": "https://github.com/CHE77/SDS011forIotManager",
|
||||
"specialThanks": "",
|
||||
"moduleName": "Sds011",
|
||||
"moduleVersion": "1.0",
|
||||
"usedRam": 15,
|
||||
"subTypes": [
|
||||
"Sds011_25",
|
||||
"Sds011_10"
|
||||
],
|
||||
"title": "Датчик пыли",
|
||||
"moduleVersion": "2.0 - можно переназначать пины, за один опрос - обновляются два элемента",
|
||||
"moduleDesc": "Позволяет получить значения концентрации пыли в воздухе с Sds011.",
|
||||
"propInfo": {
|
||||
"int": "Количество секунд между опросами датчика.",
|
||||
"rxPin": "",
|
||||
"txPin": "",
|
||||
"warmUp": "",
|
||||
"period": ""
|
||||
"plus": "поправочный коэффиент +c",
|
||||
"multiply": "поправочный коэффиент k*",
|
||||
"round": "округление",
|
||||
"rxPin": "Esp8266: GPIO 14 - D5, ESP32: GPIO 16 - RX2, > подключаем к TXD сенсора",
|
||||
"txPin": "Esp8266: GPIO 16 - D0, ESP32: GPIO 17 - TX2, > подключаем к RXD сенсора",
|
||||
"int": "Количество секунд между опросами датчика",
|
||||
"purge": "Время продувки сенсора перед замером. Cек.",
|
||||
"continuousMode": "1 - Непрерывный режим, 0 - Режим с остановкой (щедящий)",
|
||||
"maxRetriesNotAvailable": "Количество попыток ожидания ответа сенсора при опросе (не нужно менять)",
|
||||
"retryDelayMs": "Задержка между попытками, миллисекунды (не нужно менять)"
|
||||
}
|
||||
},
|
||||
"defActive": false,
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
"subTypes": [
|
||||
"SoftUART"
|
||||
],
|
||||
"title": "Софтовый uart для esp8266 или harware uart для esp32",
|
||||
"moduleDesc": "Используется вместе с Pzem004t, в последствии будет доработан для связи с arduino платами",
|
||||
"title": "Software uart для esp8266 или hardware uart для esp32",
|
||||
"moduleDesc": "Используется вместе с Pzem004t или с другими работающими по uart сенсорами, в последствии будет доработан для связи с arduino платами",
|
||||
"propInfo": {
|
||||
"tx": "TX пин",
|
||||
"rx": "RX пин",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"menuSection": "Виртуальные элементы",
|
||||
"configItem": [
|
||||
{
|
||||
"name": "Логирование в график",
|
||||
"name": "График",
|
||||
"type": "Writing",
|
||||
"subtype": "Loging",
|
||||
"id": "log",
|
||||
@@ -24,7 +24,7 @@
|
||||
"moduleVersion": "3.0",
|
||||
"usedRam": 15,
|
||||
"title": "Логирование в график",
|
||||
"moduleDesc": "Расширение позволяющее логировать любую величину в график. Графики доступны в мобильном приложении и в веб интерфейсе. Данные графиков хранятся в встроенной памяти esp. В окне ввода даты нужно выбрать день, историю которого вы хотите посмотреть. Старые файлы будут удаляться автоматически после того как объем оставшейся flesh памяти устройства будет менее 20 процентов",
|
||||
"moduleDesc": "Расширение позволяющее логировать любую величину в график. Графики доступны в мобильном приложении и в веб интерфейсе. Данные графиков хранятся в встроенной памяти esp. В окне ввода даты можно выбирать день, историю которого вы хотите посмотреть. Старые файлы будут удаляться автоматически после того как объем оставшейся flesh памяти устройства будет менее 20 процентов",
|
||||
"propInfo": {
|
||||
"int": "Интервал логирования в мнутах, рекомендуется для esp8266 использоать интервал не менее 5-ти минут",
|
||||
"logid": "ID величины которую будем логировать",
|
||||
282
src/modules/virtual/LogingDaily/LogingDaily.cpp
Normal file
282
src/modules/virtual/LogingDaily/LogingDaily.cpp
Normal file
@@ -0,0 +1,282 @@
|
||||
#include "Global.h"
|
||||
#include "classes/IoTItem.h"
|
||||
#include "ESPConfiguration.h"
|
||||
#include "NTP.h"
|
||||
|
||||
class LogingDaily : public IoTItem {
|
||||
private:
|
||||
String logid;
|
||||
String id;
|
||||
String filesList = "";
|
||||
|
||||
int _publishType = -2;
|
||||
int _wsNum = -1;
|
||||
|
||||
int points;
|
||||
|
||||
IoTItem *dateIoTItem;
|
||||
|
||||
String prevDate = "";
|
||||
bool firstTimeDate = true;
|
||||
|
||||
unsigned long interval;
|
||||
|
||||
public:
|
||||
LogingDaily(String parameters) : IoTItem(parameters) {
|
||||
jsonRead(parameters, F("logid"), logid);
|
||||
jsonRead(parameters, F("id"), id);
|
||||
jsonRead(parameters, F("points"), points);
|
||||
|
||||
if (points > 365) {
|
||||
points = 365;
|
||||
SerialPrint("E", F("LogingDaily"), "'" + id + "' user set more points than allowed, value reset to 365");
|
||||
}
|
||||
jsonRead(parameters, F("int"), interval);
|
||||
interval = interval * 1000 * 60; //приводим к милисекундам
|
||||
}
|
||||
|
||||
void doByInterval() {
|
||||
if (hasDayChanged()) {
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
void execute() {
|
||||
//если объект логгирования не был создан
|
||||
if (!isItemExist(logid)) {
|
||||
SerialPrint("E", F("LogingDaily"), "'" + id + "' LogingDaily object not exist, return");
|
||||
return;
|
||||
}
|
||||
|
||||
String value = getItemValue(logid);
|
||||
|
||||
//если значение логгирования пустое
|
||||
if (value == "") {
|
||||
SerialPrint("E", F("LogingDaily"), "'" + id + "' LogingDaily value is empty, return");
|
||||
return;
|
||||
}
|
||||
|
||||
//если время не было получено из интернета
|
||||
if (!isTimeSynch) {
|
||||
SerialPrint("E", F("LogingDaily"), "'" + id + "' Сant LogingDaily - time not synchronized, return");
|
||||
return;
|
||||
}
|
||||
|
||||
String logData;
|
||||
|
||||
float currentValue = value.toFloat();
|
||||
//прочитаем предудущее значение
|
||||
float prevValue = readDataDB(id + "-v").toFloat();
|
||||
//сохраним в базу данных текущее значение, понадобится в следующие сутки
|
||||
saveDataDB(id + "-v", value);
|
||||
|
||||
float difference = currentValue - prevValue;
|
||||
|
||||
jsonWriteInt(logData, "x", unixTime);
|
||||
jsonWriteFloat(logData, "y1", difference);
|
||||
|
||||
//прочитаем путь к файлу последнего сохранения
|
||||
String filePath = readDataDB(id);
|
||||
|
||||
//если данные о файле отсутствуют, создадим новый
|
||||
if (filePath == "failed" || filePath == "") {
|
||||
SerialPrint("E", F("LogingDaily"), "'" + id + "' file path not found, start create new file");
|
||||
createNewFileWithData(logData);
|
||||
return;
|
||||
}
|
||||
|
||||
//считаем количество строк и определяем размер файла
|
||||
size_t size = 0;
|
||||
int lines = countJsonObj(filePath, size);
|
||||
SerialPrint("i", F("LogingDaily"), "'" + id + "' " + "lines = " + String(lines) + ", size = " + String(size));
|
||||
|
||||
//если количество строк до заданной величины и дата не менялась
|
||||
if (lines <= points && !hasDayChanged()) {
|
||||
//просто добавим в существующий файл новые данные
|
||||
addNewDataToExistingFile(filePath, logData);
|
||||
//если больше или поменялась дата то создадим следующий файл
|
||||
} else {
|
||||
createNewFileWithData(logData);
|
||||
}
|
||||
}
|
||||
|
||||
void createNewFileWithData(String &logData) {
|
||||
logData = logData + ",";
|
||||
|
||||
String path = "/lgd/" + id + "/" + id + ".txt"; //создадим путь вида /lgd/id/id.txt
|
||||
//создадим пустой файл
|
||||
if (writeEmptyFile(path) != "sucсess") {
|
||||
SerialPrint("E", F("LogingDaily"), "'" + id + "' file writing error, return");
|
||||
return;
|
||||
}
|
||||
|
||||
//запишем в него данные
|
||||
if (addFile(path, logData) != "sucсess") {
|
||||
SerialPrint("E", F("LogingDaily"), "'" + id + "' data writing error, return");
|
||||
return;
|
||||
}
|
||||
//запишем путь к нему в базу данных
|
||||
if (saveDataDB(id, path) != "sucсess") {
|
||||
SerialPrint("E", F("LogingDaily"), "'" + id + "' db file writing error, return");
|
||||
return;
|
||||
}
|
||||
SerialPrint("i", F("LogingDaily"), "'" + id + "' file created http://" + WiFi.localIP().toString() + path);
|
||||
}
|
||||
|
||||
void addNewDataToExistingFile(String &path, String &logData) {
|
||||
logData = logData + ",";
|
||||
if (addFile(path, logData) != "sucсess") {
|
||||
SerialPrint("i", F("LogingDaily"), "'" + id + "' file writing error, return");
|
||||
return;
|
||||
};
|
||||
SerialPrint("i", F("LogingDaily"), "'" + id + "' LogingDaily in file http://" + WiFi.localIP().toString() + path);
|
||||
}
|
||||
|
||||
bool hasDayChanged() {
|
||||
bool changed = false;
|
||||
String currentDate = getTodayDateDotFormated();
|
||||
if (!firstTimeDate) {
|
||||
if (prevDate != currentDate) {
|
||||
changed = true;
|
||||
SerialPrint("i", F("NTP"), "Change day event");
|
||||
#if defined(ESP8266)
|
||||
FileFS.gc();
|
||||
#endif
|
||||
#if defined(ESP32)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
firstTimeDate = false;
|
||||
prevDate = currentDate;
|
||||
return changed;
|
||||
}
|
||||
|
||||
void publishValue() {
|
||||
String dir = "/lgd/" + id;
|
||||
filesList = getFilesList(dir);
|
||||
|
||||
SerialPrint("i", F("LogingDaily"), "file list: " + filesList);
|
||||
|
||||
int f = 0;
|
||||
|
||||
while (filesList.length()) {
|
||||
String path = selectToMarker(filesList, ";");
|
||||
|
||||
path = "/lgd/" + id + path;
|
||||
|
||||
f++;
|
||||
|
||||
if (_publishType == TO_MQTT) {
|
||||
publishChartFileToMqtt(path);
|
||||
} else if (_publishType == TO_WS) {
|
||||
publishChartToWs(path, _wsNum, 1000);
|
||||
} else if (_publishType == TO_MQTT_WS) {
|
||||
publishChartFileToMqtt(path);
|
||||
publishChartToWs(path, _wsNum, 1000);
|
||||
}
|
||||
SerialPrint("i", F("LogingDaily"), String(f) + ") " + path + ", sent");
|
||||
|
||||
filesList = deleteBeforeDelimiter(filesList, ";");
|
||||
}
|
||||
}
|
||||
|
||||
void clearHistory() {
|
||||
String dir = "/lgd/" + id;
|
||||
cleanDirectory(dir);
|
||||
}
|
||||
|
||||
bool publishChartFileToMqtt(String path) {
|
||||
File configFile = FileFS.open(path, FILE_READ);
|
||||
if (!configFile) {
|
||||
SerialPrint("E", F("LogingDaily"), path + " file reading error, json not created, return");
|
||||
return false;
|
||||
}
|
||||
String oneSingleJson = configFile.readString();
|
||||
configFile.close();
|
||||
String topic = mqttRootDevice + "/" + id;
|
||||
oneSingleJson = "{\"maxCount\":" + String(calculateMaxCount()) + ",\"topic\":\"" + topic + "\",\"status\":[" + oneSingleJson + "]}";
|
||||
oneSingleJson.replace("},]}", "}]}");
|
||||
SerialPrint("i", "LogingDaily", "json size: " + String(oneSingleJson.length()));
|
||||
publishChartMqtt(id, oneSingleJson);
|
||||
return true;
|
||||
}
|
||||
|
||||
//особая функция отправки графиков в веб
|
||||
void publishChartToWs(String filename, int num, size_t frameSize) {
|
||||
String json;
|
||||
jsonWriteStr(json, "topic", mqttRootDevice + "/" + id);
|
||||
jsonWriteInt(json, "maxCount", calculateMaxCount());
|
||||
|
||||
String st = "/st/chart.json|";
|
||||
if (num == -1) {
|
||||
standWebSocket.broadcastTXT(st);
|
||||
} else {
|
||||
standWebSocket.sendTXT(num, st);
|
||||
}
|
||||
String path = filepath(filename);
|
||||
auto file = FileFS.open(path, "r");
|
||||
if (!file) {
|
||||
SerialPrint(F("E"), F("FS"), F("reed file error"));
|
||||
return;
|
||||
}
|
||||
size_t fileSize = file.size();
|
||||
SerialPrint(F("i"), F("FS"), "Send file '" + String(filename) + "', file size: " + String(fileSize));
|
||||
uint8_t payload[frameSize];
|
||||
int countRead = file.read(payload, sizeof(payload));
|
||||
while (countRead > 0) {
|
||||
if (num == -1) {
|
||||
standWebSocket.broadcastBIN(payload, countRead);
|
||||
} else {
|
||||
standWebSocket.sendBIN(num, payload, countRead);
|
||||
}
|
||||
countRead = file.read(payload, sizeof(payload));
|
||||
}
|
||||
file.close();
|
||||
String end = "/end/chart.json|" + json;
|
||||
if (num == -1) {
|
||||
standWebSocket.broadcastTXT(end);
|
||||
} else {
|
||||
standWebSocket.sendTXT(num, end);
|
||||
}
|
||||
}
|
||||
|
||||
void publishChartToWsSinglePoint(String value) {
|
||||
String topic = mqttRootDevice + "/" + id;
|
||||
String json = "{\"maxCount\":" + String(calculateMaxCount()) + ",\"topic\":\"" + topic + "\",\"status\":[{\"x\":" + String(unixTime) + ",\"y1\":" + value + "}]}";
|
||||
String pk = "/string/chart.json|" + json;
|
||||
standWebSocket.broadcastTXT(pk);
|
||||
}
|
||||
|
||||
void setPublishDestination(int publishType, int wsNum = -1) {
|
||||
_publishType = publishType;
|
||||
_wsNum = wsNum;
|
||||
}
|
||||
|
||||
String getValue() {
|
||||
return "";
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (enableDoByInt) {
|
||||
currentMillis = millis();
|
||||
difference = currentMillis - prevMillis;
|
||||
if (difference >= interval) {
|
||||
prevMillis = millis();
|
||||
this->doByInterval();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//просто максимальное количество точек
|
||||
int calculateMaxCount() {
|
||||
return 86400;
|
||||
}
|
||||
};
|
||||
|
||||
void *getAPI_LogingDaily(String subtype, String param) {
|
||||
if (subtype == F("LogingDaily")) {
|
||||
return new LogingDaily(param);
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
39
src/modules/virtual/LogingDaily/modinfo.json
Normal file
39
src/modules/virtual/LogingDaily/modinfo.json
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"menuSection": "Виртуальные элементы",
|
||||
"configItem": [
|
||||
{
|
||||
"name": "График дневного расхода",
|
||||
"type": "Writing",
|
||||
"subtype": "LogingDaily",
|
||||
"id": "log",
|
||||
"widget": "chart3",
|
||||
"page": "Графики",
|
||||
"descr": "Температура",
|
||||
"num": 1,
|
||||
"int": 1,
|
||||
"logid": "t",
|
||||
"points": 365
|
||||
}
|
||||
],
|
||||
"about": {
|
||||
"authorName": "Dmitry Borisenko",
|
||||
"authorContact": "https://t.me/Dmitry_Borisenko",
|
||||
"authorGit": "https://github.com/DmitryBorisenko33",
|
||||
"specialThanks": "@itsid1 @Valiuhaaa Serg",
|
||||
"moduleName": "LogingDaily",
|
||||
"moduleVersion": "3.0",
|
||||
"usedRam": 15,
|
||||
"title": "График дневного расхода",
|
||||
"moduleDesc": "Расширение позволяющее логировать накопительные величины и видеть их дневное изменение. Графики доступны в мобильном приложении и в веб интерфейсе. Данные графиков хранятся в встроенной памяти esp",
|
||||
"propInfo": {
|
||||
"int": "Интервал логирования в мнутах, частота проверки смены суток в минутах. Не рекомендуется менять",
|
||||
"logid": "ID накопительной величины которую будем логировать",
|
||||
"points": "Максимальное количество точек"
|
||||
}
|
||||
},
|
||||
"defActive": true,
|
||||
"devices": {
|
||||
"esp32_4mb": [],
|
||||
"esp8266_4mb": []
|
||||
}
|
||||
}
|
||||
@@ -214,9 +214,10 @@ String readDataDB(String id) {
|
||||
void cleanLogs() {
|
||||
SerialPrint("i", "Files", "cleanLogs");
|
||||
cleanDirectory("/db");
|
||||
//обращение к логированию из ядра
|
||||
//очистка данных всех экземпляров графиков
|
||||
for (std::list<IoTItem*>::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) {
|
||||
if ((*it)->getSubtype() == "Loging") {
|
||||
if ((*it)->getSubtype() == "Loging" || "LogingDaily") {
|
||||
(*it)->clearHistory();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user