mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-27 06:32:19 +03:00
Добавляем sht30
This commit is contained in:
@@ -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;
|
||||
|
||||
61
src/modules/sensors/Sht30/Sht30.cpp
Normal file
61
src/modules/sensors/Sht30/Sht30.cpp
Normal 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;
|
||||
}
|
||||
}
|
||||
50
src/modules/sensors/Sht30/modinfo.json
Normal file
50
src/modules/sensors/Sht30/modinfo.json
Normal 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"
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user