Sự kiện "Event notifications" chỉ Pop-up lên điện thoại duy nhất một lần trên Blynk 2.0

As the title says, the problem I’m having is that when I configure “Event notifications”, the alert pops up on my phone only once on Blynk 2.0. After that, the Pop-up was never seen again!
Is there any way I can fix this error? Thank you very much everyone!

(Như tiêu đề, vấn đề tôi gặp phải là khi cấu hình “Event notifications” thì cảnh báo chỉ Pop-up lên điện thoại duy nhất một lần trên Blynk 2.0 . Sau đó không thấy Pop-up lại lần nào nữa!
Có cách nào để mình sửa được lỗi này không ạ? Xin cảm ơn mọi người rất nhiều ạ!)

Have you tried automation ?

1 Like

Incase you didn’t notice, there is a notification limit, according to the picture it’s 1 hour.

1 Like

Sorry, I don’t see it anywhere on my interface! Can you show me how to configure it?

When you create a datastream go to advanced settings and check expose to automation.

1 Like

Thank you so much ! I can fix it now. I like you!


But sometime , I want to use code to make a notifications such as this cmd in ESP code:
Blynk.logEvent( String(“BUTTON”) );
But the alert pops up on my phone only once on Blynk 2.0

This is my code:


// Fill-in information from your Blynk Template here
#define BLYNK_TEMPLATE_ID "TMPLSDH9boHo"
#define BLYNK_DEVICE_NAME "BLYNK NEW 20"

#define BLYNK_FIRMWARE_VERSION        "29.09.21"
#define BLYNK_PRINT Serial

#define APP_DEBUG
#define USE_NODE_MCU_BOARD

#include "BlynkEdgent.h"

#define LEDSTT        2 // Led XANH DƯƠNG trên module ESP-12E

int notification_blynk_new = 0;

void Led(int nchop,int tchop){
  for (int i = 0; i < nchop; i++){
    digitalWrite(LEDSTT, LOW); // LOW = LED SÁNG
    delay(tchop);                            
    digitalWrite(LEDSTT, HIGH); // HIGH = LED KHÔNG SÁNG
    delay(tchop);
  }
}



#define TERMINAL      V3
BLYNK_WRITE(TERMINAL){// NHẬN DỮ LIỆU TỪ TERMINAL BLYNK VÀ IN RA SERIAL
  String i = param.asStr(); 
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  if(i.substring(0, i.indexOf(':')) == "CMD"){
      Serial.println(i); 
      notification_blynk_new = 1;
  }
  else if(i == "Xoatmn"){
      Serial.println(i); 
      notification_blynk_new = 3;
  }
}


int dem_BUTTON = 0;
#define BUTTON        V4
BLYNK_WRITE(BUTTON){// NHẬN DỮ LIỆU TỪ BUTTON BLYNK VÀ IN RA SERIAL SỐ LẦN NHẤN NHẢ
  int pinValue = param.asInt(); 
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  if(pinValue == 0){
      if(dem_BUTTON < 10000){
        dem_BUTTON++;
      }
      Serial.print("DA NHAN ");
      Serial.print(dem_BUTTON);
      Serial.println(" LAN");
      
      notification_blynk_new = 2;
  }
}

void setup()
{
  Serial.begin(9600);
  delay(100);
  
  BlynkEdgent.begin(); 
  
  pinMode(LEDSTT, OUTPUT);
  
  digitalWrite(LEDSTT, HIGH);delay(222); // HIGH = LED KHÔNG SÁNG
  digitalWrite(LEDSTT, LOW);delay(222); // LOW = LED SÁNG
  
  digitalWrite(LEDSTT, HIGH);delay(222); // HIGH = LED KHÔNG SÁNG
  digitalWrite(LEDSTT, LOW);delay(222); // LOW = LED SÁNG
  
  digitalWrite(LEDSTT, HIGH);delay(222); // HIGH = LED KHÔNG SÁNG
  digitalWrite(LEDSTT, LOW);delay(222); // LOW = LED SÁNG
  
  digitalWrite(LEDSTT, HIGH);delay(222); // HIGH = LED KHÔNG SÁNG


}

