#define BLYNK_TEMPLATE_ID "TMPL6Vm501gjw"
#define BLYNK_TEMPLATE_NAME "Excercise"
#define BLYNK_AUTH_TOKEN "gwyg3IJUcCBDlpQK1p8Emq9zEff6yNLl"
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
// Define the pin to which the flame sensor is connected
const int flameSensorPin = 25; // Example pin number, adjust as needed
const int ledPin = 14; // Example pin number for LED, adjust as needed
const int buzzerPin = 5; // Example pin number for buzzer, adjust as needed
void setup() {
Serial.begin(9600); // Initialize serial communication for debugging
pinMode(flameSensorPin, INPUT); // Set flame sensor pin as input
pinMode(ledPin, OUTPUT); // Set LED pin as output
pinMode(buzzerPin, OUTPUT); // Set buzzer pin as output
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
}
void loop() {
Blynk.run();
// Read the state of the flame sensor
int flameDetected = analogRead(flameSensorPin);
Serial.println(flameDetected);
// Output the result
if (flameDetected <100) {
Serial.println("Flame detected!");
Blynk.logEvent("fire_warning_alarm");
digitalWrite(ledPin, HIGH); // Turn on LED
digitalWrite(buzzerPin, HIGH); // Turn on buzzer
} else {
Serial.println("No flame detected.");
digitalWrite(ledPin, LOW); // Turn off LED
digitalWrite(buzzerPin, LOW); // Turn off buzzer
}
delay(1000); // Delay for readability, adjust as needed
}