Simple example to read humidity and temperature from DHT11 sensor

Dependencies:   mbed

Revision:
0:dbffab632178
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Apr 05 14:04:25 2017 +0000
@@ -0,0 +1,26 @@
+#include "mbed.h"
+#include "DHT11.h"
+
+//Tested with success on STM32 Nucleo L476
+
+DigitalIn mybutton(USER_BUTTON);
+Serial pc(SERIAL_TX, SERIAL_RX); 
+
+DHT11 dht(A1);
+
+
+int main() {
+    pc.printf("DHT11 Reader example\n"); 
+    while(1) {
+        if(mybutton == 0){ 
+            if(dht.readData() < 0){
+                pc.printf("Error while reading\n\r");
+            }
+            else{
+                pc.printf("Temperature:%d\n\r",dht.getTemperature());
+                pc.printf("Humidity:%d\n\r",dht.getHumidity());
+            }
+            
+        } 
+    }
+}