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:
- 2:15a255321242
- Parent:
- 1:aedc2645d841
- Child:
- 3:b348fbaadf02
--- a/main.cpp Fri Apr 21 07:02:29 2017 +0000
+++ b/main.cpp Sat Apr 14 15:56:03 2018 +0000
@@ -1,15 +1,24 @@
#include "mbed.h"
#include "DHT.h"
-#define DHT_DATA_PIN D4
+
+// STM32L476VGT DISCOVERY BOARD
+// DHT11 SENSOR RUNNING FROM 3V3 SUPPLY
+// PULL DOWN WITH 10K RESISTOR
+// DATA VIA THE PIN PA_0
+// COM PORT 4 AT 9600 BAUD
+
+
+#define DHT_DATA_PIN PA_0 // sets pin PA_0 as data input
-DHT sensor(DHT_DATA_PIN, DHT11); //DHT(PinName pin, eType DHTtype)
+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;
-
+ float h = 0.0f, c = 0.0f, f = 0.0f, k = 0.0f, dp = 0.0f, dpf = 0.0f;
+
while(1)
{
wait(2.0f); //wait 2 second
@@ -22,12 +31,14 @@
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);
+ printf("F: %4.2f, \r\n", f); //prints temp in farenheit to Real Term
+ // printf("H: %4.2f, \r\n", h); //prints humidity to Real Term
+ printf(" \r\n "); //acts as empty line to space readings in Real Term
+ printf(" \r\n "); //acts as empty line to space readings in Real Term
}
else //case: error
{
- printf("Error: %d\n", error);
+ printf("Error: %d\r\n", error); //prints error to Real Term when "if" criteria isn't satisfied
}
}
}
\ No newline at end of file
