Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BSP_DISCO_L476VG DHT LCD_DISCO_L476VG mbed
Fork of DHT11_STM32L476VGT_DISCO by
Diff: main.cpp
- Revision:
- 1:aedc2645d841
- Parent:
- 0:3b6dd029d50c
- Child:
- 2:15a255321242
diff -r 3b6dd029d50c -r aedc2645d841 main.cpp
--- a/main.cpp Tue Jun 23 00:18:57 2015 +0000
+++ b/main.cpp Fri Apr 21 07:02:29 2017 +0000
@@ -1,17 +1,21 @@
#include "mbed.h"
#include "DHT.h"
+
+#define DHT_DATA_PIN D4
-DHT sensor(D4, DHT11);
+DHT sensor(DHT_DATA_PIN, DHT11); //DHT(PinName pin, eType DHTtype)
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) {
+ while(1)
+ {
+ wait(2.0f); //wait 2 second
+ error = sensor.readData(); //read error value
+ if (error == 0) //case: no error
+ {
c = sensor.ReadTemperature(CELCIUS);
f = sensor.ReadTemperature(FARENHEIT);
k = sensor.ReadTemperature(KELVIN);
@@ -20,7 +24,9 @@
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 {
+ }
+ else //case: error
+ {
printf("Error: %d\n", error);
}
}
