#include <DHT.h> // Library for DHT Sensors
#define DHTPIN 21 // Pin where the DHT22 is connected
#define DHTTYPE DHT22 // Type of DHT sensor
DHT dht(DHTPIN, DHTTYPE); // Define DHT Library object as dht
void setup() {
Serial.begin(115200); // Serial Monitor
dht.begin(); // Init DHT Sensor
}
void loop() {
float temperature = dht.readTemperature(); // Read temperature in Celsius
float humidity = dht.readHumidity(); // Read humidity
Serial.print("Temp: " + String(temperature, 2) + "°C ");
Serial.println("Humidity: " + String(humidity, 1) + "%");
delay(1000); //Thingspeak Free account limit is 15sec. dont send before this time.
}