DHT.h 1015 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef DHT_H
  2. #define DHT_H
  3. #if ARDUINO >= 100
  4. #include "Arduino.h"
  5. #else
  6. #include "WProgram.h"
  7. #endif
  8. // 8 MHz(ish) AVR ---------------------------------------------------------
  9. #if (F_CPU >= 7400000UL) && (F_CPU <= 9500000UL)
  10. #define COUNT 3
  11. // 16 MHz(ish) AVR --------------------------------------------------------
  12. #elif (F_CPU >= 15400000UL) && (F_CPU <= 19000000L)
  13. #define COUNT 6
  14. #else
  15. #error "CPU SPEED NOT SUPPORTED"
  16. #endif
  17. /* DHT library
  18. MIT license
  19. written by Adafruit Industries
  20. */
  21. // how many timing transitions we need to keep track of. 2 * number bits + extra
  22. #define MAXTIMINGS 85
  23. #define DHT11 11
  24. #define DHT22 22
  25. #define DHT21 21
  26. #define AM2301 21
  27. class DHT {
  28. private:
  29. uint8_t data[6];
  30. uint8_t _pin, _type, _count;
  31. boolean read(void);
  32. unsigned long _lastreadtime;
  33. boolean firstreading;
  34. public:
  35. DHT(uint8_t pin, uint8_t type, uint8_t count=COUNT);
  36. void begin(void);
  37. float readTemperature(bool S=false);
  38. float convertCtoF(float);
  39. float readHumidity(void);
  40. };
  41. #endif