/*************************************************************
You can use this sketch as a debug tool that prints all incoming values
sent by a widget connected to a Virtual Pin 1 in the Blynk App.
App dashboard setup:
Slider widget (0...100) on V1
*************************************************************/
/* Fill-in information from Blynk Device Info here */
#define BLYNK_TEMPLATE_ID "TMPL6rJnb3X_-"
#define BLYNK_TEMPLATE_NAME "Temperature Monitoring"
#define BLYNK_AUTH_TOKEN "R54byKBV8ZrPL1uyPwt2NgiKab0eJpRa"
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <DHT.h>
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
// DHT sensor setup
#define DHT_PIN 12
#define DHT_TYPE DHT22
DHT dht(DHT_PIN, DHT_TYPE);
BlynkTimer timer;
void readDHT()
{
float humidity = dht.readHumidity();
float temperature = dht.readTemperature();
if (!isnan(humidity) && !isnan(temperature)) {
Blynk.virtualWrite(V0, temperature);
Blynk.virtualWrite(V1, humidity);
}
}
void setup()
{
Serial.begin(115200);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
timer.setInterval(2000L, readDHT); // Adjust the interval based on your needs
dht.begin();
}
void loop()
{
Blynk.run();
timer.run();
}