#include "DHT.h"
#define DHTPIN 13
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(115200);
dht.begin(); // initialize the sensor
}
void loop() {
// wait a few seconds between measurements.
// read humidity
float hu = dht.readHumidity();
// read temperature as Celsius
float tc = dht.readTemperature();
// read temperature as Fahrenheit
float tf = dht.readTemperature(true);
// check if any reads failed
if (isnan(hu) || isnan(tc) || isnan(tf)) {
Serial.println("Failed to read from DHT sensor!");
} else {
Serial.print(tc);
Serial.print(" ");
Serial.print(hu);
Serial.print(" ");
Serial.println(tf);
}
}