Outputs the atmospheric humidity and temperature data.
Coding:
/*
* http://arduspot.blogspot.in/p/dht1.html
*/
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup()
{
Serial.begin(9600);
dht.begin();
}
void loop()
{
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t))
{
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Humidity: ");
Serial.println(h);
Serial.print("Temperature: ");
Serial.println(t);
Serial.print(" *C ");
}

No comments:
Post a Comment