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.
main.cpp
00001 00002 #include "mbed.h" 00003 #include "DHT.h" 00004 00005 DHT sensor(D14, DHT22); 00006 00007 int main() 00008 { 00009 int error = 0; 00010 float h = 0.0f, c = 0.0f, f = 0.0f, k = 0.0f, dp = 0.0f, dpf = 0.0f; 00011 00012 while(1) { 00013 wait(2); 00014 error = sensor.readData(); 00015 if (0 == error) { 00016 c = sensor.ReadTemperature(CELCIUS); 00017 f = sensor.ReadTemperature(FARENHEIT); 00018 k = sensor.ReadTemperature(KELVIN); 00019 h = sensor.ReadHumidity(); 00020 dp = sensor.CalcdewPoint(c, h); 00021 dpf = sensor.CalcdewPointFast(c, h); 00022 printf("Temperature in Kelvin: %4.2f, Celcius: %4.2f, Farenheit %4.2f\n", k, c, f); 00023 printf("Humidity is %4.2f, Dewpoint: %4.2f, Dewpoint fast: %4.2f\n", h, dp, dpf); 00024 } else { 00025 printf("Error: %d\n", error); 00026 } 00027 } 00028 }
Generated on Sun Jul 31 2022 19:03:46 by
1.7.2