Hw resets on multiple "Blynk.setProperty" commands

hello!

i observed some strange behaviour: when using multiple “Blynk.setProperty” commands my esp8266 resets. this is the relevant code:

BLYNK_WRITE(V_TERMINAL)                  // update unit name
{
  unitName = param.asStr();

  if (updateName()) {
    terminal.print("unit name set to ");
    terminal.write(param.getBuffer(), param.getLength());
    terminal.println();
    terminal.flush();

    //Blynk.setProperty(V_RELAY_1_STATE, "color", BLYNK_GREEN);

    Blynk.setProperty(V_RELAY_1_STATE, "label", unitName + " RLY 1");
    Blynk.setProperty(V_RELAY_2_STATE, "label", unitName + " RLY 2");
    Blynk.setProperty(V_RELAY_3_STATE, "label", unitName + " RLY 3");
    Blynk.setProperty(V_RELAY_4_STATE, "label", unitName + " RLY 4");
    Blynk.setProperty(V_MOTION_LED,    "label", unitName + " LED");
    Blynk.setProperty(V_MOTION_STATE,  "label", unitName + " ALARM");
    Blynk.setProperty(V_MESSAGE,       "label", unitName + " NFO");
    Blynk.setProperty(V_RESTART_CAUSE, "label", unitName + " LR");
    Blynk.setProperty(V_SEND_RTC,      "label", unitName + " RTC");
  }
  else {
    terminal.println("ERROR: name length mismatch!");
    terminal.flush();
  }
}

if i use only 4-5 Blynk.setProperty lines, it works perfectly. if i use above ~ 7, it resets the hw. what could be the problem?

  • it takes extremely long time to execute this code and the esp watchdog resets?
  • there is a hardcoded max limit on these consecutive commands?
  • should i call blynk.run() and / or delay(1) or yield() between these lines?

thanks!

I found it to always be a problem and extremely prone to crash my esp. I also find blynk.syncall to suffer same issues - its very unreliable escpecially when many virtual pins used. My only workaround is to include a specially blynk_delay function which pauses between calls but ensures blynk.run is executed and yield.

1 Like

thanks for the info.
do you mean by prone to carsh even for a single set property call, or only for several?

up to now i never used this function, so i do not have any experience with it.

This would be my best guess.

Try yield() efter every 4 updates?

    Blynk.setProperty(V_RELAY_1_STATE, "label", unitName + " RLY 1");
    Blynk.setProperty(V_RELAY_2_STATE, "label", unitName + " RLY 2");
    Blynk.setProperty(V_RELAY_3_STATE, "label", unitName + " RLY 3");
    Blynk.setProperty(V_RELAY_4_STATE, "label", unitName + " RLY 4");
    yield();
    Blynk.setProperty(V_MOTION_LED,    "label", unitName + " LED");
    Blynk.setProperty(V_MOTION_STATE,  "label", unitName + " ALARM");
    Blynk.setProperty(V_MESSAGE,       "label", unitName + " NFO");
    yield();
    Blynk.setProperty(V_RESTART_CAUSE, "label", unitName + " LR");
    Blynk.setProperty(V_SEND_RTC,      "label", unitName + " RTC");
1 Like

this will be my next step. right now i’m taking a break for some hours.

i wonder if i should also include a blynk.run, or only yield? if should i use both, what is the best order?

Blynk.run I think has a heartbeat timeout of 10 seconds? I doubt it’s needed, but if you do,
Worst case scenario is that half your widgets get updated before the rest :stuck_out_tongue:

And about the order I’d definitely do yield before .Blynk.run

thanks for the tip.
when i go back to my pc i will do some tests and will report.

1 Like

any idea how can i also edit the device name from hw (or api)? it would be very important for my project, but didn’t find any solution yet :frowning:

i mean this:

Sorry I have no clue :neutral_face:

This is the solution I use but I don’t bother with any calls to Blynk.run().

I consider it a general theme not just for syncAll and setProperty. What I suspect might be happening is it triggers a flood. So even though the allowance is 100 commands per second it depends how this is calculated. It’s not likely to wait 30s and then say hey you sent too many commands. So perhaps the check is in ms / ns and 10 consecutive lines of code with setProperty, virtualWrite etc will be over the allowed 100 per second.

If this is the case perhaps every Blynk command just needs a minor delay within the library.

Any thoughts @Dmitriy ?

i do not think so @Costas , because on flood error you’re just got the mcu disconnected from blynk server, not reset. but my esp gets resetted every time i execute the above code.

this is why i beleive there is some esp watchdog reset, because of the too long wifi management timeout. and calling delay on an esp, actually enables the mcu to do some wifi housekeeping. i learned that calling delay(1) is actually like calling yieald()

The WDT will kick in after about 2.6s but it shouldn’t take anywhere that amount of time to do a few setProperty calls. What data type is unitName and have you tried the following format:

Blynk.setProperty(V_RELAY_1_STATE, "label", String(unitName + " RLY 1"));

unitName is String, min 1 max 49 characters. but usually around 10 characters.

see here

I think this happens because this commands are too much for ESP. @vshymanskyy should know better. I don’t think this is something Blynk library specific. But who knows.

do you think that using yield() after every 3-4 command should prevent the reset?

or what is a correct practice?

Yeap, small delays usually help.

thanks. i will try that soon.
if you think this is not lib specific, than i edit category.

In regards to this question I have found a possible albeit not instant solution.

IF you are running local server, read on, if not, sooorrryyyyyyyy ;D

User data files could be manipulated to change device names knownig their ID or just their current name
one could search and replace old for new (provided all are unique names).
I just tried on local to manually edit my own user data file and change the name of an device and it worked but a bit wonky.

The change did not take effect untill i restarted the server then it was visible in my phone.
A way for you do do this is on PC
write a batch -file/script that polls blynk http api with curl or something of the sorts to get information IF the pc should rewrite user data.
Then just have it force a server restart aswell.

perhaps via terminal write:
DeviceRename fromName toName

and your script keeps polling the virtual pin of terminal unitll it sees
that the first 12 characters are DeviceRename,
executes the rename, changes the virtual pin value, and goes back to polling :stuck_out_tongue:

1 Like

@wanek with 9 value display widgets this code runs fine when sending 52 characters (alphabet twice), takes a second to update the 9 displays, no resets etc. Data is sent to a cloud server. All displays set to PUSH frequency.

int updateName = 1;

BLYNK_WRITE(V7)                  // update unit name with Terminal
{
  String unitName = param.asStr();

  if (updateName == 1) {
    /*
    terminal.print("Unit name set to ");
    terminal.write(param.getBuffer(), param.getLength());
    terminal.println();
    terminal.flush();
    */
    Blynk.virtualWrite(V7, "Unit name set to " + unitName + "\n");

    //Blynk.setProperty(V_RELAY_1_STATE, "color", BLYNK_GREEN);

    Blynk.setProperty(V8, "label", unitName + " RLY 1");
    Blynk.setProperty(V9, "label", unitName + " RLY 2");
    Blynk.setProperty(V10, "label", unitName + " RLY 3");
    Blynk.setProperty(V13, "label", unitName + " RLY 4");
    Blynk.setProperty(V14,  "label", unitName + " LED");
    Blynk.setProperty(V15, "label", unitName + " ALARM");
    Blynk.setProperty(V16, "label", unitName + " NFO");
    Blynk.setProperty(V17, "label", unitName + " LR");
    Blynk.setProperty(V18,  "label", unitName + " RTC");
  }
  else {
    //terminal.println("ERROR: name length mismatch!");
    //terminal.flush();
  }
}