//konfigurasi blynk
#define BLYNK_TEMPLATE_ID "TMPL6YsZ00XnQ"
#define BLYNK_TEMPLATE_NAME "Tugas Akhir"
#define BLYNK_AUTH_TOKEN "NB2XtqyReN_3lbbnxPqnR1ATqp2Y_tkK"
#define BLYNK_PRINT Serial
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <WiFi.h>
#define relay 2
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "UHO";
char pass[] = "w1w1w1w1";
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(relay, OUTPUT);
digitalWrite(relay, HIGH);
// dht.begin();
WiFi.begin(ssid, pass);
koneksiWifi();
Blynk.begin(auth, ssid, pass);
}
void loop() {
// put your main code here, to run repeatedly:
Blynk.run();
}
BLYNK_WRITE(V4) {
int statusTombol = param.asInt();
if (statusTombol == 1) {
digitalWrite(relay, LOW);
Serial.println("tombol ditekan");
} else if (statusTombol == 0) {
//digitalWrite(relay, LOW);
}
}
void koneksiWifi() {
Serial.println("Menghubungkan Wifi");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.println("Wifi belum terhubung");
}
Serial.println("Wifi terhubung");
Serial.print("Menhubungkan ke Blynk dengan token: ");
Serial.println(auth);
}