#define BLYNK_PRINT Serial
/* Fill in information from Blynk Device Info here */
#define BLYNK_TEMPLATE_ID "TMPL64hmXTCN5"
#define BLYNK_TEMPLATE_NAME "Litar IoT"
#define BLYNK_AUTH_TOKEN "dGNzwYgxABMREoinV2FV4OnOTnomncdg"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
#include <DHT.h>
#define DHTPIN 32
// Uncomment whatever type you're using!
//#define DHTTYPE DHT22 //DHT 11
#define DHTTYPE DHT22 // DHT22,AM2302,AM2331
//#define DHTTYPE DHT21 // DHT 21,AM2301
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
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;
}
Blynk.virtualWrite(V5,h);
Blynk.virtualWrite(V6,t);
if(t > 40)
{
Blynk.logEvent("notif");
}
}
void setup()
{
//Debug console
Serial.begin(9600);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
dht.begin();
//Setup a funtion to be called every second
timer.setInterval(1000L, sendSensor);
}
void loop()
{
Blynk.run();
timer.run();
}