Use a DHT11 sensot to show temperature and humidity to lcd display

Dependencies:   TS_DISCO_F746NG mbed LCD_DISCO_F746NG BSP_DISCO_F746NG DHT BUTTON_GROUP

Files at this revision

API Documentation at this revision

Comitter:
Mario0799
Date:
Sun Feb 24 11:20:42 2019 +0000
Commit message:
v1

Changed in this revision

BSP_DISCO_F746NG.lib Show annotated file Show diff for this revision Revisions of this file
BUTTON_GROUP.lib Show annotated file Show diff for this revision Revisions of this file
DHT.lib Show annotated file Show diff for this revision Revisions of this file
LCD_DISCO_F746NG.lib Show annotated file Show diff for this revision Revisions of this file
TS_DISCO_F746NG.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BSP_DISCO_F746NG.lib	Sun Feb 24 11:20:42 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/ST/code/BSP_DISCO_F746NG/#df2ea349c37a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BUTTON_GROUP.lib	Sun Feb 24 11:20:42 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/TCMIA-B/code/BUTTON_GROUP/#742da8cc7e07
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DHT.lib	Sun Feb 24 11:20:42 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/Wimpie/code/DHT/#9b5b3200688f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD_DISCO_F746NG.lib	Sun Feb 24 11:20:42 2019 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/LCD_DISCO_F746NG/#d44525b1de98
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TS_DISCO_F746NG.lib	Sun Feb 24 11:20:42 2019 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/TS_DISCO_F746NG/#fe0cf5e2960f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Feb 24 11:20:42 2019 +0000
@@ -0,0 +1,45 @@
+ #include "mbed.h"
+ #include "DHT.h"
+ #include "button_group.hpp"
+ #include "TS_DISCO_F746NG.h"
+ #include "LCD_DISCO_F746NG.h"
+ 
+ Serial pc(USBTX, USBRX);
+DHT sensor(A0,DHT11);
+ uint8_t text[30];
+  uint8_t text1[30];
+   uint8_t text2[30];
+
+LCD_DISCO_F746NG lcd_;
+TS_DISCO_F746NG ts_;
+ 
+ int main() {
+     lcd_.Clear(LCD_COLOR_WHITE);
+    lcd_.SetBackColor(LCD_COLOR_WHITE);
+    lcd_.SetTextColor(LCD_COLOR_BLACK);
+    
+    int err;
+    pc.printf("\r\nDHT Test program");
+    pc.printf("\r\n******************\r\n");
+    wait(1); // wait 1 second for device stable status
+    while (1) {
+        
+        err = sensor.readData();
+        if (err == 0) {
+            sprintf((char*)text, "Temperatura: %4.2f C",sensor.ReadTemperature(CELCIUS));
+            lcd_.DisplayStringAt(0, LINE(5),text , CENTER_MODE);
+            sprintf((char*)text1, "Umidita': %4.2f %",sensor.ReadHumidity());
+            lcd_.DisplayStringAt(0, LINE(6),text1 , CENTER_MODE);
+            
+            pc.printf("Temperature is %4.2f C \r\n",sensor.ReadTemperature(CELCIUS));
+            pc.printf("Temperature is %4.2f F \r\n",sensor.ReadTemperature(FARENHEIT));
+            pc.printf("Temperature is %4.2f K \r\n",sensor.ReadTemperature(KELVIN));
+            pc.printf("Humidity is %4.2f \r\n",sensor.ReadHumidity());
+            pc.printf("Dew point is %4.2f  \r\n",sensor.CalcdewPoint(sensor.ReadTemperature(CELCIUS), sensor.ReadHumidity()));
+            pc.printf("Dew point (fast) is %4.2f  \r\n",sensor.CalcdewPointFast(sensor.ReadTemperature(CELCIUS), sensor.ReadHumidity()));
+        } else
+            pc.printf("\r\nErr %i \n",err);
+
+        wait(1);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Feb 24 11:20:42 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file