Blynk notificaition

Hi, im trying to send a notificaition when my device is connected or disconnected to the server, it works fine with the connected notificaition, but something happens when its disconnected, the code works “correctly” but for some reason, i dont get the notificaition on my cellphone (only for the disconnected notificaition).
Here is that part of the code:

   void CheckConnection(){
  Connected2Blynk = Blynk.connected();
  if(Connected2Blynk){
        Serial.println("Still connected to Blynk server"); 
       if(n==0){
        Blynk.notify(String("Device connected"));
        Serial.print("Device connected");
       }
       n=0;
  }
  else{
    
   Serial.println("Not connected to Blynk server");
    if(n==0){
       Blynk.notify(String("Device disconnected"));
       Serial.print("Device disconnected");
       
    }

   n=1;
    //delay(1000);
    MyWiFi(); 
  }
}

I got the Serial.print for both: Device connected and Device disconnected, but i only got notificaition for device connected.
Any idea of why this is happening?

there is a new app update, which contains a different logic implemented regarding notifications, also some bug fixes. please try it and see if it helps.

also, did you enabled notifications when hw goes offline, in notification widget?

@Rodrigo_Rochin you can’t use Blynk widgets like Blynk.notify() when you are not connected to the server.

1 Like

I will try that.

But then how does the offline notificaition works?
Or is there a way to cutomize the offline notificaition?

yeah, good point. i missed that :slight_smile:

That is between server and app not MCU and server.

2 Likes

the offline notification works from the app notification widget. practically, the server waits 15 seconds to see if the tcp connection is alive or not between the hw and server. you will receive the hw offline notification on the phone with a 15 second delay. but you have to enable here:

2 Likes

But is there a way to cuztomize that notificaition?

Check out BLYNK_APP_CONNECTED(), BLYNK_APP_DISCONNECTED() and the associated slider in the app.

You can customise your own notifications but not the system disconnect notifications.

1 Like

I will check that, thanks.