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
when fire is detected i need a notification to my Blynk App. (this is working fine)
(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!");
}
}
@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.
@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