Sens_Temp_Umid_LCD

Dependencies:   mbed DHT TextLCD

Committer:
luigi_lagatta
Date:
Thu Apr 04 13:40:50 2019 +0000
Revision:
3:0b0d2e449123
Parent:
2:4f9613cebdae
Sensore_Temp_Umid_LCD

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kaizen 0:3b6dd029d50c 1 #include "mbed.h"
kaizen 0:3b6dd029d50c 2 #include "DHT.h"
luigi_lagatta 3:0b0d2e449123 3 #include "TextLCD.h"
luigi_lagatta 3:0b0d2e449123 4 #define DHT_DATA_PIN D7
WIzMatthew 1:aedc2645d841 5
luigi_lagatta 3:0b0d2e449123 6 TextLCD lcd(D10,D11,D5,D4,D3,D2); // rs, e, d4-d7
luigi_lagatta 3:0b0d2e449123 7 Serial out(USBTX,USBRX);
WIzMatthew 1:aedc2645d841 8 DHT sensor(DHT_DATA_PIN, DHT11); //DHT(PinName pin, eType DHTtype)
kaizen 0:3b6dd029d50c 9
kaizen 0:3b6dd029d50c 10 int main()
kaizen 0:3b6dd029d50c 11 {
kaizen 0:3b6dd029d50c 12 int error = 0;
kaizen 0:3b6dd029d50c 13 float h = 0.0f, c = 0.0f, f = 0.0f, k = 0.0f, dp = 0.0f, dpf = 0.0f;
kaizen 0:3b6dd029d50c 14
luigi_lagatta 3:0b0d2e449123 15 // while(1)
WIzMatthew 1:aedc2645d841 16 {
WIzMatthew 1:aedc2645d841 17 wait(2.0f); //wait 2 second
ajeet3004 2:4f9613cebdae 18 error = sensor.readData();
ajeet3004 2:4f9613cebdae 19 // c = sensor.ReadTemperature(CELCIUS); //read error value
ajeet3004 2:4f9613cebdae 20 // out.printf(" Celcius: %4.2f",c);
WIzMatthew 1:aedc2645d841 21 if (error == 0) //case: no error
WIzMatthew 1:aedc2645d841 22 {
kaizen 0:3b6dd029d50c 23 c = sensor.ReadTemperature(CELCIUS);
kaizen 0:3b6dd029d50c 24 f = sensor.ReadTemperature(FARENHEIT);
kaizen 0:3b6dd029d50c 25 k = sensor.ReadTemperature(KELVIN);
kaizen 0:3b6dd029d50c 26 h = sensor.ReadHumidity();
luigi_lagatta 3:0b0d2e449123 27 //dp = sensor.CalcdewPoint(c, h);
luigi_lagatta 3:0b0d2e449123 28 //dpf = sensor.CalcdewPointFast(c, h);
luigi_lagatta 3:0b0d2e449123 29 lcd.printf("Temp: %4.1f C \n", c);
luigi_lagatta 3:0b0d2e449123 30 lcd.printf("Umid: %4.1f \n", h);
luigi_lagatta 3:0b0d2e449123 31
kaizen 0:3b6dd029d50c 32 printf("Temperature in Kelvin: %4.2f, Celcius: %4.2f, Farenheit %4.2f\n", k, c, f);
kaizen 0:3b6dd029d50c 33 printf("Humidity is %4.2f, Dewpoint: %4.2f, Dewpoint fast: %4.2f\n", h, dp, dpf);
WIzMatthew 1:aedc2645d841 34 }
WIzMatthew 1:aedc2645d841 35 else //case: error
WIzMatthew 1:aedc2645d841 36 {
kaizen 0:3b6dd029d50c 37 printf("Error: %d\n", error);
kaizen 0:3b6dd029d50c 38 }
kaizen 0:3b6dd029d50c 39 }
kaizen 0:3b6dd029d50c 40 }