Добавляем Bh1750 и Dwini

This commit is contained in:
2023-03-07 16:03:52 +03:00
parent 2c89974a6a
commit e0df67ccee
6 changed files with 418 additions and 24 deletions

View File

@@ -117,7 +117,21 @@
}, },
{ {
"global": 0, "global": 0,
"name": "8. Виртуальная кнопка", "name": "8. Цветной текст",
"type": "Reading",
"subtype": "VariableColor",
"id": "color",
"needSave": 0,
"widget": "anydataDef",
"page": "Вывод",
"descr": "Цветной текст",
"val": "...",
"round": 0,
"num": 8
},
{
"global": 0,
"name": "9. Виртуальная кнопка",
"type": "Reading", "type": "Reading",
"subtype": "VButton", "subtype": "VButton",
"id": "vbtn", "id": "vbtn",
@@ -127,14 +141,77 @@
"descr": "Кнопка", "descr": "Кнопка",
"int": "0", "int": "0",
"val": "0", "val": "0",
"num": 8 "num": 9
},
{
"global": 0,
"name": "10. Погода",
"type": "Reading",
"subtype": "Weather",
"id": "Weather",
"needSave": 0,
"widget": "anydataDef",
"page": "Погода",
"descr": "",
"int": 3,
"location": "Moscow",
"param": "temp_C",
"round": 0,
"val": "...",
"num": 10
}, },
{ {
"header": "Сенсоры" "header": "Сенсоры"
}, },
{ {
"global": 0, "global": 0,
"name": "9. DS18B20 Температура", "name": "11. Аналоговый сенсор",
"type": "Reading",
"subtype": "AnalogAdc",
"id": "t",
"widget": "anydataTmp",
"page": "Сенсоры",
"descr": "Температура",
"map": "1,1024,1,100",
"plus": 0,
"multiply": 1,
"round": 1,
"pin": 0,
"int": 15,
"avgSteps": 1,
"num": 11
},
{
"global": 0,
"name": "12. BMP280 Температура",
"type": "Reading",
"subtype": "Bmp280t",
"id": "tmp3",
"widget": "anydataTmp",
"page": "Сенсоры",
"descr": "280 Температура",
"int": 15,
"addr": "0x77",
"round": 1,
"num": 12
},
{
"global": 0,
"name": "13. BMP280 Давление",
"type": "Reading",
"subtype": "Bmp280p",
"id": "Press3",
"widget": "anydataMm",
"page": "Сенсоры",
"descr": "280 Давление",
"int": 15,
"addr": "0x77",
"round": 1,
"num": 13
},
{
"global": 0,
"name": "14. DS18B20 Температура",
"type": "Reading", "type": "Reading",
"subtype": "Ds18b20", "subtype": "Ds18b20",
"id": "dstmp", "id": "dstmp",
@@ -146,12 +223,107 @@
"index": 0, "index": 0,
"addr": "", "addr": "",
"round": 1, "round": 1,
"num": 9 "num": 14
}, },
{ {
"global": 0, "global": 0,
"name": "10. HC-SR04 Ультразвуковой дальномер", "name": "15. Сканер DS2401 меток",
"num": 10, "type": "Reading",
"subtype": "DS2401",
"id": "rds",
"int": 100,
"intRepeat": 6,
"pin": 12,
"num": 15
},
{
"global": 0,
"name": "16. Сканер кнопок 433 MHz",
"num": 16,
"type": "Reading",
"subtype": "RCswitch",
"id": "rsw",
"int": 100,
"intRepeat": 6,
"pinRx": 12,
"pinTx": 12
},
{
"global": 0,
"name": "17. Часы реального времени",
"type": "Reading",
"subtype": "RTC",
"id": "rtc",
"widget": "anydataDef",
"page": "Таймеры",
"descr": "Время RTC",
"chipCode": 1,
"timeFormat": "d-m-Y H:i:s",
"RST": -1,
"CLK": -1,
"DAT": -1,
"ticker": 0,
"int": 5,
"btn-setUTime": "0",
"btn-setSysTime": "nil",
"num": 17
},
{
"global": 0,
"name": "18. Sht20 Температура",
"type": "Reading",
"subtype": "Sht20t",
"id": "tmp2",
"widget": "anydataTmp",
"page": "Сенсоры",
"descr": "Температура",
"int": 15,
"round": 1,
"num": 18
},
{
"global": 0,
"name": "19. Sht20 Влажность",
"type": "Reading",
"subtype": "Sht20h",
"id": "Hum2",
"widget": "anydataHum",
"page": "Сенсоры",
"descr": "Влажность",
"int": 15,
"round": 1,
"num": 19
},
{
"global": 0,
"name": "20. Sht30 Температура",
"type": "Reading",
"subtype": "Sht30t",
"id": "tmp30",
"widget": "anydataTmp",
"page": "Сенсоры",
"descr": "SHT30 Температура",
"int": 15,
"round": 1,
"num": 20
},
{
"global": 0,
"name": "21. Sht30 Влажность",
"type": "Reading",
"subtype": "Sht30h",
"id": "Hum30",
"widget": "anydataHum",
"page": "Сенсоры",
"descr": "SHT30 Влажность",
"int": 15,
"round": 1,
"num": 21
},
{
"global": 0,
"name": "22. HC-SR04 Ультразвуковой дальномер",
"num": 22,
"type": "Reading", "type": "Reading",
"subtype": "Sonar", "subtype": "Sonar",
"id": "sonar", "id": "sonar",
@@ -167,7 +339,7 @@
}, },
{ {
"global": 0, "global": 0,
"name": "11. Кнопка подключенная к пину", "name": "23. Кнопка подключенная к пину",
"type": "Writing", "type": "Writing",
"subtype": "ButtonIn", "subtype": "ButtonIn",
"id": "btn", "id": "btn",
@@ -181,11 +353,12 @@
"pinMode": "INPUT", "pinMode": "INPUT",
"debounceDelay": 50, "debounceDelay": 50,
"fixState": 0, "fixState": 0,
"num": 11 "inv": 0,
"num": 23
}, },
{ {
"global": 0, "global": 0,
"name": "12. Управление пином", "name": "24. Управление пином",
"type": "Writing", "type": "Writing",
"subtype": "ButtonOut", "subtype": "ButtonOut",
"needSave": 0, "needSave": 0,
@@ -196,11 +369,11 @@
"int": 0, "int": 0,
"inv": 0, "inv": 0,
"pin": 2, "pin": 2,
"num": 12 "num": 24
}, },
{ {
"global": 0, "global": 0,
"name": "13. Расширитель портов Mcp23017", "name": "25. Расширитель портов Mcp23017",
"type": "Reading", "type": "Reading",
"subtype": "Mcp23017", "subtype": "Mcp23017",
"id": "Mcp", "id": "Mcp",
@@ -210,11 +383,11 @@
"int": "0", "int": "0",
"addr": "0x20", "addr": "0x20",
"index": 1, "index": 1,
"num": 13 "num": 25
}, },
{ {
"global": 0, "global": 0,
"name": "14. Сенсорная кнопка", "name": "26. Сенсорная кнопка",
"type": "Writing", "type": "Writing",
"subtype": "Multitouch", "subtype": "Multitouch",
"id": "impulse", "id": "impulse",
@@ -228,11 +401,11 @@
"pinMode": "INPUT", "pinMode": "INPUT",
"debounceDelay": 50, "debounceDelay": 50,
"PWMDelay": 500, "PWMDelay": 500,
"num": 14 "num": 26
}, },
{ {
"global": 0, "global": 0,
"name": "15. Расширитель портов Pcf8574", "name": "27. Расширитель портов Pcf8574",
"type": "Reading", "type": "Reading",
"subtype": "Pcf8574", "subtype": "Pcf8574",
"id": "Pcf", "id": "Pcf",
@@ -242,11 +415,11 @@
"int": "0", "int": "0",
"addr": "0x20", "addr": "0x20",
"index": 1, "index": 1,
"num": 15 "num": 27
}, },
{ {
"global": 0, "global": 0,
"name": "16. PWM ESP8266", "name": "28. PWM ESP8266",
"type": "Writing", "type": "Writing",
"subtype": "Pwm8266", "subtype": "Pwm8266",
"id": "pwm", "id": "pwm",
@@ -258,11 +431,11 @@
"freq": 5000, "freq": 5000,
"val": 0, "val": 0,
"apin": -1, "apin": -1,
"num": 16 "num": 28
}, },
{ {
"global": 0, "global": 0,
"name": "17. Телеграм-Лайт", "name": "29. Телеграм-Лайт",
"type": "Writing", "type": "Writing",
"subtype": "TelegramLT", "subtype": "TelegramLT",
"id": "tg", "id": "tg",
@@ -271,14 +444,30 @@
"descr": "", "descr": "",
"token": "", "token": "",
"chatID": "", "chatID": "",
"num": 17 "num": 29
}, },
{ {
"header": "Экраны" "header": "Экраны"
}, },
{ {
"global": 0, "global": 0,
"name": "18. LCD экран 2004", "name": "30. LCD Dwin экран",
"type": "Reading",
"subtype": "DwinI",
"id": "dwin",
"widget": "",
"page": "",
"descr": "",
"int": 15,
"TX": 17,
"RX": 16,
"line": 2,
"speed": 115200,
"num": 30
},
{
"global": 0,
"name": "31. LCD экран 2004",
"type": "Reading", "type": "Reading",
"subtype": "Lcd2004", "subtype": "Lcd2004",
"id": "Lcd", "id": "Lcd",
@@ -290,10 +479,10 @@
"size": "20,4", "size": "20,4",
"coord": "0,0", "coord": "0,0",
"id2show": "id датчика", "id2show": "id датчика",
"num": 18 "num": 31
}, },
{ {
"name": "19. LCD экран 1602", "name": "32. LCD экран 1602",
"type": "Reading", "type": "Reading",
"subtype": "Lcd2004", "subtype": "Lcd2004",
"id": "Lcd", "id": "Lcd",
@@ -305,6 +494,6 @@
"size": "16,2", "size": "16,2",
"coord": "0,0", "coord": "0,0",
"id2show": "id датчика", "id2show": "id датчика",
"num": 19 "num": 32
} }
] ]

