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

Feedback if Blynk.notify has sent to server

Hi!

I´m quite new to Blynk and it works great so far. But in some cases i would need a feedback from Server, if my board has succesfully sent data to the server.

In my project i don´t use the void loop, as my controller sleeps the most time and only wakes up to sync data with the server. That’s working fine. I have created a connection routine that ensures all pins i need and the RTC are syncronised to the server like:

Stay as long in BLYNK_CONNECTED untill everything is syncronised…

BLYNK_CONNECTED()
{  int timeouttime =millis();
Serial.println("getting Server time..");  
rtc.begin();
while(year() == 1970)
{
Blynk.run();
if(millis()>(timeouttime+5000))
{
    Serial.println("Timeout time sync go to sleep..");
    ESP.deepSleep(15*6e7);
    delay(100);
 }
}

Serial.println("Server IOs sync.."); 
syncIO(flag_PinV5SyncOK, V5);

}

function to sync IOs:

void syncIO(int &flag, int pin)
{
int timeouttime =millis();
Blynk.syncVirtual(pin);
while(flag != 1)
{  
 Blynk.run();
 if(millis()>(timeouttime+5000))
 {
      Serial.print("Sync Pin V");
      Serial.print(pin);
      Serial.println(" timeout");
      ESP.deepSleep(10*6e7);
      delay(100);
 }
} 
Serial.print("Sync Pin V");
Serial.print(pin);
Serial.println(" OK");
} 

Add flag for every BLYNK_WRITE to know if BLYNK was there:

BLYNK_WRITE(V5)
 {
 flag_PinV5SyncOK = 1;
 KeepAwake = param.asInt();
 }

It´s more a workaround but it’s working. Now i want to send diagnostic messages as push notification. But when i’m calling Blynk.notify("") right before the next sleep, it happens that the controller goes to sleep without sending. I used a 5s time loop with Blynk.run() after Blynk.notify and it works, but that´s not a good practice as i cannot be sure that the diagnostic message is really sent before sleep…

What i’m looking for is something like a ping from the server, so that i can run Blynk.run() for serveral answers from the server and then go to sleep… I already found out that it`s important to run Blynk.run() at least every 10s because otherwise Heartbeat will disconnect the Server… Is there a way to use BLYNK_HEARTBEAT?

best regards

Do you have a lot of data that you need to pull back from the Blynk server each time your device wakes? If so then maybe this is the wrong approach and you should be using SPIFFS or FS instead?

Is there a reason why you need your device to know the current date/time?

You could extend the heartbeat time, but I don’t think that would help, as you need Blynk.run to be executed to perform most data exchange tasks.

As far as getting feedback from the server that Blynk.notify has been received is concerned, there isn’t really any mechanism for this. If you enable debugging then you would get a message back, but you’d need to parse the serial data and that gets messy - especially if the aim is to have a ‘lean and mean’ wake-up and do some stuff then go back to sleep approach.

There are alternatives such a Pushover that send an acknowledgement back to the host to say that a notification has been received and queued, but I’m not convinced that notifications are necessarily the most appropriate solution here.

Pete.

Hi,

Do you have a lot of data that you need to pull back from the Blynk server each time your device wakes? If so then maybe this is the wrong approach and you should be using SPIFFS or FS instead?

Is there a reason why you need your device to know the current date/time?

no it’s not much and not every time it wakes up…
Its only a Button which tells the device to stay alive next time it starts with connection (or HardReset), In this case the void loop is entered until the Button wents false again.

And the Sheduled time and Date is submitted. And therefore i need the RTC to calculate how long the controller should sleep. If its more than 1 hour it wakes up without wifi and goes to sleep for one hour again, for this i use a counter and some variables which are written into the RTC memory…

There are alternatives such a Pushover that send an acknowledgement back to the host to say that a notification has been received and queued, but I’m not convinced that notifications are necessarily the most appropriate solution here

Yes an acknowledge would be perfect, do you have any suggestions how to realize that ?

best regards