diff --git a/data_svelte/items.json b/data_svelte/items.json index 4885076c..e5357277 100644 --- a/data_svelte/items.json +++ b/data_svelte/items.json @@ -361,8 +361,32 @@ "num": 26 }, { - "name": "27. Сонар HC-SR04", - "num": 27, + "name": "27. Cенсор температуры Sht30", + "type": "Reading", + "subtype": "Sht30t", + "id": "tmp30", + "widget": "anydataTmp", + "page": "Сенсоры", + "descr": "SHT30 Температура", + "int": 15, + "round": 1, + "num": 27 + }, + { + "name": "28. Cенсор влажности Sht30", + "type": "Reading", + "subtype": "Sht30h", + "id": "Hum30", + "widget": "anydataHum", + "page": "Сенсоры", + "descr": "SHT30 Влажность", + "int": 15, + "round": 1, + "num": 28 + }, + { + "name": "29. Сонар HC-SR04", + "num": 29, "type": "Reading", "subtype": "Sonar", "id": "sonar", @@ -377,7 +401,7 @@ "header": "Расширения" }, { - "name": "28. Поддержка DS1302(1), DS1307(2), DS3231(3), RX8025(4)", + "name": "30. Поддержка DS1302(1), DS1307(2), DS3231(3), RX8025(4)", "type": "Reading", "subtype": "IarduinoRTC", "id": "RTC", @@ -391,10 +415,10 @@ "dat": 4, "defFormat": "d-m-Y", "ticker": 0, - "num": 28 + "num": 30 }, { - "name": "29. Расширитель портов Mcp23017", + "name": "31. Расширитель портов Mcp23017", "type": "Reading", "subtype": "Mcp23017", "id": "Mcp", @@ -404,10 +428,10 @@ "int": "0", "addr": "0x20", "index": 1, - "num": 29 + "num": 31 }, { - "name": "30. Доп. функции системы", + "name": "32. Доп. функции системы", "type": "Reading", "subtype": "SysExt", "id": "SysExt", @@ -415,10 +439,10 @@ "page": "", "descr": "", "int": 15, - "num": 30 + "num": 32 }, { - "name": "31. Переменная", + "name": "33. Переменная", "type": "Reading", "subtype": "Variable", "id": "var", @@ -427,6 +451,6 @@ "descr": "", "int": "0", "val": "0", - "num": 31 + "num": 33 } ] \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index da9be68c..f51d2b09 100644 --- a/platformio.ini +++ b/platformio.ini @@ -103,6 +103,7 @@ lib_deps = adafruit/MAX6675 library rc-switch @ ^2.6.4 robtillaart/SHT2x@^0.1.1 + WEMOS SHT3x@1.0.0 adafruit/Adafruit MCP23017 Arduino Library@^2.0.2 adafruit/Adafruit BusIO @ ^1.13.0 build_src_filter = @@ -123,6 +124,7 @@ build_src_filter = + + + + + + + + diff --git a/src/modules/API.cpp b/src/modules/API.cpp index ca2bbd17..079c1061 100644 --- a/src/modules/API.cpp +++ b/src/modules/API.cpp @@ -17,6 +17,7 @@ void* getAPI_Hdc1080(String subtype, String params); void* getAPI_Max6675(String subtype, String params); void* getAPI_RCswitch(String subtype, String params); void* getAPI_Sht20(String subtype, String params); +void* getAPI_Sht30(String subtype, String params); void* getAPI_Sonar(String subtype, String params); void* getAPI_IarduinoRTC(String subtype, String params); void* getAPI_Mcp23017(String subtype, String params); @@ -42,6 +43,7 @@ if ((tmpAPI = getAPI_Hdc1080(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Max6675(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_RCswitch(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Sht20(subtype, params)) != nullptr) return tmpAPI; +if ((tmpAPI = getAPI_Sht30(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Sonar(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_IarduinoRTC(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Mcp23017(subtype, params)) != nullptr) return tmpAPI; diff --git a/src/modules/sensors/Sht30/Sht30.cpp b/src/modules/sensors/Sht30/Sht30.cpp new file mode 100644 index 00000000..d0a927b6 --- /dev/null +++ b/src/modules/sensors/Sht30/Sht30.cpp @@ -0,0 +1,61 @@ +/****************************************************************** + Simple library for the WEMOS SHT30 Shield. + + https://github.com/wemos/WEMOS_SHT3x_Arduino_Library + + adapted for version 4 @Serghei63 + ******************************************************************/ + +#include "Global.h" +#include "classes/IoTItem.h" + + +#include "Wire.h" +#include + +SHT3X sht30(0x45); + +class Sht30t : public IoTItem { + public: + Sht30t(String parameters): IoTItem(parameters) { } + + void doByInterval() { + if(sht30.get()==0){ + value.valD = sht30.cTemp; + + SerialPrint("E", "Sensor Sht30t", "OK"); + + if (value.valD < -46.85F) regEvent(value.valD, "Sht30t"); // TODO: найти способ понимания ошибки получения данных + else SerialPrint("E", "Sensor Sht30t", "Error"); + } + } + ~Sht30t() {}; +}; + +class Sht30h : public IoTItem { + public: + Sht30h(String parameters): IoTItem(parameters) { } + + void doByInterval() { + if(sht30.get()==0){ + value.valD = sht30.humidity; + + SerialPrint("E", "Sensor Sht30h", "OK"); + if (value.valD != -6) regEvent(value.valD, "Sht30h"); // TODO: найти способ понимания ошибки получения данных + else SerialPrint("E", "Sensor Sht30h", "Error"); + } + } + ~Sht30h() {}; +}; + + +void* getAPI_Sht30(String subtype, String param) { + if (subtype == F("Sht30t")){ + return new Sht30t(param); + } + if (subtype == F("Sht30h")) { + return new Sht30h(param); + } else { + return nullptr; + } +} diff --git a/src/modules/sensors/Sht30/modinfo.json b/src/modules/sensors/Sht30/modinfo.json new file mode 100644 index 00000000..ad5b9c22 --- /dev/null +++ b/src/modules/sensors/Sht30/modinfo.json @@ -0,0 +1,50 @@ +{ + "menuSection": "Сенсоры", + + "configItem": [{ + "name": "Cенсор температуры Sht30", + "type": "Reading", + "subtype": "Sht30t", + "id": "tmp30", + "widget": "anydataTmp", + "page": "Сенсоры", + "descr": "SHT30 Температура", + "int": 15, + "round": 1 + }, + { + "name": "Cенсор влажности Sht30", + "type": "Reading", + "subtype": "Sht30h", + "id": "Hum30", + "widget": "anydataHum", + "page": "Сенсоры", + "descr": "SHT30 Влажность", + "int": 15, + "round": 1 + }], + + "about": { + "authorName": "Serghei Crasnicov", + "authorContact": "https://t.me/Serghei63", + "authorGit": "https://github.com/Serghei63", + "specialThanks": "", + "moduleName": "Sht30", + "moduleVersion": "1.0", + "moduleDesc": "Позволяет получить температуру и влажность с датчика Sht30.", + "propInfo": { + "int": "Количество секунд между опросами датчика." + } + }, + + "defActive": true, + + "devices": { + "esp32_4mb": [ + "WEMOS SHT3x@1.0.0" + ], + "esp8266_4mb": [ + "WEMOS SHT3x@1.0.0" + ] + } +} \ No newline at end of file