Thanks Alot Khoih for share the complete project.
I spotted an error as <BlynkSimpleEsp8266.h>
moreover, due to come hardware constrain, i cant use this at the moment, thanks alot for your help.
My plan now is to continue with Fire & Smoke notification that I can receive in my Blynk app.
Alarm / beep is not needed.
Hi Pete,
based on my situation, I plan not to continue setting any alarm when it trigger threshold.
I used the exact code as per in your post at
the issue i spotted is, when there is a fire, i got notification
but when there is a smoke, I didn’t get a notification
below is the code.
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;
//Auth Code, Wi-Fi and others.
char auth[] = "i-use-my-token"; //Auth code sent via Email
char ssid[] = "mywifi"; //Wifi name
char pass[] = "mypassword"; //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();
}
Regards
KM