Blynk Notification not working in app/Mobile

Hi,
I am unable to pull up Blynk notification from the code given below.
The code is running fine and also the hardware is responding but the Blynk app is not notifying. Can you please help?

//Declaration of devices and Timer.
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#define BLYNK_PRINT Serial 
int flag=0;

//Blynk online details.
char auth[] = "XXX"; //Auth code sent via Email
char ssid[] = "XXXX"; //Wifi name
char pass[] = "1XXXX";  //Wifi Password
//char server[] = "Server address here";

//Pin description.
#define relay D8 //Relay is connected to D8 pin of Esp8266
#define Flame5Pin_1 D0 //5way is connected to D0 pin of Esp8266
#define Flame5Pin_2 D1 //5way is connected to D1 pin of Esp8266
#define Flame5Pin_3 D2 //5way is connected to D2 pin of Esp8266


int Flame5State; //Define 5Way Flame Sensor state
int val; //Set value
///int x;

SimpleTimer timer;

///BLYNK_CONNECTED() {
      ///Blynk.syncVirtual(V0); //Virtual Pin define.
//  }
//Blynk Virtual Pin define.
///BLYNK_WRITE(V0){
 ///x = param.asInt();
///}
 
//Blynk read
void Flame5val(){
int val_1 = digitalRead(Flame5Pin_1); //Read Flame5Pin_1
int val_2 = digitalRead(Flame5Pin_2); //Read Flame5Pin_2
int val_3 = digitalRead(Flame5Pin_3); //Read Flame5Pin_3
    if ((val_1 == HIGH) || (val_2 == HIGH) || (val_3 == HIGH))  {
      digitalWrite(relay, HIGH);  
      flag=1;
      }
      else {
        digitalWrite(relay, LOW); 
        flag=0;
      }
   }
//Blynk notify set.
  void Flame5(void){
   if (val == 1) {
      if (digitalRead(Flame5Pin_1) == HIGH)
         Blynk.notify("FIRE in Room 1");
      if (digitalRead(Flame5Pin_2) == HIGH)
         Blynk.notify("Fire in Room 2");
      if (digitalRead(Flame5Pin_3) == HIGH)
         Blynk.notify("Fire in Room 3");
         flag=1;
      }
    }
    
void setup(){
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
  //Blynk.begin (auth, ssid, pass, server, 8080);//local server
   // You can change server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);

  pinMode(relay, OUTPUT); //Relay output in Pin D8
  pinMode(Flame5Pin_1, INPUT); //Flame5Pin D0
  pinMode(Flame5Pin_2, INPUT); //Flame5Pin D1
  pinMode(Flame5Pin_3, INPUT); //Flame5Pin D2
  timer.setInterval(3000L,Flame5val);
  delay(100);

//Set Timer interval.
  timer.setInterval(2000L, Flame5val);
   timer.setInterval(3000L, Flame5);
  }
  //Loop set.
void loop(){
   Blynk.run();
   timer.run();
}

Why is this topic shown in Grey color??? Have you blocked me or something???

Your post doesn’t appear grey to me, and your user privileges appear normal.

There are several things wrong with your code, but as you know I’m not prepared to get involved in this project so I’ll leave to to others to help you with it - assuming that they are prepared to get involved.

Pete.

@PeteKnight Bro you make me sound like a Terrorist or something. Trust me I am doing this for a good cause and, I have already spent so much and I can’t get any notification on Blynk app. After hearing those details from you I have even completely disconnected Blynk from the main fire system and used a custom Buzzer for each floor separating it from the main fire alarm system. I am not that bad as you might think man.

It was working all fine now Blynk won’t notify.

Details…??? Do you have the notifications widget on your app screen?

Yes @daveblynk and it’s set to high priority and all. Problem is in the code i think.

To trouble shoot put a notify in the setup and see if it notifies. Maybe it isn’t being called in the code.

I have tried to change the format and I am getting errors. Here is the new format code below:

//Declaration of devices and Timer.
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
//#include <SimpleTimer.h>
#define BLYNK_PRINT Serial 

//Blynk online details.
char auth[] = "XXX"; //Auth code sent via Email
char ssid[] = "XXXX"; //Wifi name
char pass[] = "XXXX";  //Wifi Password
//char server[] = "Server address here";

//Pin description.
#define relay D8 //Relay is connected to D8 pin of Esp8266
#define Flame5Pin_1 D0 //5way is connected to D0 pin of Esp8266
#define Flame5Pin_2 D1 //5way is connected to D1 pin of Esp8266
#define Flame5Pin_3 D2 //5way is connected to D2 pin of Esp8266


