#include <DHT.h>
#define DHTPIN 9
#define DHTTYPE DHT22
DHT dht(DHTPIN,DHTTYPE);
void setup() {
// put your setup code here, to run once:
dht.begin();
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
float temperature=dht.readTemperature();
float humidity=dht.readHumidity();
if(isnan(temperature) || isnan(humidity)){
Serial.println("Failed to read from DHT22 sensor!");
}
else{
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.print(" °C | Humidity: ");
Serial.print(humidity);
Serial.println(" %"); delay(3000);
}
}