#define BLYNK_TEMPLATE_ID "TMPL3RNDGyASh"
#define BLYNK_TEMPLATE_NAME "LEDcontrol"
#define BLYNK_AUTH_TOKEN "54b_Tm-h7YU8BhEE_mxB1b8HmmBWdG7g"
#include <LiquidCrystal.h>
#include "DHT.h"
#define DHTPIN 13
#define DHTTYPE DHT22
/* Display */
LiquidCrystal lcd(21, 19, 18, 5, 4, 2);
DHT dht(DHTPIN, DHTTYPE);
// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
BlynkTimer timer;
float h, t, f;
void setup()
{
Serial.begin(115200);
lcd.begin(16, 2);
lcd.clear();
Serial.begin(115200);
Serial.println(F("DHT22 test!"));
dht.begin();
Blynk.begin(auth, ssid, pass);
timer.setInterval(1000L, myTimerEvent);
}
void loop()
{
Blynk.run();
timer.run(); // Initiates BlynkTimer
h = dht.readHumidity();
t = dht.readTemperature();
f = dht.readTemperature(true);
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
float hif = dht.computeHeatIndex(f, h);
float hic = dht.computeHeatIndex(t, h, false);
Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(F("% Temperature: "));
Serial.print(t);
Serial.print(F("°C "));
Serial.print(f);
Serial.print(F("°F Heat index: "));
Serial.print(hic);
Serial.print(F("°C "));
Serial.print(hif);
Serial.println(F("°F"));
lcd.setCursor(0, 0);
lcd.print("Humidity- %");
lcd.setCursor(9, 0);
lcd.print(h,2);
lcd.setCursor(0, 1);
lcd.print("Temp- C");
lcd.setCursor(11, 1);
lcd.print("\337C");
lcd.setCursor(5, 1);
lcd.print(t,2);
delay(500);
}
void myTimerEvent()
{
Blynk.virtualWrite(V2, h);
Blynk.virtualWrite(V3, t);
}