#include <DHT.h>
#define DHTPIN 1 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
// Wait a few seconds between measurements.
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
// Convert temperature to Kelvin and Reaumur
float kelvin = t + 273.15;
float reaumur = t * 0.8;
// Print temperature and humidity
Serial.print("Sample OK: ");
Serial.print(t);
Serial.print(" *C, ");
Serial.print(kelvin);
Serial.print(" K, ");
Serial.print(reaumur);
Serial.println(" Re");
}