Tester for DHT22

Dependencies:   DHT mbed

main.cpp

Committer:
gert_lauritsen
Date:
2016-02-26
Revision:
2:97f36e93b6e6
Parent:
1:781c47971406

File content as of revision 2:97f36e93b6e6:

#include "mbed.h"
#include "DHT.h"


DigitalOut myled(LED1);
DigitalOut Error(LED2);
DHT dht22(p21,DHT22);  

int main() {
    printf("Starting!!!\r\n");
    wait(1);
    while(1) {
       int err=dht22.readData();
       if (err==0) {
          Error=0; 
          printf("T: %.1f C",dht22.ReadTemperature(CELCIUS));
          printf(" H %.1f\% \n\r",dht22.ReadHumidity());
       }
       else {
         Error=1;
         dht22.printErr(err);
       }  

        myled = 1;
        wait(3);
        myled = 0;

    }
}