#define BLYNK_TEMPLATE_ID "TMPL-Vz9P9CB"
#define BLYNK_TEMPLATE_NAME "dht22"
#define BLYNK_AUTH_TOKEN "x8P9CQKp6myYtHDrs09RPUVGRmUb1wxw"

#define BLYNK_PRINT Serial

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <LiquidCrystal_I2C.h>
#include "DHTesp.h"
LiquidCrystal_I2C lcd(0x27, 16, 2);
char auth[] = BLYNK_AUTH_TOKEN;

char ssid[] = "Wokwi-GUEST";
char pass[] = "";

const int DHT_PIN = 23;

DHTesp dhtSensor;
BlynkTimer timer;
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.print("Tes Sensor DHT22");
  dhtSensor.setup(DHT_PIN, DHTesp::DHT22);
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(2500L, sendSensor);
}
void loop() {
  Blynk.run();
  timer.run();
  
}
void sendSensor() {
  TempAndHumidity data = dhtSensor.getTempAndHumidity();
  float t = data.temperature;
  float h = data.humidity;

  if(isnan(t) || isnan(h)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  Blynk.virtualWrite(V0, t);
  Blynk.virtualWrite(V1, h);

  Serial.print("Nilai suhu");
  Serial.print(t);
  Serial.print(" ||Kelembaban : ");
  Serial.println(h);

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Suhu : ");
  lcd.setCursor(10, 0);
  lcd.print("RH : ");
  lcd.setCursor(0, 1);
  lcd.print(t,1);
  lcd.print((char)223);
  lcd.print("C");
  lcd.setCursor(10, 1);
  lcd.print(h,1);
  lcd.print("%");
  if (t > 70) {
    Blynk.logEvent("notifikasi", "Suhu diatas 70 derajat celcius");

  }
}
Loading
esp32-devkit-c-v4