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 #include "mbed.h" 00002 #include "DHT.h" 00003 00004 DigitalOut myled(LED_GREEN); 00005 Serial pc(USBTX, USBRX); // default baud 9600 00006 00007 DHT sensor(PTA11, DHT11); 00008 00009 int main() { 00010 int err; 00011 pc.printf("\nDHT11 Test Program\n"); 00012 00013 wait(1); // wait 1 sec for device stable 00014 while (true) { 00015 myled = 0; // 0: on 00016 err = sensor.readData(); 00017 if (err == 0) { 00018 pc.printf("Temperature is %4.2f C \r\n", sensor.ReadTemperature(CELCIUS)); 00019 pc.printf("Temperature is %4.2f F \r\n", sensor.ReadTemperature(FARENHEIT)); 00020 pc.printf("Humidity is %4.f % \r\n", sensor.ReadHumidity()); 00021 printf("Dew point is %4.2f \r\n",sensor.CalcdewPoint(sensor.ReadTemperature(CELCIUS), sensor.ReadHumidity())); 00022 printf("Dew point (fast) is %4.2f \r\n\n",sensor.CalcdewPointFast(sensor.ReadTemperature(CELCIUS), sensor.ReadHumidity())); 00023 } 00024 else { 00025 printf("\r\nErr %i \n", err); 00026 } 00027 myled = 1; 00028 wait(15); 00029 } 00030 }
Generated on Thu Jul 14 2022 14:36:58 by
1.7.2