Добавляем sht30

This commit is contained in:
2022-08-09 21:48:48 +03:00
parent 41286083b7
commit 6b582cb2bd
5 changed files with 149 additions and 10 deletions

View File

@@ -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
}
]

View File

@@ -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 =
+<modules\sensors\Max6675>
+<modules\sensors\RCswitch>
+<modules\sensors\Sht20>
+<modules\sensors\Sht30>
+<modules\sensors\Sonar>
+<modules\system\IarduinoRTC>
+<modules\system\Mcp23017>

View File

@@ -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;

View File

@@ -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 <WEMOS_SHT3X.h>
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;
}
}

View File

@@ -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"
]
}
}