// credencial blynk
#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "TMPLbT1MRc-f"
#define BLYNK_AUTH_TOKEN "FU_xLeYPfSRnZ8TqxYMmAzKJ1zPMJTjI"

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include "DHTesp.h"

#define dhtPin 15
DHTesp dhtSensor;

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

BlynkTimer timer;

void sendSensorData(){
  TempAndHumidity data = dhtSensor.getTempAndHumidity();
  Serial.println("Temp : " + String(data.temperature, 2) + "^C");
  Blynk.virtualWrite(V0, data.temperature);
}

void setup() {
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  dhtSensor.setup(dhtPin, DHTesp::DHT22);
  timer.setInterval(1000L, sendSensorData);
}

void loop() {
  // TempAndHumidity data = dhtSensor.getTempAndHumidity();
  // Serial.println(data.temperature);
  // // put your main code here, to run repeatedly:
  // delay(1000); // this speeds up the simulation
  Blynk.run();
  timer.run();
}