#define BLYNK_TEMPLATE_ID "TMPL3oCiCa3CV"
#define BLYNK_TEMPLATE_NAME "DHT"
#define BLYNK_AUTH_TOKEN "EM8cc6ENHleXpNdn4jslcsIxnqYBQyDh"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#define led1 2
#include "DHT.h"
#define DHTPIN 4
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
BLYNK_WRITE(V0) {
int pinValue = param.asInt();
digitalWrite(led1, pinValue);
}
void dht_sensor()
{
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
Serial.print("Humidity: \t" );
Serial.print(h);
Serial.print(" %\n");
delay(500);
Serial.print("Temperature: \t");
Serial.print(t);
Serial.print(" *C \n");
Blynk.virtualWrite(V1, h);
Blynk.virtualWrite(V2, t);
}
void setup() {
// put your setup code here, to run once:
pinMode(led1, OUTPUT);
Blynk.begin(auth, ssid, pass);
Serial.begin(9600);
Serial.println("DHT test!");
dht.begin();
}
void loop() {
// put your main code here, to run repeatedly:
Blynk.run();
//delay(10); // this speeds up the simulation
dht_sensor();
}