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 00005 00006 #define DHT_TIPO DHT11 00007 #define DHT_PIN PTA13 00008 00009 //Definicion de objjeto del sensor de humedad y temperatura 00010 DHT dht(DHT_PIN, DHT_TIPO); 00011 float measuredTemperature; 00012 int error_code; 00013 float measuredHumidity; 00014 00015 // Host PC Communication channels 00016 Serial Terminal(USBTX, USBRX); // Tx, Rx 00017 00018 int main() 00019 { 00020 00021 while (true) { 00022 Terminal.printf("\rReading DHT ... "); 00023 error_code = dht.readData(); 00024 if (error_code){ 00025 Terminal.printf("\r\nError Code: %d \r\n", error_code); 00026 Terminal.printf("\r\n"); 00027 00028 Terminal.printf("\r\nData: %d %d %d %d %d \v\v\v\v", dht.DHT_data[0], dht.DHT_data[1],dht.DHT_data[2], dht.DHT_data[3], dht.DHT_data[4]); 00029 } 00030 else{ 00031 measuredHumidity = dht.ReadHumidity(); //Se lee la humedad 00032 Terminal.printf("\r\nHumedad: %.2f", measuredHumidity); 00033 measuredTemperature = dht.ReadTemperature(CELCIUS); //Se lee la temperatura: CELCIUS=0,FARENHEIT=1,KELVIN=2 00034 Terminal.printf("\r\nData: %d %d %d %d %d ", dht.DHT_data[0], dht.DHT_data[1],dht.DHT_data[2], dht.DHT_data[3], dht.DHT_data[4]); 00035 00036 Terminal.printf("\r\nTemperatura: %.2f \r\n\v\v\v\v\v\v\v\v\v", measuredTemperature); 00037 00038 } 00039 wait(4); 00040 00041 } 00042 }
Generated on Tue Jul 12 2022 18:25:25 by
1.7.2