Example of my library for the DHT11 temperature and humidity sendor

Dependencies:   DHT11 TextLCD mbed

Files at this revision

API Documentation at this revision

Comitter:
s_inoue_mbed
Date:
Thu Sep 11 13:50:10 2014 +0000
Commit message:
Example of my library for the DHT11 temperature and humidity sendor

Changed in this revision

DHT11.lib Show annotated file Show diff for this revision Revisions of this file
TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r da7b1c04a659 DHT11.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DHT11.lib	Thu Sep 11 13:50:10 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/s_inoue_mbed/code/DHT11/#056d1e9b428c
diff -r 000000000000 -r da7b1c04a659 TextLCD.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Thu Sep 11 13:50:10 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#308d188a2d3a
diff -r 000000000000 -r da7b1c04a659 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Sep 11 13:50:10 2014 +0000
@@ -0,0 +1,41 @@
+/*
+ * A program for the use of the DHT11, a temperature and humidity sensor
+ * Shigenori Inoue, September 10, 2014
+ */
+ 
+#include "mbed.h"
+#include "TextLCD.h"
+#include "DHT11.h"
+
+// LEDs for debugging
+BusOut leds(LED4, LED3, LED2, LED1);
+
+// LCD module
+TextLCD lcd(p25, p24, p12, p13, p14, p23);
+
+// Humidity sensor
+DHT11 d(p18);
+
+// The main function
+int main()
+{
+    int state;
+
+    lcd.cls();
+    lcd.locate(0, 0);
+    lcd.printf("DHT11 Humidity");
+
+    while(true) {
+        state = d.readData();
+
+        if (state != DHT11::OK) {
+            lcd.locate(0, 1);
+            lcd.printf("Error: %d", state);
+        } else {
+            lcd.locate(0, 1);
+            lcd.printf("T: %dC, H: %d%%", d.readTemperature(), d.readHumidity());
+        }
+        leds = leds + 1;
+        wait(2.0);
+    }
+}
diff -r 000000000000 -r da7b1c04a659 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Sep 11 13:50:10 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013
\ No newline at end of file