#define BLYNK_TEMPLATE_ID "TMPL6AVYraEGj"
#define BLYNK_TEMPLATE_NAME "Dht 22"
#define BLYNK_AUTH_TOKEN "Dmp-oHfGSL45Eb9SKAD8AOrDkgTJloo8"
/* Fill-in your Template ID (only if using Blynk.Cloud) */
//#define BLYNK_TEMPLATE_ID "YourTemplateID"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <DHT.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = BLYNK_AUTH_TOKEN;
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Wokwi-GUEST"; //untuk jaringan wifi yang dipakai
char pass[] = "";
int lampu1 = 5;
#define DHTPIN 15
#define DHTTYPE DHT22 // Tipe sensor DHT (DHT11 atau DHT22)
DHT dht(DHTPIN, DHTTYPE);
BLYNK_WRITE (V2) {
int status = param.asInt();
if(status) {
digitalWrite(lampu1, HIGH);
}
else{
digitalWrite(lampu1, LOW);
}
}
void setup()
{
// Debug console
Serial.begin(9600);
pinMode(lampu1, OUTPUT);
dht.begin();
Blynk.begin(auth, ssid, pass);
}
void loop()
{
Blynk.run();
float temperature = dht.readTemperature();
Blynk.virtualWrite (V4, String (temperature) + "C");
}