2022-02-01 14:48:52 +03:00
|
|
|
#include "Global.h"
|
2022-02-15 11:37:31 +01:00
|
|
|
#include "classes/IoTItem.h"
|
2022-02-01 14:48:52 +03:00
|
|
|
|
|
|
|
|
#include "Wire.h"
|
|
|
|
|
#include "SHT2x.h"
|
|
|
|
|
|
|
|
|
|
SHT2x* sht = nullptr;
|
|
|
|
|
|
2022-02-06 09:11:07 +03:00
|
|
|
class Sht20t : public IoTItem {
|
2022-02-01 14:48:52 +03:00
|
|
|
public:
|
2022-09-14 18:53:02 +02:00
|
|
|
Sht20t(String parameters) : IoTItem(parameters) {}
|
|
|
|
|
|
2022-02-01 14:48:52 +03:00
|
|
|
void doByInterval() {
|
|
|
|
|
sht->read();
|
2022-02-14 17:23:39 +03:00
|
|
|
value.valD = sht->getTemperature();
|
2022-09-14 18:53:02 +02:00
|
|
|
if (value.valD > -46.85F)
|
|
|
|
|
regEvent(value.valD, "Sht20t");
|
|
|
|
|
else
|
|
|
|
|
SerialPrint("E", "Sensor Sht20t", "Error");
|
2022-02-01 14:48:52 +03:00
|
|
|
}
|
|
|
|
|
|
2022-09-14 18:53:02 +02:00
|
|
|
~Sht20t(){};
|
2022-02-01 14:48:52 +03:00
|
|
|
};
|
|
|
|
|
|
2022-02-06 09:11:07 +03:00
|
|
|
class Sht20h : public IoTItem {
|
2022-02-01 14:48:52 +03:00
|
|
|
public:
|
2022-09-14 18:53:02 +02:00
|
|
|
Sht20h(String parameters) : IoTItem(parameters) {}
|
|
|
|
|
|
2022-02-01 14:48:52 +03:00
|
|
|
void doByInterval() {
|
2022-02-01 21:44:57 +03:00
|
|
|
sht->read();
|
2022-02-14 17:23:39 +03:00
|
|
|
value.valD = sht->getHumidity();
|
2022-09-14 18:53:02 +02:00
|
|
|
if (value.valD != -6)
|
|
|
|
|
regEvent(value.valD, "Sht20h");
|
|
|
|
|
else
|
|
|
|
|
SerialPrint("E", "Sensor Sht20h", "Error");
|
|
|
|
|
}
|
2022-02-01 14:48:52 +03:00
|
|
|
|
2022-09-14 18:53:02 +02:00
|
|
|
~Sht20h(){};
|
2022-02-01 14:48:52 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void* getAPI_Sht20(String subtype, String param) {
|
2022-09-14 18:53:02 +02:00
|
|
|
// if (subtype == F("Sht20t") || subtype == F("Sht20h")) {
|
|
|
|
|
// if (!sht) {
|
|
|
|
|
// sht = new SHT2x;
|
|
|
|
|
// if (sht) sht->begin();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (subtype == F("Sht20t")) {
|
|
|
|
|
// return new Sht20t(param);
|
|
|
|
|
// } else if (subtype == F("Sht20h")) {
|
|
|
|
|
// return new Sht20h(param);
|
|
|
|
|
// }
|
|
|
|
|
//} else {
|
|
|
|
|
return nullptr;
|
|
|
|
|
//}
|
2022-02-01 14:48:52 +03:00
|
|
|
}
|