#define BLYNK_TEMPLATE_ID "TMPL3n4kH_A8j"
#define BLYNK_TEMPLATE_NAME "Home Application 1"
#define BLYNK_AUTH_TOKEN "DbGF1ft3SOklqZ4Weq-TD7-Wc9McbL_u"
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <DHT.h>
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Wokwi-GUEST"; // type your wifi name
char pass[] = ""; // type your wifi password
BlynkTimer timer;
#define DHTPIN 27 //Connect Out pin to D2 in NODE MCU
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
void sendSensor()
{
float h = dht.readHumidity();
float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V1, t);
Blynk.virtualWrite(V2, h);
Serial.print("Temperature : ");
Serial.print(t);
Serial.print(" Humidity : ");
Serial.println(h);
}
void setup()
{
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
dht.begin();
timer.setInterval(100L, sendSensor);
}
void loop()
{
Blynk.run();
timer.run();
}