28 lines
806 B
C++
28 lines
806 B
C++
#pragma once
|
|
|
|
#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"};
|
|
};
|