Fire & Smoke - Problems with Notifications

Hi There,

This is KM, I am having quite similar issues to this topic, Here is the hardware that i am using.

  1. NodeMCU
  2. Fire sensor mobule https://images-na.ssl-images-amazon.com/images/I/61hndEsh-dL.SX425.jpg
  3. Gas https://images-na.ssl-images-amazon.com/images/I/31YWXNCD0IL.jpg
  4. beep speaker

I managed to use the same code that use by Bashar (Thanks Bashar & Pete)

Although I am using the similar code, i have added few more lines to achieve the item#2

  1. when fire is detected i need a notification to my Blynk App. (this is working fine)

  2. (Item2) When smoke is detected value above 120 i need a notification to my Blynk app like how i got for Fire alarm & also need to start the beep

The beep speaker is connected to D8 and the other ping is at Ground.

No errors when i validate or update the code. but the issue i am facing now is.

when i make some smoke, i can see the Gauge value is increased, but i dont receive any notification D8 is not active. (basically the sound is on all the time)
also i want to use virtual pin V5 to activate the pinD8, I did that by using blynk Eventor settings, below is the command.

blynk Eventor Settings

“When V5 is higher than 120 turn ON D8”

Appreciate someone’s help on this.

Below is the nodeMCU 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[] = “4d564cb29bd9410b8c23ba318e17772e”; //Auth code sent via Email
char ssid[] = “mywifi”; //Wifi name
char pass[] = “mypassword”; //Wifi Password
int flag=0;
int gas_value;
int gas_avalue;
int mq135 =A0; //smoke sensor is connected with the analog A0
int data =0;

void notifyOnFire() //Flame Sensor Code
{
int isButtonPressed = digitalRead(D5);
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 = analogRead(A0);
if (isButtonPressed==1 && flag==0)
{
Serial.println(“Alert!!! SMOKE is Detected.”);
Blynk.notify(“Alert!!! SMOKE is Detected.”);
Blynk.virtualWrite(V5, gas_avalue);

flag=1;
}
else if (isButtonPressed==0)
{
flag=0;
}
}

void setup()
{
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
pinMode(D5,INPUT_PULLUP);
pinMode (A0,INPUT_PULLUP);
timer.setInterval(1000L,notifyOnFire);
delay(100);
timer.setInterval(1000L,notifyOnSmoke);
}

void loop()
{
Blynk.run();
timer.run();
}

/******************************************
*Send sensor data to Blynk
******************************************/
void getSendData()
{
  data = analogRead(mq135);
    Blynk.virtualWrite(V5, data); //virtual pin V5

    if (data > 120)
    {
      Blynk.notify ("Somke Detected!");
    }
}

Regards
KM

@kernelmaker99a as you’ve obviously read the other posts in this topic, you’ll know that code has to have triple backticks at the beginning and end for it to display correctly.
Triple backticks look like this:
```

Please edit your post, using the pencil icon at the bottom, and add your code back in - this time with triple backticks at the beginning and end.

Pete.

Thanks Sir Pete, for the fastest response.
My apology on the mistake as i overlooked on the right procedure to past the command in the forum.

You’ve still not done it correctly, you’ve used *** characters instead of backticks.
I gave you some backticks to copy and paste, please use them.

Pete.

Yes Sir, I just done that.

You can have a look at the similar code in GitHub

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

@kernelmaker99a rather than allow you to keep hijacking existing topics with your specific issues, I’ve moved your comments from both of the topics that you’ve been posting in to this new topic. Please use it for all of your posts relating to this project, and in future create a new topic for your specific issues.

As far as debugging your existing code, I’d suggest that that you add some serial print statements to your code so that you can see the values of the variables used in your if statements. These obviously need to be before the if statements

Pete.

Thanks Pete,

Meaning i have to use D2 pin is it? I have been using A0 pin on my NodeMCU all this while.
Let me correct that, Thank you.

Regards
KM

Thanks Bashar!

Hi Pete,

Sure.

Thanks,

Regards
KM

I think you can use the code which is written for NodeMCU. Just change these two lines:

#define USE_BLYNK_WM   true
//#define USE_BLYNK_WM   false

into

//#define USE_BLYNK_WM   true
#define USE_BLYNK_WM   false

You can also change the pins in the sketch to match your configuration or use the pins as is in the sketch.

#define MQ135_PIN             A0
#define FLAME_SENSOR_PIN      D3
#define BUZZER_PIN            D7