virtualWrite hangs for 2+ minutes

I’m setting a virtual pin every three seconds, and it works fine for several minutes, but then it will hang during one of the pin writes that previously worked. I’m assuming it’s waiting for some kind of response back from the Blynk server, but not getting it.

Here’s the debug, as you can see the whole program hangs for 2.5 min while it waits for this virtualpin write to complete. Is there any way to more quickly move on from this pin write failure?

Current time: 12:34:24 8 8 2017
[566407] >[00|00|01|00|C8]
[566407] Ready (ping: 571ms).
[566408] <[11|00|03|00]aver[00]0.4.8[00]h-beat[00]60[00]buff-in[00]256[00]dev[00]Arduino[00]cpu[00]ATmega328P[00]con[00]SIM800[00]build[00]Aug  8 2017 12:24:25[00]
Virtual write is about to happen
Door is open
[566947] <[14|00|04|00|09]vw[00]2[00]Open
[714880] Cmd error
Virtual write complete. <---- Ignore this string that I added to my function.
[715016] Cmd skipped:17
Current time: 12:36:53 8 8 2017

Here is the code:

void sendDoorStatus() {
    Serial.println("Virtual write is about to happen");
    if (digitalRead(doorSensor)) {
        Serial.println("Door is open");
        Blynk.virtualWrite(V2, "Open");
    } else {
        Blynk.virtualWrite(V2, "Closed");
        Serial.println("Door is closed");
    }
    Serial.println("Virtual write complete.");
}

void setup() {
    // Set Relay pin
    digitalWrite(doorRelay, HIGH); // Door relay is activated when LOW, so set to HIGH before enabling output.
    pinMode(doorRelay, OUTPUT);

    // Set door sensor pin
    pinMode(doorSensor, INPUT_PULLUP);

    // Debug console
    Serial.begin(9600);
    delay(10);

    // Set GSM module baud rate
    SerialAT.begin(9600);
    delay(3000);

    // Restart takes quite some time
    // To skip it, call init() instead of restart()
    Serial.println("Initializing modem...");
    modem.restart();

    // Connect to Blynk
    Blynk.begin(auth, modem, apn, user, pass);
    while (Blynk.connect() == false) {}
    setSyncInterval(1);
    Serial.println("Waiting for RTC to sync");
    rtc.begin();
    delay(1000);
    Serial.println("Syncing with Blynk");
    Blynk.syncAll();
    setSyncInterval(3*60);
    // Send door status to app
    timer.setInterval(3000L, sendDoorStatus);
    timer.setInterval(1000L, clockDisplay);
}

void loop() {
    Blynk.run();
    timer.run();
}

You could simply be having communication lag over the cellular connection.

I think I might have been sending too many updates to Blynk. Maybe there’s a notification that I missed, but it would have been nice to get some kind of pop-up in the app or something that says “Hey, slow down. We’re rate limiting your requests because you’re sending too many.”

I changed my function to only transmit when there is a state change on the pin, and I think that’s fixed it. Seems more efficient anyway.

There is this… http://docs.blynk.cc/#troubleshooting-flood-error But your issue may not have applied sufficiently for the error to be generated? Probably just lost to the airwaves without the receiver even knowing it.