Blynk re-connect on repeated button widget presses

Hi All,

I just have strange behaviour on my code, so just want to know if this issue is from my code or Blynk platform.

I have a piece of code in my project like below and when I press the button widget in the application repeatedly for about 5+ times the entire project goes blank and restarts (like pressing the reset button in Arduino).

// When pushed from app make it HIGH/LOW.
BLYNK_WRITE(vOnOffPin) {
  relayState = param.asInt();
  digitalWrite(relayPin, relayState);

      // For motor status on LCD
      if (relayState == HIGH) {
        lcd.setCursor(16, 0);
        lcd.print("ON ");
      } else {
        lcd.setCursor(16, 0);
        lcd.print("OFF");
      }

      // Update Button Widget
      Blynk.virtualWrite(vOnOffPin, relayState);

      // For motor status fo LED widget
      if (relayState == LOW) {
        vLED.setColor(BLYNK_RED);
      } else {
        vLED.setColor(BLYNK_GREEN);
        Blynk.notify("Well Motor Started");
      }
    }

But the same code when I comment out the following like below the reset is not happening even I press the button widget reputedly.

// When pushed from app make it HIGH/LOW.
BLYNK_WRITE(vOnOffPin) {
  relayState = param.asInt();
  digitalWrite(relayPin, relayState);

  // For motor status on LCD
  if (relayState == HIGH) {
    lcd.setCursor(16, 0);
    lcd.print("ON ");
  } else {
    lcd.setCursor(16, 0);
    lcd.print("OFF");
  }

  // Update Button Widget
//  Blynk.virtualWrite(vOnOffPin, relayState);
//
//  // For motor status for LED widget
//  if (relayState == LOW) {
//    vLED.setColor(BLYNK_RED);
//  } else {
//    vLED.setColor(BLYNK_GREEN);
//    Blynk.notify("Well Motor Started");
//  }
}

My setup is:

  1. Arduino UNO with USB.
  2. Android Version 10
  3. I checked on both Blynk server and local server same issue.
  4. Blynk Library version 0.6.1

Please let me know if I am doing anything wrong.

Thank You So Much!!!

The code you’ve commented-out has three pieces of data that it pushes to the Blynk server…
1x Blynk.virtualWrite
1x Blynk LED widget update
1x Blynk.notify

If you do more than 10 virtualWrites per second then you will flood the server and some of these instructions will be dropped. With the Blynk cloud server there is a limit of one notification every 5 seconds.

However, exceeding these limits should result in hardware crashes. My guess is that there are other issues in the parts of the code that you haven’t shared, or there are hardware issues - maybe such as power supply problems - that could be causing the crashes.

However, the sooner you move away from the serial connection, and preferably from the Uno too, and start using something like the NodeMCU or ESP32 the better.

Pete.

1 Like

Thank you very much for your reply.

I definitely agree with and you have pointed me in the right direction to troubleshoot this issue.

Hope my ESP32 order will be delivered soon and everything goes well with it.

You made my day!! :smiley: