You have a number of issues including:
An unwanted semicolon here:
The wrong number of closing curly brackets in your notifyOnFire()
and notifyOnSmoke()
functions.
A typo in the word “Interval” in your second timer:
and these two timers are trying to execute at exactly the same time, so they need a small delay between each.
Here’s the amended code:
//Blynk Fire Alarm Notification
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;
//Auth Code, Wi-Fi and others.
char auth[] = "XXXX"; //Auth code sent via Email
char ssid[] = "XXXX"; //Wifi name
char pass[] = "XXXX"; //Wifi Password
int flag=0;
int gas_value;
int gas_avalue;
void notifyOnFire() //Flame Sensor Code
{
int isButtonPressed = digitalRead(D1);
if (isButtonPressed==1 && flag==0)
{
Serial.println("Fire in the House");
Blynk.notify("Alert : Fire in the House");
flag=1;
}
else if (isButtonPressed==0)
{
flag=0;
}
}
void notifyOnSmoke() //SMOKE Sensor Code
{
int isButtonPressed = digitalRead(D2);
if (isButtonPressed==1 && flag==0)
{
Serial.println("Alert!!! SMOKE is Detected.");
Blynk.notify("Alert!!! SMOKE is Detected.");
flag=1;
}
else if (isButtonPressed==0)
{
flag=0;
}
}
void setup()
{
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
pinMode(D1,INPUT_PULLUP);
pinMode (D2,INPUT_PULLUP);
timer.setInterval(1000L,notifyOnFire);
delay(100);
timer.setInterval(1000L,notifyOnSmoke);
}
void loop()
{
Blynk.run();
timer.run();
}
Pete.