DHT22 library, based on Simon Cooksey's. Improved with some error checking and more rigid timing (interrupts off).

Fork of lib_dht22 by Jodie Perry

Revision:
4:30a98da09c59
Parent:
3:40df3c72813f
--- a/dht22.h	Thu Nov 03 11:08:45 2016 +0000
+++ b/dht22.h	Thu Nov 03 11:12:51 2016 +0000
@@ -10,6 +10,7 @@
 #define DHT22_START_BIT_TIME                1000  // uS
 #define DHT22_START_BIT_RESPONSE            80   // uS
 
+#undef DEBUG_DHT22
 
 typedef struct {
     int temp;
@@ -20,7 +21,10 @@
 
 class DHT22 {
 public:
-    DHT22 (PinName pin) : dht22_s (pin), debug (PTB19)
+    DHT22 (PinName pin) : dht22_s (pin)
+#ifdef DEBUG_DHT22
+                            , debug (PTB19)     /* GROT! -- hardwired for K64F */
+#endif
     {
         dht22_s.input ();
         isinput = 1;
@@ -30,7 +34,9 @@
 private:
     DigitalInOut dht22_s;
     int isinput;
+#ifdef DEBUG_DHT22
     DigitalOut debug;
+#endif
 
     void wait_2us (void);
     void setinput (void);