Скопом добавляем несколько сенсоров

This commit is contained in:
2022-02-17 18:25:50 +03:00
parent 52db75b8d5
commit c728d7b90c
8 changed files with 425 additions and 15 deletions

54
src/modules/Hdc1080.cpp Normal file
View File

@@ -0,0 +1,54 @@
/******************************************************************
Used ClosedCube HDC1080 Driver (temperature and humidity sensor)
Support for HDC1080
https://github.com/closedcube/ClosedCube_HDC1080_Arduino
adapted for version 4 @Serghei63
******************************************************************/
#include "Global.h"
#include "Classes/IoTItem.h"
#include "Wire.h"
#include "ClosedCube_HDC1080.h"
#include <map>
//создаем объект HDC1080
ClosedCube_HDC1080 hdc1080;
class Hdc1080t : public IoTItem {
public:
Hdc1080t(String parameters): IoTItem(parameters) { }
void doByInterval() {
value.valD = hdc1080.readTemperature();
if (value.valD > -46.85F) regEvent(value.valD, "Hdc1080t");
else SerialPrint("E", "Sensor Hdc1080t", "Error");
}
~Hdc1080t();
};
class Hdc1080h : public IoTItem {
public:
Hdc1080h(String parameters): IoTItem(parameters) { }
void doByInterval() {
value.valD = hdc1080.readHumidity();
if (value.valD > -46.85F) regEvent(value.valD, "Hdc1080h");
else SerialPrint("E", "Sensor Hdc1080h", "Error");
}
~Hdc1080h();
};
void* getAPI_Hdc1080(String subtype, String param) {
if (subtype == F("Hdc1080t")) {
hdc1080.begin(0x40);
return new Hdc1080t(param);
} else if (subtype == F("Hdc1080h")) {
hdc1080.begin(0x40);
return new Hdc1080h(param);
} else {
return nullptr;
}
}