Things/things/DeviceDht.h

28 lines
806 B
C
Raw Normal View History

2016-04-22 22:32:36 +02:00
#pragma once
#include "Device.h"
#include <Homie.h>
2016-04-22 22:45:45 +02:00
#include <DHT.h> // https://github.com/adafruit/DHT-sensor-library
class DeviceDht : public Device {
public:
2016-04-10 00:20:50 +02:00
inline DeviceDht(byte dhtPin, byte dhtType):dht(dhtPin, dhtType) {
pin = dhtPin;
type = dhtType;
}
2016-04-11 00:29:05 +02:00
virtual void deviceSetup();
virtual void deviceRegister();
virtual void deviceLoop();
private:
byte pin;
byte type;
2016-04-10 00:20:50 +02:00
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"};
};