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:20:04 2018 +0000
Revision:
0:b1384299f31c
Child:
1:6df9454191d4
Primer prueba con sensor trabajando

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 0:b1384299f31c 24 if (error_code)
RazielLopez 0:b1384299f31c 25 Terminal.printf("\r\nError Code: %d \r\n", error_code);
RazielLopez 0:b1384299f31c 26 else{
RazielLopez 0:b1384299f31c 27 measuredHumidity = dht.ReadHumidity(); //Se lee la humedad
RazielLopez 0:b1384299f31c 28 Terminal.printf("\r\nHumedad: %.2f", measuredHumidity);
RazielLopez 0:b1384299f31c 29 measuredTemperature = dht.ReadTemperature(CELCIUS); //Se lee la temperatura: CELCIUS=0,FARENHEIT=1,KELVIN=2
RazielLopez 0:b1384299f31c 30
RazielLopez 0:b1384299f31c 31 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 32
RazielLopez 0:b1384299f31c 33 Terminal.printf("\r\nTemperatura: %.2f \r\n\v\v\v\v\v\v\v", measuredTemperature);
RazielLopez 0:b1384299f31c 34
RazielLopez 0:b1384299f31c 35 }
RazielLopez 0:b1384299f31c 36 wait(4);
RazielLopez 0:b1384299f31c 37
RazielLopez 0:b1384299f31c 38 }
RazielLopez 0:b1384299f31c 39 }