#include <WiFi.h>
#include <DHT.h>

#define BLYNK_TEMPLATE_ID "TMPL6st9g5Zrv"
#define BLYNK_TEMPLATE_NAME "DHT22 Monitor"
#define BLYNK_AUTH_TOKEN "gIJkbsCbrJdslNSBShr-gP798vx0C5uP"
#include <BlynkSimpleEsp32.h>

#define DHTPIN  23
#define TEMP    V0
#define HUMI    V1

#define SSID    "Wokwi-GUEST"
#define PASS    ""

DHT dht(DHTPIN, DHT22);
BlynkTimer timer;

void sendSensorValue() {
  float t = dht.readTemperature();
  float h = dht.readHumidity();

  Serial.println("Temperature: " + String(t, 1) + "°C" + "\tHumidity: " + String(h) + "%");

  Blynk.virtualWrite(TEMP, t);
  Blynk.virtualWrite(HUMI, h);
}

void setup() {
  Serial.begin(115200);
  dht.begin();
  Blynk.begin(BLYNK_AUTH_TOKEN, SSID, PASS);
  timer.setInterval(1000L, sendSensorValue);
}

void loop() {
  Blynk.run();
  timer.run();
}