DHT11 program

Dependencies:   mbed DHT11

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "Dht11.h"
00003  
00004 Serial pc(USBTX, USBRX);
00005 Dht11 sensor(p15);
00006 int temp,humid;
00007 
00008 int main() {
00009      while(1){
00010         sensor.read();
00011         temp = sensor.getFahrenheit();
00012         humid = sensor.getHumidity();
00013         temp = (temp - 32.0)/1.80;    // Fahrenheit --> Celsius
00014         pc.printf("T: %d, H: %d\r\n", temp, humid);
00015         wait(1.0);
00016     }
00017 }