DHT11 sensor test for Stage 1 Engineering at the University of York

Dependencies:   DHT11 UoY-serial

Revision:
2:789cc1bc1adc
Parent:
1:acb591685a28
--- a/main.cpp	Thu Feb 04 17:12:01 2021 +0000
+++ b/main.cpp	Thu Sep 16 15:37:20 2021 +0000
@@ -1,14 +1,19 @@
 #include "mbed.h"
+#include "UoY-serial.h"
+#include "DHT11.h"
 
-DigitalOut green(D2);
-DigitalOut red(D3);
+// D2 is the data pin name on the Nucleo board
+DHT11 sensor(D2);
 
 int main()
 {
-    while (true) {
-        green = true;
-        thread_sleep_for(500);
-        green = false;
-        thread_sleep_for(2500);
+    while(true) {
+        // Print temperature and humidity
+        printf("Temp: %d\n", sensor.readTemperature());
+        printf("  RH: %d%%\n", sensor.readHumidity());
+        
+        // Wait 2 seconds before doing it again
+        thread_sleep_for(2000);
     }
 }
+