mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-31 04:19:15 +03:00
Убираем нумерацию папок модулей
This commit is contained in:
80
src/modules/sensors/Dht1122/Dht1122.cpp
Normal file
80
src/modules/sensors/Dht1122/Dht1122.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
/******************************************************************
|
||||
Used DHT Temperature & Humidity Sensor library for Arduino & ESP32.
|
||||
Support for DHT11 and DHT22/AM2302/RHT03
|
||||
https://github.com/beegee-tokyo/arduino-DHTesp
|
||||
******************************************************************/
|
||||
|
||||
|
||||
#include "Global.h"
|
||||
#include "classes/IoTItem.h"
|
||||
|
||||
#include "DHTesp.h"
|
||||
#include <map>
|
||||
|
||||
|
||||
std::map<int, DHTesp*> dhts;
|
||||
|
||||
class Dht1122t : public IoTItem {
|
||||
private:
|
||||
DHTesp* _dht;
|
||||
|
||||
public:
|
||||
Dht1122t(DHTesp* dht, String parameters): IoTItem(parameters) {
|
||||
_dht = dht;
|
||||
}
|
||||
|
||||
void doByInterval() {
|
||||
value.valD = _dht->getTemperature();
|
||||
if (String(value.valD) != "nan") regEvent(value.valD, "Dht1122t");
|
||||
else SerialPrint("E", "Sensor DHTt", "Error");
|
||||
}
|
||||
|
||||
~Dht1122t() {};
|
||||
};
|
||||
|
||||
|
||||
class Dht1122h : public IoTItem {
|
||||
private:
|
||||
DHTesp* _dht;
|
||||
|
||||
public:
|
||||
Dht1122h(DHTesp* dht, String parameters): IoTItem(parameters) {
|
||||
_dht = dht;
|
||||
}
|
||||
|
||||
void doByInterval() {
|
||||
value.valD = _dht->getHumidity();
|
||||
if (String(value.valD) != "nan") regEvent(value.valD, "Dht1122h");
|
||||
else SerialPrint("E", "Sensor DHTh", "Error");
|
||||
}
|
||||
|
||||
~Dht1122h() {};
|
||||
};
|
||||
|
||||
|
||||
void* getAPI_Dht1122(String subtype, String param) {
|
||||
if (subtype == F("Dht1122t") || subtype == F("Dht1122h")) {
|
||||
int pin;
|
||||
String senstype;
|
||||
jsonRead(param, "pin", pin);
|
||||
jsonRead(param, "senstype", senstype);
|
||||
|
||||
if (dhts.find(pin) == dhts.end()) {
|
||||
dhts[pin] = new DHTesp();
|
||||
|
||||
if (senstype == "dht11") {
|
||||
dhts[pin]->setup(pin, DHTesp::DHT11);
|
||||
} else if (senstype == "dht22") {
|
||||
dhts[pin]->setup(pin, DHTesp::DHT22);
|
||||
}
|
||||
}
|
||||
|
||||
if (subtype == F("Dht1122t")) {
|
||||
return new Dht1122t(dhts[pin], param);
|
||||
} else if (subtype == F("Dht1122h")) {
|
||||
return new Dht1122h(dhts[pin], param);
|
||||
}
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
53
src/modules/sensors/Dht1122/modinfo.json
Normal file
53
src/modules/sensors/Dht1122/modinfo.json
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"menuSection": "Сенсоры",
|
||||
|
||||
"configItem": [{
|
||||
"name": "Cенсор температуры dht11",
|
||||
"type": "Reading",
|
||||
"subtype": "Dht1122t",
|
||||
"id": "tmp3",
|
||||
"widget": "anydataTmp",
|
||||
"page": "Сенсоры",
|
||||
"descr": "Температура",
|
||||
"int": 15,
|
||||
"pin": 0,
|
||||
"senstype": "dht11"
|
||||
},
|
||||
{
|
||||
"name": "Cенсор влажности dht11",
|
||||
"type": "Reading",
|
||||
"subtype": "Dht1122h",
|
||||
"id": "Hum3",
|
||||
"widget": "anydataHum",
|
||||
"page": "Сенсоры",
|
||||
"descr": "Влажность",
|
||||
"int": 15,
|
||||
"pin": 0,
|
||||
"senstype": "dht11"
|
||||
}],
|
||||
|
||||
"about": {
|
||||
"authorName": "Ilya Belyakov",
|
||||
"authorContact": "https://t.me/Biveraxe",
|
||||
"authorGit": "https://github.com/biveraxe",
|
||||
"specialThanks": "Serghei Crasnicov @Serghei63",
|
||||
"moduleName": "Dht1122",
|
||||
"moduleVersion": "1.0",
|
||||
"moduleDesc": "Позволяет получить значения температуры и влажности с dht11 или dht22.",
|
||||
"propInfo": {
|
||||
"senstype": "Тип сенсора dht11 или dht22.",
|
||||
"int": "Количество секунд между опросами датчика."
|
||||
}
|
||||
},
|
||||
|
||||
"defActive": true,
|
||||
|
||||
"devices": {
|
||||
"esp32_4mb": [
|
||||
"beegee-tokyo/DHT sensor library for ESPx"
|
||||
],
|
||||
"esp8266_4mb": [
|
||||
"beegee-tokyo/DHT sensor library for ESPx"
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user