Syncvirtual strange behaviour

Hi all

I have an Arduino UNO, connected to wifi over USB.

Sketch code here: https://github.com/sunrunner4kr-simon/inittracker/tree/main

I’m trying to sync a set of virtual pins in the BLYNK_CONNECTED call, and it just crashes the app.

So i decided to do some testing, and put a single virtual pin sync (V6) in a button widget function.

BLYNK_WRITE(V5)
{
  if (param.asInt() == 1) {
    printValues();
    CURRENT_SEAT = 100;
    NEXT_SEAT = 100;
    clearAll();

    strcpy(player[0].name, "shanko");
    strcpy(player[1].name, "sael");
    strcpy(player[2].name, "kae");
    strcpy(player[3].name, "tree");
    strcpy(player[4].name, "gith");
    strcpy(player[5].name, "otadus");
    strcpy(player[6].name, "monster1");
    strcpy(player[7].name, "monster2");
    strcpy(player[8].name, "monster3");
    strcpy(player[9].name, "monster4");
    strcpy(player[10].name, "owl");
    strcpy(player[11].name, "monster5");

    player[0].value = 0;
    player[1].value = 0;
    player[2].value = 0;
    player[3].value = 0;
    player[4].value = 0;
    player[5].value = 0;
    player[6].value = 0;
    player[7].value = 0;
    player[8].value = 0;
    player[9].value = 0;
    player[10].value = 0;
    player[11].value = 0; 
    Blynk.syncVirtual(V6);
    printValues();
    Blynk.virtualWrite(V30, "resetting");
  }
}

So i’m expecting to see, sent to V30 (my terminal widget):
“0 enabled”

“resetting”

However, when i click this button widget(V5), instead of displaying whatever output I have in the BLYNK_WRITE of V6 (see below), it instead outputs the comment i have in the BLYNK_CONNECTED().

“sync complete”

Which to me, really doesn’t make any sense. It even doesn’t output the virtualWrite to V30 in the button function after the sync command.

BLYNK_WRITE(V6)
{
  int i = param.asInt();
  player[0].enabled = i;
  Blynk.virtualWrite(V30, "0 enabled");
}

https://imgur.com/a/hwnkd8W

Does syncVirtual call BLYNK_CONNECTED somehow??

Thanks for any advice!

Simon

Do you have an FTDI adapter connected to pins 10 & 11 ?

What percentage of the UNO’s memory does this sketch occupy?

Pete.

Sketch uses 19652 bytes (60%) of program storage space. Maximum is 32256 bytes.
Global variables use 1673 bytes (81%) of dynamic memory, leaving 375 bytes for local variables. Maximum is 2048 bytes.
Low memory available, stability problems may occur.

I don’t use an adapter. I just have a pin output to my led strip, and the 5V grounded.

Arduino Uno :joy:

2 Likes

In that case, there is no point in including the SoftwareSerial library and creating the SoftwareSerial port if you’re not using it. This will save on memory.
If you did have an FTDI it may provide some useful information though.

That’s probably what’s causing your issues. I would guess that your UNO is rebooting, which is causing a re-connection and triggering the BLYNK_CONNECTED callback.

You’d be far better using a more capable board, such as a NodeMCU or ESP32, which would give you native WiFi cab ability too.

Pete.

1 Like