Simple library for the DHT11 temperature and humidity sensor. Forked from an existing Mbed DHT11 project.

Dependents:   UoY-DHT11-test

Simple DHT11 temperature and humidity library.

Example usage

#include "mbed.h"
#include "DHT11.h"

DHT11 dht(D8); // Change pin name here if required

main()
{
    printf("T:%d, H:%d\r\n", dht.readTemperature(), dht.readHumidity());
}

The sensor may be read as often as desired, but temperature and humidity values are cached and will only be updated if they are more than 2 seconds old. This is the underlying sensor update rate.

Please note that this project has been modified only enough to make it work for its intended purpose. Various parts of this project still need work, and the source code should not be seen as an example of best practice.

Revision:
3:8cd064147bde
Parent:
2:1e997b7a1f9a
Child:
4:48798b126d93
diff -r 1e997b7a1f9a -r 8cd064147bde DHT11.h
--- a/DHT11.h	Wed Sep 10 17:03:41 2014 +0000
+++ b/DHT11.h	Wed Sep 10 17:10:42 2014 +0000
@@ -36,9 +36,6 @@
     DHT11(PinName pin);
     ~DHT11();
 
-    /** Reading the data from the DHT11 */
-    int readData(void);
-    
     /** Reading the data from the DHT11
      * @return Error code
      *     0: OK.
@@ -49,17 +46,18 @@
      *     5: Checksum is incorrect.
      *     6: Timeout
      */
-     
+    int readData(void);
+
     /** Reading the humidity from the data
      * @return Humidity in % if readData() returns no error. Otherwise, returns 0xffffffff.
      */
     int readHumidity(void);
-    
-    /** Reading the humidity from the data
+
+    /** Reading the temperature from the data
      * @return Temperature in Celcius if readData() returns no error. Otherwise, returns 0xffffffff.
      */
     int readTemperature(void);
-    
+
     enum ErrorDHT11 {
         OK = 0,
         TOO_FAST_READ = 1,