BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Blynk Notification not working in app/Mobile

#21

I don’t think I need to visit any barber this year. I changed the code again to the following below and the relay is working properly and now I’m back to Notification, which is not showing in the Blynk app.
What am I missing that is not sending notification to Blynk app?

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


//Blynk online details.
char auth[] = "XXXX"; //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);
  pinMode(D1,INPUT);
  pinMode(D2,INPUT);
  //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();
}
0 Likes

#22

Focus on this part what is wrong that Blynk can’t get notification.

//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);
  pinMode(D1,INPUT);
  pinMode(D2,INPUT);
  //timer.setInterval(3000L,Flame5val);
  

//Set Timer interval.
  timer.setInterval(500L, Flame5val);
  delay(100);
  timer.setInterval(1000L, Flame5);
  }
0 Likes

#23

Are you getting the Serial.println("Button 1 is pressed."); in your monitor?

If not, then the code is not executing the notification part of the code.

Where does val get set? if (val == 1){

Try changing int val; to int val = 1;

Also, you read the state of the pin and store it as a variable, but then just read the state of the pin for the if statement. Doesn’t make much sense to me? I would Either not store the pin state as a variable, or use them in the if statement.

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 (val_1 == HIGH)
      digitalWrite(D0, HIGH);
      Serial.println("Button 1 is pressed.");
         Blynk.notify("FIRE in Room 1");
      if (val_2 == HIGH)
      digitalWrite(D1, HIGH);
      Serial.println("Button 2 is pressed.");
         Blynk.notify("Fire in Room 2");
      if (val_3 == HIGH)
      digitalWrite(D2, HIGH);
      Serial.println("Button 3 is pressed.");
         Blynk.notify("Fire in Room 3");
               }
               
    }

I would also try to be a bit more consistent with stuff. first you use Flame5Pin_1, but then later you use D0?

0 Likes

#24

No, Serial Print is blank as well.

I think this line is the culpit.

Let me work on it.

How am I storing this not sure it would help if you explain more. I have copy pasted from every source I found to make the notification on Blynk app work. Now I’m completely lost.

0 Likes

#25

see code above as to how I would do it.

You should really take the time to understand what the commands and such are, and what they do.

Just blindly copying and pasting code isn’t the best way to go.

If you dont know what the code is doing, how can you troubleshoot it? How do you know it is right?

Especially for a safety system!!

1 Like

#26

OK Now I am getting a different error @Toro_Blanco. I have changed to if (val=1) by removing a = and the

notification is working back on to normal but look at the image below, it’s working a bit too much as it’s always notifying as marked below… What did I do wrong now :(:weary:

0 Likes

#27

What is the error? It is doing exactly what your code is telling it to do. That is, every .5 seconds check the state of the pins, if they are high send notification.

As mentioned you need to learn about coding. There isn’t always an exact piece of code out there waiting for you to cut and paste.

As a hint you need to learn about flags. Although I suspect you need to learn about a lot more as far as programming goes. I suggest a few YouTube videos on some Arduino programming basics.

0 Likes

#28

I think you may have bit off a little more then you can chew.

Start with some simple examples/projects, and once you have a better understanding of how to do things come back to this project. It will make things much easier.

0 Likes

#29

The pins were not high aka not being triggered by anything.

0 Likes

#30

Yeah!!! I am new to this Brother. Previously have done some simple projects but this is really making me run in circles.

0 Likes

#31

I will definitely take a look, I don’t mind learning at all but YouTube videos got me this far and now I don;t know which direction to go.

0 Likes

#32

But that is what the code is looking for. You wrote (I mean copy and pasted) it. I just edited it so it made more sense.

Maybe check to see if they are LOW.

How does the senor work? Is the signal HIGH or LOW when the flame is detected?

0 Likes

#33

The 5 Way Flame Sensor triggers the val to High, this is what I need. When it gets triggered to High, I need Blynk to notify on app, not before or without.
Hope I was able to explain myself. But now I think I modified it in a wrong way, as a result of which this trigger is notifying even when the 5 Way Flame Sensor is Low. What it is?

0 Likes

#34

Solved… :smiley: I have changed the value of the Pin to Low and it started working. Here is the final 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[] = "XXXX"; //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(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) == LOW)
         Serial.println("Button 1 is pressed.");
         Blynk.notify("FIRE in Room 1");
      if (digitalRead(val_2) == LOW)
        Serial.println("Button 2 is pressed.");
         Blynk.notify("Fire in Room 2");
      if (digitalRead(val_3) == LOW)
      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);
  pinMode(D1,INPUT);
  pinMode(D2,INPUT);
  //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();
}
0 Likes

#35

Well it appears you took none of the advise given.

int val_1 = digitalRead(D0); //Read Flame5Pin_1

if (digitalRead(val_1) == LOW)

And if the signal is LOW when flame is detected, how does the relay function correctly if you are looking for the signal to be HIGH?

Best of luck to you.

Glad this isn’t going in any building near me.

0 Likes

#36

I am sorry, I have taken all your advice. I never meant to disobey it. Please point me if I didn’t, as I am a newbie and might miss interpetate.

All I did was changed the signal value to Low and it stated to function just like I wanted it to be. The relay as well is turning On and Off.
Please, advice I don’t want to kill anyone.

0 Likes

#37

Then stop what you are doing.

You obviously don’t have the skills necessary for this level of a project.

No offense, just sayin.

You would be better off buying them all a smoke alarm.

0 Likes

#38

None Taken. Well, I will not install, but I will learn and get back at it. Until then, nothing. I will repost when ready. Hope you are ok with that.

0 Likes

#39

It is not my approval you need.

I’m just here giving advise where I can.

0 Likes

#40

Thank you. :slight_smile: I am at my learning curve and I.m determined to learn, and I will. Your advice was really meaningful.

0 Likes