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.

Files at this revision

API Documentation at this revision

Comitter:
s_inoue_mbed
Date:
Thu Sep 25 14:13:10 2014 +0000
Parent:
10:f0d789f49df7
Child:
12:af1eadec17e5
Commit message:
Bug fix (I/O pin is changed to OUTPUT for the start pulse).

Changed in this revision

DHT11.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/DHT11.cpp	Tue Sep 16 13:06:43 2014 +0000
+++ b/DHT11.cpp	Thu Sep 25 14:13:10 2014 +0000
@@ -55,10 +55,13 @@
 
     // Sending start signal, low signal for around 10 ms
     t.reset();
+    io.output();
+    io = 0;
     do {
-        io = 0;
     } while (t.read_ms() < 20 + t_tol_start);
+    io.input();
     io = 1;
+    
 
     // Waiting for the start of the response signal
     t.reset();