#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "TMPL3XvWT_aYr"
#define BLYNK_TEMPLATE_NAME "poject3"
#define BLYNK_AUTH_TOKEN "UWg-oAScOD8JUN5YJM4_Hg-Z6KlkIbTf"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include "DHT.h"
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <TimeLib.h>
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 20, 4);
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
//BlynkTimer timer;
const byte LED1 = 13; // Merah
const byte LED2 = 12; // Kuning
const byte LED3 = 14 ; // Hijau
int SW_State_M = 0;
int SW_State_K = 0;
int SW_State_H = 0;
const byte DHTPIN = 15; // GPIO that is connected to the sensor
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
const byte Trig = 18;
const byte Echo = 19;
float jarak = 0;
float ketinggian_air = 0;
float dht_temp;
float dht_hum;
void setup()
{
dht.begin();
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(Trig, OUTPUT);
pinMode(Echo, INPUT);
Serial.begin(9600);
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Connecting to Blynk ");
lcd.setCursor(0, 1);
lcd.print("WiFi ");
//Blynk.begin(auth, ssid, pass);
Blynk.begin(auth, ssid, pass, "iot.serangkota.go.id", 8080);
lcd.setCursor(0, 1);
lcd.print("Success");
delay(2000);
lcd.clear();
}
void loop()
{
ReadSensorPING();
ReadSensorDHT();
Blynk.virtualWrite(V12, dht_hum);
Blynk.virtualWrite(V13, dht_temp);
Blynk.virtualWrite(V14, ketinggian_air);
Blynk.run();
//timer.run();
requestTime();
}