View File

@@ -80,6 +80,10 @@
"path": "src/modules/sensors/AnalogAdc", "path": "src/modules/sensors/AnalogAdc",
"active": true "active": true
}, },
{
"path": "src/modules/sensors/BH_1750",
"active": false
},
{ {
"path": "src/modules/sensors/Ble", "path": "src/modules/sensors/Ble",
"active": false "active": false
@@ -100,6 +104,10 @@
"path": "src/modules/sensors/Ds18b20", "path": "src/modules/sensors/Ds18b20",
"active": true "active": true
}, },
{
"path": "src/modules/sensors/DS2401",
"active": false
},
{ {
"path": "src/modules/sensors/Emon", "path": "src/modules/sensors/Emon",
"active": false "active": false
@@ -252,6 +260,10 @@
} }
], ],
"Экраны": [ "Экраны": [
{
"path": "src/modules/display/DwinI",
"active": false
},
{ {
"path": "src/modules/display/Lcd2004", "path": "src/modules/display/Lcd2004",
"active": true "active": true

View File

@@ -0,0 +1,56 @@
#include "Global.h"
#include "classes/IoTItem.h"
#ifdef ESP8266
#include <SoftwareSerial.h>
#else
#include <HardwareSerial.h>
#endif
class DwinI : public IoTItem {
private:
#ifdef ESP8266
SoftwareSerial* _myUART;
#else
HardwareSerial* _myUART;
#endif
public:
DwinI(String parameters) : IoTItem(parameters) {
int _tx, _rx, _speed, _line;
jsonRead(parameters, "RX", _rx);
jsonRead(parameters, "TX", _tx);
jsonRead(parameters, "speed", _speed);
jsonRead(parameters, "line", _line);
#ifdef ESP8266
_myUART = new SoftwareSerial(_rx, _tx);
_myUART->begin(_speed);
#endif
#ifdef ESP32
_myUART = new HardwareSerial(_line);
_myUART->begin(_speed, SERIAL_8N1, _rx, _tx);
#endif
}
void doByInterval() {
Serial.println("ddddddddddddd");
}
IoTValue execute(String command, std::vector<IoTValue> &param) { // будет возможным использовать, когда сценарии запустятся
return {};
}
~DwinI(){
};
};
void *getAPI_DwinI(String subtype, String param) {
if (subtype == F("DwinI")) {
return new DwinI(param);
} else {
return nullptr;
}
}

View File

@@ -0,0 +1,61 @@
{
"menuSection": "Экраны",
"configItem": [{
"global": 0,
"name": "LCD Dwin экран",
"type": "Reading",
"subtype": "DwinI",
"id": "dwin",
"widget": "",
"page": "",
"descr": "",
"int": 15,
"TX": 17,
"RX": 16,
"line": 2,
"speed": 115200
}],
"about": {
"authorName": "Ilya Belyakov",
"authorContact": "https://t.me/Biveraxe",
"authorGit": "https://github.com/biveraxe",
"specialThanks": "",
"moduleName": "DwinI",
"moduleVersion": "1.0",
"usedRam": {
"esp32_4mb": 15,
"esp8266_4mb": 15
},
"moduleDesc": "Позволяет выводить на графические экраны фирмы Dwin информацию от элементов конфигурации в автоматическом режиме.",
"propInfo": {
"int": ""
},
"funcInfo": [
{
"name": "rrrr",
"descr": "rrrr",
"params": []
}
]
},
"defActive": false,
"usedLibs": {
"esp32_4mb": [
],
"esp8266_4mb": [
],
"esp8266_1mb": [
],
"esp8266_1mb_ota": [
],
"esp8285_1mb": [
],
"esp8285_1mb_ota": [
]
}
}

View File

@@ -0,0 +1,32 @@
#include "Global.h"
#include "classes/IoTItem.h"
#include "BH1750.h"
class Bh1750 : public IoTItem {
BH1750 _lightMeter;
public:
Bh1750(String parameters): IoTItem(parameters){
_lightMeter.begin();
}
void doByInterval() {
value.valD = _lightMeter.readLightLevel();
if (value.valD < 70000)
regEvent(value.valD, "BH1750");
else
SerialPrint("E", "Sensor BH1750", "Error");
}
~Bh1750() {};
};
void* getAPI_Bh1750(String subtype, String param) {
if (subtype == F("Bh1750")) {
return new Bh1750(param);
} else {
return nullptr;
}
}

View File

@@ -0,0 +1,44 @@
{
"menuSection": "Сенсоры",
"configItem": [{
"global": 0,
"name": "Cенсор освещенность Bh1750",
"type": "Reading",
"subtype": "Bh1750",
"id": "Bh1750",
"widget": "anydata",
"page": "Сенсоры",
"descr": "Освещённость",
"round": 1,
"int": 15
}],
"about": {
"authorName": "Ilya Belyakov",
"authorContact": "https://t.me/Biveraxe",
"authorGit": "https://github.com/biveraxe",
"exampleURL": "https://iotmanager.org/wiki",
"specialThanks": "",
"moduleName": "Bh1750",
"moduleVersion": "1.0",
"usedRam": {
"esp32_4mb": 15,
"esp8266_4mb": 15
},
"title": "Cенсор освещённости",
"moduleDesc": "Позволяет получить текущее значение освещённости в LUX.",
"propInfo": {
"int": "Количество секунд между опросами датчика."
}
},
"defActive": false,
"usedLibs": {
"esp32_4mb": [
"BH1750"
],
"esp8266_4mb": [
"BH1750"
]
}
}