#include "DHT.h"
#define DHTPIN 2 // Pin where the data pin of the sensor is connected
#define DHTTYPE DHT22 // Change to DHT22 if you are using that sensor
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
delay(2000); // Wait 2 seconds between measurements
float humidity = dht.readHumidity();
float temperature = dht.readTemperature(); // Default is Celsius
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" *C");
}