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(LED1); 00005 00006 DHT sensor(A2,DHT22); // Use the SEN11301P sensor 00007 Serial pc(SERIAL_TX,SERIAL_RX); 00008 Serial xbee(A0,A1); 00009 int main() { 00010 int err; 00011 pc.printf("\r\nDHT Test program"); 00012 pc.printf("\r\n******************\r\n"); 00013 wait(1); // wait 1 second for device stable status 00014 while (1) { 00015 myled = 1; 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("Temperature is %4.2f K \r\n",sensor.ReadTemperature(KELVIN)); 00021 pc.printf("Humidity is %4.2f \r\n",sensor.ReadHumidity()); 00022 pc.printf("Dew point is %4.2f \r\n",sensor.CalcdewPoint(sensor.ReadTemperature(CELCIUS), sensor.ReadHumidity())); 00023 pc.printf("Dew point (fast) is %4.2f \r\n",sensor.CalcdewPointFast(sensor.ReadTemperature(CELCIUS), sensor.ReadHumidity())); 00024 xbee.printf("Temperature is %4.2f C \r\n",sensor.ReadTemperature(CELCIUS)); 00025 xbee.printf("Temperature is %4.2f F \r\n",sensor.ReadTemperature(FARENHEIT)); 00026 xbee.printf("Temperature is %4.2f K \r\n",sensor.ReadTemperature(KELVIN)); 00027 xbee.printf("Humidity is %4.2f \r\n",sensor.ReadHumidity()); 00028 xbee.printf("Dew point is %4.2f \r\n",sensor.CalcdewPoint(sensor.ReadTemperature(CELCIUS), sensor.ReadHumidity())); 00029 xbee.printf("Dew point (fast) is %4.2f \r\n",sensor.CalcdewPointFast(sensor.ReadTemperature(CELCIUS), sensor.ReadHumidity())); 00030 } else 00031 pc.printf("\r\nErr %i \n",err); 00032 xbee.printf("\r\nErr %i \n",err); 00033 00034 myled = 0; 00035 wait(5); 00036 } 00037 }
Generated on Fri Jul 22 2022 23:44:56 by
1.7.2