Temp and Humidity sensor example. DHT11

Dependencies:   DHT mbed

Fork of Seeed_Grove_Temp_Humidity_Example by Seeed

Files at this revision

API Documentation at this revision

Comitter:
anywill
Date:
Mon Nov 20 03:38:28 2017 +0000
Parent:
1:6bcb143683f3
Commit message:
STM32 Nucleo F103RB+ DHT11;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Mar 10 21:33:31 2015 +0000
+++ b/main.cpp	Mon Nov 20 03:38:28 2017 +0000
@@ -1,9 +1,9 @@
 
 #include "mbed.h"
 #include "DHT.h"
-
+//串口助手不支持中文输出
 DHT sensor(D4, DHT11);
-
+Serial pc(SERIAL_TX, SERIAL_RX);
 int main()
 {
     int error = 0;
@@ -19,10 +19,10 @@
             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);
+            pc.printf("Temperature in Kelvin: %4.2f, Celcius: %4.2f, Farenheit %4.2f\n", k, c, f);
+            pc.printf("Humidity is %4.2f, Dewpoint: %4.2f, Dewpoint fast: %4.2f\n", h, dp, dpf);
         } else {
-            printf("Error: %d\n", error);
+            pc.printf("Error: %d\n", error);
         }
     }
 }