Skovbrynet / Mbed 2 deprecated DHT2_NY_TEST

Dependencies:   mbed

Fork of Solar by Skovbrynet

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "DHT.h"
00003 
00004 RawSerial pc(USBTX, USBRX);//Serial LOG
00005 DHT dht21(p21,DHT22);  //Udendørs temperatur
00006 DHT dht22(p22,DHT22);  //Udendørs temperatur
00007 
00008 float UdeTemp1;
00009 float UdeHym1;
00010 
00011 float UdeTemp2;
00012 float UdeHym2;
00013 
00014 int main()
00015 {
00016     while(1) {
00017 
00018         int err=dht22.readData();
00019         wait(2.0);
00020         if (err==0) {
00021             UdeTemp1=dht22.ReadTemperature(CELCIUS);
00022             UdeHym1=dht22.ReadHumidity();
00023 
00024         int err=dht21.readData();
00025         wait(2.0);
00026         if (err==0) {
00027             UdeTemp2=dht21.ReadTemperature(CELCIUS);
00028             UdeHym2=dht21.ReadHumidity();
00029         }
00030 
00031         //Serial Log
00032         pc.printf("Temp:\r\n");
00033         pc.printf("DHT22: %.2fC %.1f% \n\r",UdeTemp1,UdeHym1);
00034         pc.printf("DHT21: %.2fC %.1f% \n\r",UdeTemp2,UdeHym2);
00035         pc.printf("\n\r");
00036 
00037         wait(2.0);
00038     }
00039 }
00040 }