2012-07-27 08:39:47 +04:00
|
|
|
#ifndef DHT_H
|
|
|
|
#define DHT_H
|
|
|
|
#if ARDUINO >= 100
|
|
|
|
#include "Arduino.h"
|
|
|
|
#else
|
|
|
|
#include "WProgram.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* DHT library
|
|
|
|
|
|
|
|
MIT license
|
|
|
|
written by Adafruit Industries
|
|
|
|
*/
|
|
|
|
|
|
|
|
// how many timing transitions we need to keep track of. 2 * number bits + extra
|
|
|
|
#define MAXTIMINGS 85
|
|
|
|
|
|
|
|
#define DHT11 11
|
|
|
|
#define DHT22 22
|
|
|
|
#define DHT21 21
|
|
|
|
#define AM2301 21
|
|
|
|
|
|
|
|
class DHT {
|
|
|
|
private:
|
|
|
|
uint8_t data[6];
|
2012-12-29 22:14:51 +04:00
|
|
|
uint8_t _pin, _type, _count;
|
2012-07-27 08:39:47 +04:00
|
|
|
unsigned long _lastreadtime;
|
|
|
|
boolean firstreading;
|
|
|
|
|
|
|
|
public:
|
2012-12-29 22:14:51 +04:00
|
|
|
DHT(uint8_t pin, uint8_t type, uint8_t count=6);
|
2012-07-27 08:39:47 +04:00
|
|
|
void begin(void);
|
|
|
|
float readTemperature(bool S=false);
|
|
|
|
float convertCtoF(float);
|
2014-07-26 06:34:35 +04:00
|
|
|
float convertFtoC(float);
|
2014-06-02 23:54:54 +04:00
|
|
|
float computeHeatIndex(float tempFahrenheit, float percentHumidity);
|
2012-07-27 08:39:47 +04:00
|
|
|
float readHumidity(void);
|
2014-06-03 00:13:50 +04:00
|
|
|
boolean read(void);
|
2012-07-27 08:39:47 +04:00
|
|
|
|
|
|
|
};
|
|
|
|
#endif
|