void loop() {
  
  BlynkEdgent.run();
  
  if(notification_blynk_new == 1){// notification_blynk_new == 1
    Blynk.virtualWrite(TERMINAL,  "ĐÃ NHẬN ĐƯỢC LỆNH TỪ TERMINAL <- OK!\n\n");
    Blynk.logEvent( String("TERMINAL") );
    Led(2,55);  
  }  
  else if(notification_blynk_new == 2){// notification_blynk_new == 2
    Blynk.virtualWrite(TERMINAL,  "ĐÃ NHẬN ĐƯỢC LỆNH TỪ BUTTON <- OK!\n\n");
    Blynk.logEvent( String("BUTTON") );
    Led(2,55);  
  }  
  else if(notification_blynk_new == 3){// notification_blynk_new == 3
    Blynk.virtualWrite(TERMINAL,  "clr");// "clr" = xóa terminal
    Blynk.virtualWrite(TERMINAL,  "ĐÃ NHẬN ĐƯỢC LỆNH XÓA TERMINAL <- OK!\n\n");
    Blynk.logEvent( String("TERMINAL") );
    Led(2,55);  
  }  
  
  notification_blynk_new = 0; 
     
}

int getRSSIasQuality1(void) { // HÀM LẤY GIÁ TRỊ WIFI
  int RSSI1;
  int quality = 0;
  RSSI1 = WiFi.RSSI();
  if (RSSI1 <= -100) {
    quality = 0;
  } else if (RSSI1 >= -50) {
    quality = 100;
  } else {
    quality = 2 * (RSSI1 + 100);
  }
  return quality;
}

extern BlynkTimer timer; // KHAI BÁO DÙNG TIMER BLYNK
BLYNK_CONNECTED() {// KHI BLYNK ĐƯỢC KẾT NỐI THÌ TẠO 1 TIMER TÊN LÀ myTimerEvent NGẮT 2000 (ms)
  timer.setInterval(2000L, myTimerEvent);
}

String NAME_OF_WIFI;
int dem = 0;
bool led_value = 0;

#define SHOW_WIFI     V0
#define SHOW_COUNT    V1
#define SHOW_LED      V2

void myTimerEvent(){
// TRONG HÀM NGẮT TIMER THÌ TA GET TÊN WIFI VÀ GIÁ TRỊ WIFI
  NAME_OF_WIFI = WiFi.SSID(); 
  NAME_OF_WIFI.trim();
  int quality = getRSSIasQuality1();
  String WF;
  WF = NAME_OF_WIFI;
  WF +=  " (";
  WF += String(quality);
  WF +=  "%)";
  
// TRONG HÀM NGẮT TIMER THÌ TA TĂNG BIẾN dem LÊN 1
  if(dem < 100)
  dem++;
  else
  dem = 0;
  
// TRONG HÀM NGẮT TIMER THÌ TA ĐẢO BIẾN bool led_value
  if(led_value == 0)
  led_value = 1;
  else
  led_value = 0;

 // TRONG HÀM NGẮT TIMER THÌ TA DÙNG HÀM Blynk.virtualWrite ĐỂ GHI GIÁ TRỊ LÊN BLYNK
  Blynk.virtualWrite(SHOW_WIFI, WF);  
  Blynk.virtualWrite(SHOW_COUNT, "COUNTER = " + String(dem)); 
  Blynk.virtualWrite(SHOW_LED, led_value); 

}


First please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:```

Second you should keep your void loop clean as possible.

Third as I mentioned there’s notification limit.

Greetings.

1 Like

Yes sir, In my void loop has some code.
And maybe i will have check

if (Serial.available()) {
// check data and control here
}

in my void loop, too.
So where do you think I should put them?

Anywhere out side the loop.

1 Like

I think you should start with a simple sketch.

1 Like

Yes sir, I will try it soon! Thank you!

1 Like

Your welcome bro.

1 Like