BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       👉 SKETCH BUILDER

BLYNK IOT problem push notification

Hello
I am new to programming, and I would like your help.
I have been working here for a long time on the following sketch

/*************************************************************

  This is a simple demo of sending and receiving some data.
  Be sure to check out other examples!
 *************************************************************/

// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud
// See the Device Info tab, or Template settings
//define BLYNK_TEMPLATE_ID           "TMPLW********"
//#define BLYNK_DEVICE_NAME           "home alarm *******"
//#define BLYNK_AUTH_TOKEN            "SO1_2ZyDcAl*******************"
#define BLYNK_TEMPLATE_ID "TMP*********"
#define BLYNK_DEVICE_NAME "SI***********"
#define BLYNK_AUTH_TOKEN "n6lNJ********************"



// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;
// Your WiFi credentials.
// Set password to "" for open networks.
//char ssid[] = "TP-LINK_GP";
char ssid[] = "TP-LINK@GP";
char pass[] = "7************";

bool alarm_mode = false ; 
bool sensorf = false  ;
//int alarm_led = 9;
int sensor = 5;  //GPIO Pin number on which sensor is connected
int sensor_1 = 13;  //GPIO Pin number on which sensor is connected
int buzzer = 15; //GPIO Pin number on which buzzer is connecte
int pir_sensor = 14; //GPIO Pin number on which sensor is connected
int pir_sensor1 = 16; //GPIO Pin number on which sensor is connected
int pir_sensor2 = 12; //GPIO Pin number on which sensor is connected
int pir_sensor3 = 10;
int pin_onoff = 4;

BlynkTimer timer;

void myTimerEvent(){
   
    if(digitalRead(sensor) == 0){
    Blynk.virtualWrite(V0, "ΣΕΙΡΗΝΑ ΑΝΕΝΕΡΓΗ");}

    if(digitalRead(sensor_1) == 1){
    Blynk.virtualWrite(V2, "ΣΥΣΤΗΜΑ ΟΠΛΙΣΜΕΝΟ");}

   if(digitalRead(pir_sensor1) == 0){
    Blynk.virtualWrite(V3, "CLOSE");}

    if(digitalRead(pir_sensor2) == 0){
    Blynk.virtualWrite(V4, "CLOSE");}

   if(digitalRead(pir_sensor) == 0){
    Blynk.virtualWrite(V5, "CLOSE");}

   if(digitalRead(pir_sensor3) == 0){
    Blynk.virtualWrite(V6, "CLOSE");}
   
  
  if(digitalRead(sensor) == 1){
    Blynk.virtualWrite(V0, "ΣΕΙΡΗΝΑ ΕΝΕΡΓΗ");
    if(alarm_mode == true){
     Blynk.notify("ΠΡΟΣΟΧΗ!!! Η ΣΕΙΡΗΝΑ ΧΤΥΠΑ"); 
     digitalWrite(buzzer, HIGH); 
     }
     }       
      if(digitalRead(sensor_1) == 0){
    Blynk.virtualWrite(V2, "ΣΥΣΤΗΜΑ ΑΦΟΠΛΙΣΜΕΝΟ");
    if(alarm_mode == true){
      Blynk.notify("ΠΡΟΣΟΧΗ!!! ΤΟ ΣΥΣΤΗΜΑ ΕΙΝΑΙ ΑΦΟΠΛΙΣΜΕΝΟ");
      digitalWrite(buzzer,HIGH);
    }
    }

        if(digitalRead(pir_sensor1) == 1){
    Blynk.virtualWrite(V3, "OPEN");
    if(alarm_mode == true && sensorf == false){
      Blynk.notify("ALERT,radar apothikh is open,Alarm Mode ON");
      digitalWrite(buzzer,HIGH);
    }
    }

    if(digitalRead(pir_sensor3) == 1){
    Blynk.virtualWrite(V6, "OPEN");
    if(alarm_mode == true && sensorf == false){
     Blynk.notify("ALERT,RADAR KREBATOKAMARA IS OPEN,ALARM MODE ON");
     digitalWrite(buzzer,HIGH);
     }
     }   
    
       if(digitalRead(pir_sensor2) == 1){
   Blynk.virtualWrite(V4, "OPEN");
   if(alarm_mode == true && sensorf == false){
    Blynk.notify("ALERT,radar paidiko is open,Alarm Mode ON");
      digitalWrite(buzzer,HIGH);
    }
    }

       if(digitalRead(pir_sensor) == 1){
    Blynk.virtualWrite(V5, "OPEN");
    if(alarm_mode == true && sensorf == false){
      Blynk.notify("ALERT,radar saloni is open,Alarm Mode ON");
      digitalWrite(buzzer,HIGH);
    }
  }
  }

 BLYNK_WRITE(V1) {
  switch (param.asInt()) {
    case 1: { // Item 1
      Serial.println("Item 1 selected");
      alarm_mode = true;
    sensorf = false;
  //digitalWrite(alarm_led, HIGH); 
      break;
    }
    case 4: { // Item 4
      Serial.println("Item 4 selected");
      alarm_mode = true;
      sensorf =true;
      digitalWrite(sensor, HIGH); 
    //digitalWrite(alarm_led, LOW); 
      break;
    }
    case 2: { // Item 2
      Serial.println("Item 2 selected");
      alarm_mode = false;
    sensorf = false;
   digitalWrite(buzzer, LOW);
     // digitalWrite(alarm_led, LOW);  
      break;
    }
    case 3: { // Item 3
      Serial.println("Item 3 selected");
      alarm_mode = false;
    sensorf = false;
    digitalWrite(buzzer, HIGH);  
     // digitalWrite(alarm_led, LOW);  
      break;
    }    
    //case 5: { // Item 5
     // Serial.println("Item 5 selected");
      //alarm_mode = false;
     //sensorf = false;
     //digitalWrite(4,HIGH);
    //digitalWrite(pin_onoff, HIGH);  // δοκιμασε το και αναποδα
    //delay(200);
    //digitalWrite(pin_onoff, LOW);
    //pinMode(pin_onoff,OUTPUT);  
      //break;
         
 }
}
 BLYNK_CONNECTED(){ 
 Blynk.syncAll();
}

