DHT22 tester (p21) (p22) 4,7kR pullup

Dependencies:   mbed

Fork of Solar by Skovbrynet

main.cpp

Committer:
Tuxitheone
Date:
2017-07-01
Revision:
4:e2c50e38f7e0
Parent:
3:ae94f568bde5

File content as of revision 4:e2c50e38f7e0:

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

RawSerial pc(USBTX, USBRX);//Serial LOG
DHT dht21(p21,DHT22);  //Udendørs temperatur
DHT dht22(p22,DHT22);  //Udendørs temperatur

float UdeTemp1;
float UdeHym1;

float UdeTemp2;
float UdeHym2;

int main()
{
    while(1) {

        int err=dht22.readData();
        wait(2.0);
        if (err==0) {
            UdeTemp1=dht22.ReadTemperature(CELCIUS);
            UdeHym1=dht22.ReadHumidity();

        int err=dht21.readData();
        wait(2.0);
        if (err==0) {
            UdeTemp2=dht21.ReadTemperature(CELCIUS);
            UdeHym2=dht21.ReadHumidity();
        }

        //Serial Log
        pc.printf("Temp:\r\n");
        pc.printf("DHT22: %.2fC %.1f% \n\r",UdeTemp1,UdeHym1);
        pc.printf("DHT21: %.2fC %.1f% \n\r",UdeTemp2,UdeHym2);
        pc.printf("\n\r");

        wait(2.0);
    }
}
}