#define BLYNK_TEMPLATE_ID "TMPL61o71WRk6"
#define BLYNK_TEMPLATE_NAME "monitoring temperature and humidity"
#define BLYNK_AUTH_TOKEN "3h3jSRJFEQ0_zEPyESC4W2qxLT1Ci1eV"
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <DHT.h> //This line includes the DHT library
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
DHT dht (5, DHT22); //This declares a dht object connected to pin 17, that represents the DHT22 sensor.
float Temperature, Humidity; //This declares two float type variables to store the temperature and humidity.
void setup(){
dht.begin(); //Initializes the DHT sensor.
Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
Serial.begin(9600); //Starts serial communication at a baud rate of 9600.
}
void loop (){
Temperature = dht.readTemperature(); //Reads the temperature from the DHT22 sensor and stores it in the Temperature variable.
Humidity = dht.readHumidity();
Blynk.run();
Blynk.virtualWrite (V0, Temperature);
Blynk.virtualWrite (V1, Humidity) //Reads the humidity from the DHT22 sensor and stores it in the Humidity variable.
//Print the text "T: " followed by the temperature value on the Serial Monitor.
Serial.print("T: ");
Serial.println(Temperature);
//Print the text "H: " followed by the humidity value on the Serial Monitor.
Serial.print("H: ");
Serial.println(Humidity);
delay(1000); //The program waits for 1000 milliseconds (1 second) before reading the temperature and humidity again
}