DHT11 program

Dependencies:   mbed DHT11

Connection

Vcc → 3.3V ~ 5V (supply voltage)

GND → GND

DATA → p15 (mbed AnalogIn)

Revision:
0:d743365e4ee4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Nov 06 18:09:06 2019 +0000
@@ -0,0 +1,17 @@
+#include "mbed.h"
+#include "Dht11.h"
+ 
+Serial pc(USBTX, USBRX);
+Dht11 sensor(p15);
+int temp,humid;
+
+int main() {
+     while(1){
+        sensor.read();
+        temp = sensor.getFahrenheit();
+        humid = sensor.getHumidity();
+        temp = (temp - 32.0)/1.80;    // Fahrenheit --> Celsius
+        pc.printf("T: %d, H: %d\r\n", temp, humid);
+        wait(1.0);
+    }
+}
\ No newline at end of file