#include <DHT.h>
#define DHTPIN 4 // Pin connected to the DHT22 data pin
#define DHTTYPE DHT22 // DHT22 sensor type
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600); // Initialize serial communication
dht.begin(); // Initialize the DHT sensor
}
void loop() {
delay(2000); // Wait 2 seconds between readings
// Read humidity and temperature (Celsius)
float humidity = dht.readHumidity();
float temperature = dht.readTemperature();
// Print the values to the Serial Monitor
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.print("%, Temperature: ");
Serial.print(temperature);
Serial.println("°C");
}