Things/things/DeviceDht.h

31 lines
844 B
C++

#ifndef DEVICEDHT_H
#define DEVICEDHT_H
#include "Device.h"
#include <Homie.h>
#include <DHT.h> // https://github.com/adafruit/DHT-sensor-library
class DeviceDht : public Device {
public:
inline DeviceDht(byte dhtPin, byte dhtType):dht(dhtPin, dhtType) {
pin = dhtPin;
type = dhtType;
}
virtual void deviceSetup();
virtual void deviceRegister();
virtual void deviceLoop();
private:
byte pin;
byte type;
DHT dht;
const int INTERVAL_DHT = 60;
unsigned long lastSentDHT = 0;
float humidity, temperature; // raw values from the sensor
float heatindex; // computed value from the sensor
HomieNode humidityNode{"humidity", "humidity"};
HomieNode temperatureNode{"temperature", "temperature"};
HomieNode heatindexNode{"heatindex", "heatindex"};
};
#endif