#define BLYNK_TEMPLATE_ID "TMPL6FnLgqIph"
#define BLYNK_TEMPLATE_NAME "Monitoring Smoke Sensor"
#define BLYNK_AUTH_TOKEN "p5Wz7EztqXa9t3HtTXmfbGTeeV6XG9Tm"
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
#define BLYNK_AUTH_TOKEN "" //Enter your blynk auth token
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Wokwi-GUEST";//Enter your WIFI name
char pass[] = "";//Enter your WIFI password
const int smokeSensorPin = 34; // Pin analog untuk sensor asap
const int buzzer = 4; // Pin untuk buzzerD indikator
void setup() {
Serial.begin(115200);
delay(100);
pinMode(smokeSensorPin, INPUT);
pinMode(buzzer,OUTPUT);
Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
}
void loop() {
int smokeLevel = analogRead(smokeSensorPin);
Blynk.virtualWrite(A0,smokeLevel);
Serial.print("Smoke Level: ");
Serial.println(smokeLevel);
int threshold = 500000;
if (smokeLevel > threshold ) { // Sesuaikan ambang batas sesuai kebutuhan
digitalWrite(buzzer, HIGH);
Serial.println("Deteksi Asap!");
} else {
digitalWrite(buzzer, LOW);
}
delay(1000); // Delay untuk menghindari pembacaan yang terlalu cepat
Blynk.run();
}