mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-29 15:42:20 +03:00
Меняем структуру FS для хранения модулей и добавляем скрипт сборки модулей для интеграции в меню и библиотеки
This commit is contained in:
60
src/modules/sensors/Aht20/Aht20.cpp
Normal file
60
src/modules/sensors/Aht20/Aht20.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
/******************************************************************
|
||||
Used Adafruit AHT20 Driver (temperature and humidity sensor)
|
||||
Support for AHT20
|
||||
https://github.com/adafruit/Adafruit_AHTX0
|
||||
|
||||
adapted for version 4 @Serghei63
|
||||
******************************************************************/
|
||||
|
||||
|
||||
#include "Global.h"
|
||||
#include "classes/IoTItem.h"
|
||||
|
||||
#include "Adafruit_AHTX0.h"
|
||||
#include <map>
|
||||
|
||||
Adafruit_AHTX0 aht;
|
||||
sensors_event_t temp, humidity;
|
||||
|
||||
class Aht20t : public IoTItem {
|
||||
public:
|
||||
Aht20t(String parameters): IoTItem(parameters) { }
|
||||
|
||||
void doByInterval() {
|
||||
value.valD = temp.temperature;
|
||||
if (value.valD != -200) regEvent(value.valD, "Aht20t"); // TODO: найти способ понимания ошибки получения данных
|
||||
else SerialPrint("E", "Sensor AHTt", "Error");
|
||||
}
|
||||
|
||||
~Aht20t() {};
|
||||
};
|
||||
|
||||
|
||||
class Aht20h : public IoTItem {
|
||||
public:
|
||||
Aht20h(String parameters): IoTItem(parameters) { }
|
||||
|
||||
void doByInterval() {
|
||||
value.valD = humidity.relative_humidity;
|
||||
if (value.valD != -200) regEvent(value.valD, "Aht20h"); // TODO: найти способ понимания ошибки получения данных
|
||||
else SerialPrint("E", "Sensor AHTt", "Error");
|
||||
}
|
||||
|
||||
~Aht20h() {};
|
||||
};
|
||||
|
||||
|
||||
void* getAPI_Aht20(String subtype, String param) {
|
||||
if (subtype == F("Aht20t")) {
|
||||
aht.begin();
|
||||
aht.getEvent(&humidity, &temp);// populate temp and humidity objects with fresh data
|
||||
return new Aht20t(param);
|
||||
} else if (subtype == F("Aht20h")) {
|
||||
aht.begin();
|
||||
aht.getEvent(&humidity, &temp);// populate temp and humidity objects with fresh data
|
||||
return new Aht20h(param);
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
27
src/modules/sensors/Aht20/items.json
Normal file
27
src/modules/sensors/Aht20/items.json
Normal file
@@ -0,0 +1,27 @@
|
||||
[{
|
||||
"name": "Cенсор температуры AHT20",
|
||||
"num": 12,
|
||||
"type": "Reading",
|
||||
"subtype": "Aht20t",
|
||||
"id": "Temp20",
|
||||
"widget": "anydataTmp",
|
||||
"page": "Сенсоры",
|
||||
"descr": "AHT20 Температура",
|
||||
"int": 15,
|
||||
"addr": "0x38",
|
||||
"round": 1
|
||||
},
|
||||
{
|
||||
"name": "Cенсор влажности AHT20",
|
||||
"num": 13,
|
||||
"type": "Reading",
|
||||
"subtype": "Aht20h",
|
||||
"id": "Hum20",
|
||||
"widget": "anydataHum",
|
||||
"page": "Сенсоры",
|
||||
"descr": "AHT20 Влажность",
|
||||
"int": 15,
|
||||
"addr": "0x38",
|
||||
"round": 1
|
||||
}
|
||||
]
|
||||
7
src/modules/sensors/Aht20/platformio.ini
Normal file
7
src/modules/sensors/Aht20/platformio.ini
Normal file
@@ -0,0 +1,7 @@
|
||||
[env:esp8266_4mb]
|
||||
lib_deps =
|
||||
Adafruit AHTX0
|
||||
|
||||
[env:esp32_4mb]
|
||||
lib_deps =
|
||||
Adafruit AHTX0
|
||||
Reference in New Issue
Block a user