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: mbed DHT TextLCD
main.cpp
00001 #include "mbed.h" 00002 #include "DHT.h" 00003 #include "TextLCD.h" 00004 #define DHT_DATA_PIN D7 00005 00006 TextLCD lcd(D10,D11,D5,D4,D3,D2); // rs, e, d4-d7 00007 Serial out(USBTX,USBRX); 00008 DHT sensor(DHT_DATA_PIN, DHT11); //DHT(PinName pin, eType DHTtype) 00009 00010 int main() 00011 { 00012 int error = 0; 00013 float h = 0.0f, c = 0.0f, f = 0.0f, k = 0.0f, dp = 0.0f, dpf = 0.0f; 00014 00015 // while(1) 00016 { 00017 wait(2.0f); //wait 2 second 00018 error = sensor.readData(); 00019 // c = sensor.ReadTemperature(CELCIUS); //read error value 00020 // out.printf(" Celcius: %4.2f",c); 00021 if (error == 0) //case: no error 00022 { 00023 c = sensor.ReadTemperature(CELCIUS); 00024 f = sensor.ReadTemperature(FARENHEIT); 00025 k = sensor.ReadTemperature(KELVIN); 00026 h = sensor.ReadHumidity(); 00027 //dp = sensor.CalcdewPoint(c, h); 00028 //dpf = sensor.CalcdewPointFast(c, h); 00029 lcd.printf("Temp: %4.1f C \n", c); 00030 lcd.printf("Umid: %4.1f \n", h); 00031 00032 printf("Temperature in Kelvin: %4.2f, Celcius: %4.2f, Farenheit %4.2f\n", k, c, f); 00033 printf("Humidity is %4.2f, Dewpoint: %4.2f, Dewpoint fast: %4.2f\n", h, dp, dpf); 00034 } 00035 else //case: error 00036 { 00037 printf("Error: %d\n", error); 00038 } 00039 } 00040 }
Generated on Sun Jul 17 2022 08:54:20 by
1.7.2