void setup()
{
  pinMode(sensor,INPUT_PULLUP);
  pinMode(buzzer,OUTPUT);
 // pinMode(alarm_led,INPUT_PULLUP);
  pinMode(pir_sensor,INPUT_PULLUP);
  pinMode(sensor_1,INPUT_PULLUP);
  pinMode(pir_sensor1,INPUT_PULLUP);
  pinMode(pir_sensor2,INPUT_PULLUP);
  pinMode(pir_sensor3,INPUT_PULLUP);
  pinMode(pin_onoff,OUTPUT);
  digitalWrite(4,LOW);

  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  
  // Setup a function to be called every second
  timer.setInterval(1000L, myTimerEvent);
  //timer.setInterval(500L, myTimerEvent);
 
}
void loop()
{
  Blynk.run();
  timer.run(); // Initiates BlynkTimer
}

with the previous version, I had notifications on my phone normally,
now i can’t make it.
I want to have notifications about the following
(“ΠΡΟΣΟΧΗ!!! ΤΟ ΣΥΣΤΗΜΑ ΕΙΝΑΙ ΑΦΟΠΛΙΣΜΕΝΟ”)
and
ΠΡΟΣΟΧΗ!!! Η ΣΕΙΡΗΝΑ ΧΤΥΠΑ
I have created an account,tamplate,event,datastreams and automations

You don’t use Blynk.notify in Blynk IoT, you use Events with Notifications enabled instead.

You should read this…

Pete.

Thanks for the prompt reply.
I followed the link you sent me but I have some questions.
I created an event for arming the alarm, when it is disabled, I passed the event code to the corresponding position in the sketch, I changed the path from blink notify to blink log event, then I created aytomation, I managed to have a notification on my mobile, but I get the same notification when it is activated and when it is deactivated.
what am I doing wrong?

Your help is valuable

My guide wasn’t intended to be used with Automations, and that’s something I’ve not tried, so I can’t help I’m afraid.

Pete.

1 Like

Thanks, I’ll try and I hope to find a solution sometime