#include <DHT.h>
DHT dht(8, DHT22); //initialize DHT Sensor
float humidity; //stores humidity value
float temperature; //stores temperature value
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
// Read data from sensors & store it to the variables humidity & temperature.
humidity = dht.readHumidity();
temperature = dht.readTemperature();
//Print temperature and humidity values to serial monitor
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.print("%, Temperature: ");
Serial.print(temperature);
Serial.println("Celsius");
delay(2000); //delay for 2 seconds
}