Based on another DHT library, this is just a modified one without using the RTC component

Dependencies:   mbed

Committer:
RazielLopez
Date:
Fri Dec 21 03:47:05 2018 +0000
Revision:
1:6df9454191d4
Parent:
0:b1384299f31c
Child:
3:8c402316ce7e
mejorando recepcion de datos

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RazielLopez 0:b1384299f31c 1 #include "mbed.h"
RazielLopez 0:b1384299f31c 2 #include "DHT.h"
RazielLopez 0:b1384299f31c 3
RazielLopez 0:b1384299f31c 4
RazielLopez 0:b1384299f31c 5
RazielLopez 0:b1384299f31c 6 #define DHT_TIPO DHT11
RazielLopez 0:b1384299f31c 7 #define DHT_PIN PTA13
RazielLopez 0:b1384299f31c 8
RazielLopez 0:b1384299f31c 9 //Definicion de objjeto del sensor de humedad y temperatura
RazielLopez 0:b1384299f31c 10 DHT dht(DHT_PIN, DHT_TIPO);
RazielLopez 0:b1384299f31c 11 float measuredTemperature;
RazielLopez 0:b1384299f31c 12 int error_code;
RazielLopez 0:b1384299f31c 13 float measuredHumidity;
RazielLopez 0:b1384299f31c 14
RazielLopez 0:b1384299f31c 15 // Host PC Communication channels
RazielLopez 0:b1384299f31c 16 Serial Terminal(USBTX, USBRX); // Tx, Rx
RazielLopez 0:b1384299f31c 17
RazielLopez 0:b1384299f31c 18 int main()
RazielLopez 0:b1384299f31c 19 {
RazielLopez 0:b1384299f31c 20
RazielLopez 0:b1384299f31c 21 while (true) {
RazielLopez 0:b1384299f31c 22 Terminal.printf("\rReading DHT ... ");
RazielLopez 0:b1384299f31c 23 error_code = dht.readData();
RazielLopez 1:6df9454191d4 24 if (error_code){
RazielLopez 1:6df9454191d4 25 Terminal.printf("\r\nError Code: %d \r\n", error_code);
RazielLopez 1:6df9454191d4 26 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]);
RazielLopez 1:6df9454191d4 27 }
RazielLopez 0:b1384299f31c 28 else{
RazielLopez 0:b1384299f31c 29 measuredHumidity = dht.ReadHumidity(); //Se lee la humedad
RazielLopez 0:b1384299f31c 30 Terminal.printf("\r\nHumedad: %.2f", measuredHumidity);
RazielLopez 0:b1384299f31c 31 measuredTemperature = dht.ReadTemperature(CELCIUS); //Se lee la temperatura: CELCIUS=0,FARENHEIT=1,KELVIN=2
RazielLopez 0:b1384299f31c 32 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]);
RazielLopez 0:b1384299f31c 33
RazielLopez 1:6df9454191d4 34 Terminal.printf("\r\nTemperatura: %.2f \r\n\v\v\v\v\v\v\v\v\v", measuredTemperature);
RazielLopez 0:b1384299f31c 35
RazielLopez 0:b1384299f31c 36 }
RazielLopez 0:b1384299f31c 37 wait(4);
RazielLopez 0:b1384299f31c 38
RazielLopez 0:b1384299f31c 39 }
RazielLopez 0:b1384299f31c 40 }