Things/things/DeviceDht.h

28 lines
806 B
C
Raw Normal View History

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