DHT11+AQM0802

Dependencies:   mbed DHT AQM0802A

Revision:
0:c12c28a0f9e7
Child:
2:a17a95217222
diff -r 000000000000 -r c12c28a0f9e7 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Aug 15 20:59:57 2014 +0000
@@ -0,0 +1,28 @@
+
+#include "mbed.h"
+#include "DHT.h"
+
+DHT sensor(D4, DHT11);
+
+int main()
+{
+    int error = 0;
+    float h = 0.0f, c = 0.0f, f = 0.0f, k = 0.0f, dp = 0.0f, dpf = 0.0f;
+
+    while(1) {
+        wait(2.0f);
+        error = sensor.readData();
+        if (0 == error) {
+            c   = sensor.ReadTemperature(CELCIUS);
+            f   = sensor.ReadTemperature(FARENHEIT);
+            k   = sensor.ReadTemperature(KELVIN);
+            h   = sensor.ReadHumidity();
+            dp  = sensor.CalcdewPoint(c, h);
+            dpf = sensor.CalcdewPointFast(c, h);
+            printf("Temperature in Kelvin: %4.2f, Celcius: %4.2f, Farenheit %4.2f\n", k, c, f);
+            printf("Humidity is %4.2f, Dewpoint: %4.2f, Dewpoint fast: %4.2f\n", h, dp, dpf);
+        } else {
+            printf("Error: %d\n", error);
+        }
+    }
+}