27 lines
542 B
C++
27 lines
542 B
C++
#ifndef DHT_CONTROLLER_H
|
|
#define DHT_CONTROLLER_H
|
|
|
|
#include <Arduino.h>
|
|
#include <DHT.h>
|
|
|
|
class DHTController {
|
|
private:
|
|
DHT _dht;
|
|
unsigned long _lastReadTime;
|
|
unsigned long _minReadInterval;
|
|
float _lastTemperature;
|
|
float _lastHumidity;
|
|
bool _lastReadSuccess;
|
|
|
|
public:
|
|
DHTController(uint8_t pin, uint8_t type = DHT11);
|
|
|
|
void begin();
|
|
bool read();
|
|
float getTemperature();
|
|
float getHumidity();
|
|
bool isLastReadSuccessful() const;
|
|
void setMinReadInterval(unsigned long interval);
|
|
};
|
|
|
|
#endif |