//int Flame5State; //Define 5Way Flame Sensor state
int val; //Set value
///int x;
BlynkTimer timer;
///SimpleTimer timer;

///BLYNK_CONNECTED() {
      ///Blynk.syncVirtual(V0); //Virtual Pin define.
//  }
//Blynk Virtual Pin define.
///BLYNK_WRITE(V0){
 ///x = param.asInt();
///}
 
//Blynk read
void Flame5val(){
int val_1 = digitalRead(Flame5Pin_1); //Read Flame5Pin_1
int val_2 = digitalRead(Flame5Pin_2); //Read Flame5Pin_2
int val_3 = digitalRead(Flame5Pin_3); //Read Flame5Pin_3
    if ((val_1 == HIGH) || (val_2 == HIGH) || (val_3 == HIGH))  {
      digitalWrite(relay, HIGH);  
   
      }
      else {
        digitalWrite(relay, LOW); 
   
      }
   }
//New Format for notify
void notifyOnFlame0Press()
{
  // Invert state, since button is "Active LOW"
  int isButtonPressed = !digitalRead(D0);
  if (isButtonPressed) {
    Serial.println("Button 0 is pressed.");
    // Note:
    //   We allow 1 notification per 15 seconds for now.
    Blynk.notify("FIRE in Room 1");
  }
  void notifyOnFlame1Press()
  {
  // Invert state, since button is "Active LOW"
  int isButtonPressed = !digitalRead(D1);
  if (isButtonPressed) {
    Serial.println("Button 1 is pressed.");
    // Note:
    //   We allow 1 notification per 15 seconds for now.
    Blynk.notify("FIRE in Room 2");
  }
  
  void notifyOnFlame2Press()
{
  // Invert state, since button is "Active LOW"
  int isButtonPressed = !digitalRead(D2);
  if (isButtonPressed) {
    Serial.println("Button 2 is pressed.");
    // Note:
    //   We allow 1 notification per 15 seconds for now.
    Blynk.notify("FIRE in Room 3");
  }
/*  
//Blynk notify set.
  void Flame5(void){
int val_1 = digitalRead(Flame5Pin_1); //Read Flame5Pin_1
int val_2 = digitalRead(Flame5Pin_2); //Read Flame5Pin_2
int val_3 = digitalRead(Flame5Pin_3); //Read Flame5Pin_3
   if (val == 1) {
      if (digitalRead(val_1) == HIGH)
         Blynk.notify("FIRE in Room 1");
      if (digitalRead(val_2) == HIGH)
         Blynk.notify("Fire in Room 2");
      if (digitalRead(val_3) == HIGH)
         Blynk.notify("Fire in Room 3");
               }
               
    }
  */  
    
void setup(){
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
  //Blynk.begin (auth, ssid, pass, server, 8080);//local server
   // You can change server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);

  pinMode(relay, OUTPUT); //Relay output in Pin D8
  pinMode(Flame5Pin_1, INPUT); //Flame5Pin D0
  pinMode(Flame5Pin_2, INPUT); //Flame5Pin D1
  pinMode(Flame5Pin_3, INPUT); //Flame5Pin D2

  pinMode(D1,INPUT_PULLUP);
  pinMode(D1,INPUT_PULLUP);
  pinMode(D2,INPUT_PULLUP);
  //timer.setInterval(3000L,Flame5val);
  

//Set Timer interval.
  timer.setInterval(500L, Flame5val);
  delay(100);
  timer.setInterval(1000L, Flame5);
  }
  //Loop set.
void loop(){
   Blynk.run();
   timer.run();
}

What errors??

Unnecessary PinMode duplication… all overruled by final three commands (of which one is in error… no D0?)

@Gunner Thanks.
I have found that in Blynk if I write INPUT_PULLUP it sends notification to Blynk notification app. But if I use it alone without writing INPUT the code fails to compile. I am unable to get any notification on the Blynk app or in the Serial monitor.

Writing these lines alone keeps the Relay module on at all times. I am going in circles.

The error
exit status 1 a function-definition is not allowed here before '{' token

You’re missing a bracket after the closing bracket of the if function

Your code:

void notifyOnFlame1Press(){
if(...){
    ...
}

What you need:

void notifyOnFlame1Press(){
    if(....) {
        ...
    }
} <——- missing

If that makes sense.

I tried and fixed this.
Now when I try to compile the below code it works, as in compiles but when I upload it, the Blynk notification doesn’t work and also it keeps the Relay Module on at all time.

//Declaration of devices and Timer.
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
//#include <SimpleTimer.h>
#define BLYNK_PRINT Serial 

//Blynk online details.
char auth[] = "XXX"; //Auth code sent via Email
char ssid[] = "XXX"; //Wifi name
char pass[] = "XXX";  //Wifi Password
//char server[] = "Server address here";

//Pin description.
#define relay D8 //Relay is connected to D8 pin of Esp8266
#define Flame5Pin_1 D0 //5way is connected to D0 pin of Esp8266
#define Flame5Pin_2 D1 //5way is connected to D1 pin of Esp8266
#define Flame5Pin_3 D2 //5way is connected to D2 pin of Esp8266


//int Flame5State; //Define 5Way Flame Sensor state
int val; //Set value
///int x;
BlynkTimer timer;
///SimpleTimer timer;

///BLYNK_CONNECTED() {
      ///Blynk.syncVirtual(V0); //Virtual Pin define.
//  }
//Blynk Virtual Pin define.
///BLYNK_WRITE(V0){
 ///x = param.asInt();
///}
 
//Blynk read
void Flame5val(){
int val_1 = digitalRead(Flame5Pin_1); //Read Flame5Pin_1
int val_2 = digitalRead(Flame5Pin_2); //Read Flame5Pin_2
int val_3 = digitalRead(Flame5Pin_3); //Read Flame5Pin_3
    if ((val_1 == HIGH) || (val_2 == HIGH) || (val_3 == HIGH))  {
      digitalWrite(relay, HIGH);  
   
      }
      else {
        digitalWrite(relay, LOW); 
   
      }
   }
   /*
//New Format for notify
void notifyOnFlame0Press()
{
  // Invert state, since button is "Active LOW"
  int isButtonPressed = !digitalRead(D0);
  if (isButtonPressed) {
    Serial.println("Button 0 is pressed.");
    // Note:
    //   We allow 1 notification per 15 seconds for now.
    Blynk.notify("FIRE in Room 1");
  }
  void notifyOnFlame1Press()
  {
  // Invert state, since button is "Active LOW"
  int isButtonPressed = !digitalRead(D1);
  if (isButtonPressed) {
    Serial.println("Button 1 is pressed.");
    // Note:
    //   We allow 1 notification per 15 seconds for now.
    Blynk.notify("FIRE in Room 2");
  }
  
  void notifyOnFlame2Press()
{
  // Invert state, since button is "Active LOW"
  int isButtonPressed = !digitalRead(D2);
  if (isButtonPressed) {
    Serial.println("Button 2 is pressed.");
    // Note:
    //   We allow 1 notification per 15 seconds for now.
    Blynk.notify("FIRE in Room 3");
  }
  */

//Blynk notify set.
  void Flame5(void){
int val_1 = digitalRead(Flame5Pin_1); //Read Flame5Pin_1
int val_2 = digitalRead(Flame5Pin_2); //Read Flame5Pin_2
int val_3 = digitalRead(Flame5Pin_3); //Read Flame5Pin_3
     if (val == 1) {
      if (digitalRead(val_1) == HIGH)
      Serial.println("Button 1 is pressed.");
         Blynk.notify("FIRE in Room 1");
      if (digitalRead(val_2) == HIGH)
      Serial.println("Button 2 is pressed.");
         Blynk.notify("Fire in Room 2");
      if (digitalRead(val_3) == HIGH)
      Serial.println("Button 3 is pressed.");
         Blynk.notify("Fire in Room 3");
               }
               
    }
    
     
void setup(){
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
  //Blynk.begin (auth, ssid, pass, server, 8080);//local server
   // You can change server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);

  pinMode(relay, OUTPUT); //Relay output in Pin D8
  //pinMode(Flame5Pin_1, INPUT); //Flame5Pin D0
  //pinMode(Flame5Pin_2, INPUT); //Flame5Pin D1
  //pinMode(Flame5Pin_3, INPUT); //Flame5Pin D2

  pinMode(D0,INPUT_PULLUP);
  pinMode(D1,INPUT_PULLUP);
  pinMode(D2,INPUT_PULLUP);
  //timer.setInterval(3000L,Flame5val);
  

//Set Timer interval.
  timer.setInterval(500L, Flame5val);
  delay(100);
  timer.setInterval(1000L, Flame5);
  }
  //Loop set.
void loop(){
   Blynk.run();
   timer.run();
}

Unless your relays are Active LOW, then yes, these are activating your relays by setting these Pins to default to HIGH if not otherwise held LOW.

Besides, D0 is not the best pin to use…

1 Like

How can I do that by default? Where do I look for it?

Can I use the following command?
#define RELAY_ON LOW

1 Like

No no no… :stuck_out_tongue:

A relay is either Active HIGH - energised when the signal pin is 3.3v or 5v… depending on MCU type

Or Active LOW - energised when the signal pin is 0v or Grounded.

So first determine how your relay works, then set your pinMode(pin, OUTPUT); as basic OUTPUT and handle the rest with a followup command digitalWrite(pin, LOW); or digitalWrite(pin, HIGH);

1 Like

Changed the code to this below but still the same :frowning:

//Declaration of devices and Timer.
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
//#include <SimpleTimer.h>
#define BLYNK_PRINT Serial 


//Blynk online details.
char auth[] = "XXX"; //Auth code sent via Email
char ssid[] = "XXX"; //Wifi name
char pass[] = "XXX";  //Wifi Password
//char server[] = "Server address here";

//Pin description.
#define relay D8 //Relay is connected to D8 pin of Esp8266
#define Flame5Pin_1 D0 //5way is connected to D0 pin of Esp8266
#define Flame5Pin_2 D1 //5way is connected to D1 pin of Esp8266
#define Flame5Pin_3 D2 //5way is connected to D2 pin of Esp8266


//int Flame5State; //Define 5Way Flame Sensor state
int val; //Set value
///int x;
BlynkTimer timer;
///SimpleTimer timer;

///BLYNK_CONNECTED() {
      ///Blynk.syncVirtual(V0); //Virtual Pin define.
//  }
//Blynk Virtual Pin define.
///BLYNK_WRITE(V0){
 ///x = param.asInt();
///}
 
//Blynk read
void Flame5val(){
int val_1 = digitalRead(Flame5Pin_1); //Read Flame5Pin_1
int val_2 = digitalRead(Flame5Pin_2); //Read Flame5Pin_2
int val_3 = digitalRead(Flame5Pin_3); //Read Flame5Pin_3
    if ((val_1 == HIGH) || (val_2 == HIGH) || (val_3 == HIGH))  {
      digitalWrite(relay, HIGH);  
   
      }
      else {
        digitalWrite(relay, LOW); 
   
      }
   }
   /*
//New Format for notify
void notifyOnFlame0Press()
{
  // Invert state, since button is "Active LOW"
  int isButtonPressed = !digitalRead(D0);
  if (isButtonPressed) {
    Serial.println("Button 0 is pressed.");
    // Note:
    //   We allow 1 notification per 15 seconds for now.
    Blynk.notify("FIRE in Room 1");
  }
  void notifyOnFlame1Press()
  {
  // Invert state, since button is "Active LOW"
  int isButtonPressed = !digitalRead(D1);
  if (isButtonPressed) {
    Serial.println("Button 1 is pressed.");
    // Note:
    //   We allow 1 notification per 15 seconds for now.
    Blynk.notify("FIRE in Room 2");
  }
  
  void notifyOnFlame2Press()
{
  // Invert state, since button is "Active LOW"
  int isButtonPressed = !digitalRead(D2);
  if (isButtonPressed) {
    Serial.println("Button 2 is pressed.");
    // Note:
    //   We allow 1 notification per 15 seconds for now.
    Blynk.notify("FIRE in Room 3");
  }
  */

//Blynk notify set.
  void Flame5(void){
int val_1 = digitalRead(D0); //Read Flame5Pin_1
int val_2 = digitalRead(D1); //Read Flame5Pin_2
int val_3 = digitalRead(D2); //Read Flame5Pin_3
     if (val == 1) {
      if (digitalRead(val_1) == HIGH)
      digitalWrite(D0, HIGH);
      Serial.println("Button 1 is pressed.");
         Blynk.notify("FIRE in Room 1");
      if (digitalRead(val_2) == HIGH)
      digitalWrite(D1, HIGH);
      Serial.println("Button 2 is pressed.");
         Blynk.notify("Fire in Room 2");
      if (digitalRead(val_3) == HIGH)
      digitalWrite(D2, HIGH);
      Serial.println("Button 3 is pressed.");
         Blynk.notify("Fire in Room 3");
               }
               
    }
    
     
void setup(){
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
  //Blynk.begin (auth, ssid, pass, server, 8080);//local server
   // You can change server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);

  pinMode(relay, OUTPUT); //Relay output in Pin D8
  //pinMode(Flame5Pin_1, INPUT); //Flame5Pin D0
  //pinMode(Flame5Pin_2, INPUT); //Flame5Pin D1
  //pinMode(Flame5Pin_3, INPUT); //Flame5Pin D2

  pinMode(D0,INPUT_PULLUP);
  pinMode(D1,INPUT_PULLUP);
  pinMode(D2,INPUT_PULLUP);
  //timer.setInterval(3000L,Flame5val);
  

//Set Timer interval.
  timer.setInterval(500L, Flame5val);
  delay(100);
  timer.setInterval(1000L, Flame5);
  }
  //Loop set.
void loop(){
   Blynk.run();
   timer.run();
}