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.cpp	Thu Nov 03 11:08:45 2016 +0000
+++ b/dht22.cpp	Thu Nov 03 11:12:51 2016 +0000
@@ -160,9 +160,11 @@
 
         if (d > DHT22_SIGNAL_HIGH_LOW_BOUNDARY) {
             v |= (1 << bit);
+#ifdef DEBUG_DHT22
             debug = 1;
-    } else {
+        } else {
             debug = 0;
+#endif
         }
 
     }
@@ -180,8 +182,10 @@
     uint8_t buf[5];
     uint16_t u_hum, u_tmp;
     int i;
-    
+
+#ifdef DEBUG_DHT22
     debug = 0;
+#endif
     __disable_irq ();
     // Send start bits
     send_start();
@@ -227,7 +231,10 @@
     }
 
     data->checksum = buf[0];
+
+#ifdef DEBUG_DHT22
     debug = 0;
+#endif
     
     return i;
 }