Void virtualWrite -> boolean virtualWrite, time for a change?

Just a quick update, before I left for work I changed my sendLog function to use
terminal.println(text)

instead of the method

Blynk.virtualWrite(terminalPin, text)

This just to see if it would remedy anything.

OK that’s much clearer so it’s missing a whole “wake” sequence of writing to Terminal.

Have you now added the disconnect as suggested by @vshymanskyy ?

I think the only way to debug this is to provide the smallest sketch possible that exhibits the problem.

Presumably with associated flush() directly after.

Yes, before going to sleep

Blynk.run();
Blynk.disconnect();
  
delay(200);  
// ESP sleep ~5% off on accuracy, adding 2.5% (testing) on long sleeps
ESP.deepSleep(sleepTime * ((!doorBoot || sleepTime < 10 * 60e6) ? 1.00 : 1.025));
delay(1000);  

Yes

void logSend()
{
  //Blynk.virtualWrite(vPin_terminal, logEvents);
  terminal.println(logEvents);
  terminal.flush();
  logEvents ="";
}

I notice in your old code you have flush() but AFAIK it has no effect with virtualWrite().

Do you think you need the Blynk.run(); before the disconnect() and deepSleep() ?

Yep, added flush as an atempt to remedy, no clue as to its effect (did it help or not), was broken before :slight_smile:

In regards to the .run, as I do not understand the inner workings of the .run and the .disconnect functions I do not know if I need it, thought that it could’nt hurt atleast.
Having it there and the error still persisting tells me that it’s not needed in the sense that it does not help :slight_smile:

Use flush() with terminal.print(), remove Blynk.run() but keep disconnect().

See how you go. If still buggy provide minimal reproducible sketch.

I shall try it :slight_smile: Thanks. I’ll get back to you in a couple of hours

Atm I’m testing only the change in Blynk.virtualWrite -> terminal.println

6 full cycles so far, no miss :slight_smile: 15 min between cycles,
If I dont get any misses untill 12 o’clock then it might just be that the above change fixed everything.
If I hit a miss, i’ll implement your change right away (altough I will do it even if no miss occurs since I do not want redundant code)

@vshymanskyy should a Blynk.virtualWrite() be actioned immediately or is it associated with the next Blynk.run() cycle?

Didn’t take long for errors to occur :slight_smile: In hopes of understanding where things go wrong I added a labeled widget
and to it I’m writing the same text as in terminal in regards to “the next wake-up time”. Check the image

So atm my GoToSleep function looks like this

void GoToSleep()
{   
  if (!doorBoot) // Woken on door open, shoud sleep short, recheck lock
  {
    sleepTime = getShortSleepTime();
  }
  else  
    sleepTime = getLongSleepTime();

  logSave("Sleeping until: " + getTimeFromNow(sleepTime));
  logSend();
  sendNotify();  // Notify user of states 

  Blynk.virtualWrite(vPin_targetSleepTime, getTimeFromNow(sleepTime)); 
  Blynk.run();
  Blynk.disconnect();
  
  delay(200);  
  // ESP sleep ~5% off on accuracy, adding 2.5% (testing) on long sleeps
  ESP.deepSleep(sleepTime * ((sleepTime < sleepTimeCorrect * 60e6) ? 1.00 : 1.025));
  delay(1000);  
}

Next wake-up I’ll OTA Update my device to remove the .Run just to see if it does anything.
This really does not seeem like a specific terminal issue anymore so much as a communications issue between hardware and server …

Another strange Issue, I have been monitoring V20, my terminal virtual pin, via HTTP api just to see if my server gets SOMETHING when NOTHING is update APPSIDE.

I just pulled V20 only to get this information

["
---------------- 06:44:59 ----------------
Wake Reason: Timer
Chip RstReason: Deep-Sleep Wake
Battery voltage: 0.04
Battery raw: 9.00
Sleep time: 15 minutes
Recheck time: 30 seconds
Voltage factor (977): 0.977
Temperature: 22.00 °C
Door is closed
Door is unlocked
WiFi signal at 47 %
Sleeping until: 07:00:00
"]

Since 07:00 i have had at minimum 8 write cycles, so it seems that somehow the information on the server was looped back to an older read?

The latest print in my widget terminal is
a read @ ~09:30

Maybe you are seeing the oldest part of the Terminal log.

Cant be, I’ve made a few posts to terminal since my last message yet V20 still displays the previously mentioned text. There is something really fishy going on

Going to try an older server v.

The oldest part of the log is exactly that, not the new stuff you are adding to it.

That does not make any sense, If it is the oldest part and I add new parts then the oldest should change to the second oldest and so on since there is a limit to terminal history storage no? And I have posted shit-tons of information over the couple of days so the pool is full, and should then behave like below with 5 symbolizing the oldest and 1 newest:

5. oldest                                5. second oldest
4. second oldest       (new post)        4. Post
3. post                ------->          3. Post
2. post                                  2. newest post
1. newest post                           1. A newer post

You are right but maybe you haven’t reached the limit yet so oldest is oldest.

@Dmitriy, @vshymanskyy Do you have any way of debugging communication between HW and server?
All I can tell atm with Blynk debug and Blynk.log is that my HW has connected and that the device performed a virtualWrite.

But is there any way I can tell what happend on server side, did it receive those writes and just ignore them?
It’s like everything works but my communication (virtualWrites) to server sometimes is just skipped

If anyone has the time to read for possible errors the full code is in the .rar provided here
http://s000.tinyupload.com/index.php?file_id=51042876112464934325

It is split up in 7 tabs hence why I havn’t posted it all here

Safe to say this is not the case
my #number of strings to store in terminal widget is set to 25

terminal.strings.pool.size=25

I just spammed a blynk get update with the http API just writing “Test” to terminal, while doing this watching my terminal grow with “Test” prints
https://***********…/update/V20?value=%0ATest

25+ times :slight_smile:
https://*************/get/V20

still returns

["
---------------- 06:44:59 ----------------
Wake Reason: Timer
Chip RstReason: Deep-Sleep Wake
Battery voltage: 0.04
Battery raw: 9.00
Sleep time: 15 minutes
Recheck time: 30 seconds
Voltage factor (977): 0.977
Temperature: 22.00 °C
Door is closed
Door is unlocked
WiFi signal at 47 %
Sleeping until: 07:00:00
"]

If i tried another virtualPin like say V17 where I had a labeled widget, the widget updated with the word “test” and the get function returned the word

[""Test""]`

All in all I somehow broke terminal… will try later to recreate project from scratch, maybe going back from device tiles borked it somehow…

I thought you were using Blynk’s server, no?

Nono local server :slight_smile:
as visible in the serial monitor
Doubt it makes any difference though


Connecting to 192.168.1.3:8442
Ready (ping: 3ms).
Free RAM: 37144
Time sync: OK