/*
  iot-technology-ftbs
  program ini menggunakanESP32 dan terhubungan dengan aplikasi Blynk Lagacy
*/
#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "T1234567890"
#define BLYNK_TEMPLATE_NAME "UTS-2204"
#define BLYNK_AUTH_TOKEN "BLYNK_TOKEN"

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

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

BlynkTimer timer;

#define LED1 13

DHTesp dhtSensor;
const int DHT_PIN = 15;


void setup()
{
  dhtSensor.setup(DHT_PIN, DHTesp::DHT22);
  pinMode(LED1, OUTPUT);
  Serial.begin(9600);
  //Blynk.begin(auth, ssid, pass);
  Blynk.begin(auth, ssid, pass, "iot.serangkota.go.id", 8080);
}

void loop()
{
  TempAndHumidity  data = dhtSensor.getTempAndHumidity();
  Blynk.virtualWrite(V12, data.temperature);
  Blynk.virtualWrite(V13, data.humidity);
  Blynk.run();
  timer.run();
}

BLYNK_WRITE (V1)
{
  led1State = param.asInt();

}