Connection Management RTC and Sync

@Dmitriy if you look at the Serial Monitor and associated sketch at the start of this thread you will see that we connect, disconnect and reconnect several times over a 30 second interval. This is not the way the actual system works but it is more to highlight our problem. So the first connection gives RTC data but none of the subsequent connections.

Thinking about this it is probably the 5 / 10 minute standard interval that is set with RTC. We expect our systems to sleep for 10 minutes (maybe 5) so it might not be a problem, but when we are testing we set the sleep period very short (30 seconds sometimes) as we don’t want to wait 5 or 10 minutes to see if our latest sketch changes are working.

On second thoughts this can’t be the problem as the 1000+ connections with the standard RTC sketch we made the night before last were at 20 second intervals (with a short deepsleep included within the 20 seconds).

A sample of the 8000+ lines of Serial Monitor data for the 1000+ succesful RTC requests are shown below:

[15661] Current time: 22:42:39 29 03 2016 
Connecting to GargoyleTest
[1244] Connected to WiFi
[1244] My IP: 192.168.10.226
[1245] Blynk v0.3.4
[5001] Connecting to blynk-cloud.com:8442
[5311] Ready (ping: 1ms).
[5623] Time sync: OK
[15905] Current time: 22:43:05 29 03 2016
Connecting to GargoyleTest
[1252] Connected to WiFi
[1252] My IP: 192.168.10.226
[1252] Blynk v0.3.4
[5001] Connecting to blynk-cloud.com:8442
[5344] Ready (ping: 3ms).
[5680] Time sync: OK
[15680] Current time: 22:43:32 29 03 2016
Connecting to GargoyleTest
[1250] Connected to WiFi
[1250] My IP: 192.168.10.226
[1250] Blynk v0.3.4
[5001] Connecting to blynk-cloud.com:8442
[5309] Ready (ping: 0ms).
[5638] Time sync: OK
[15638] Current time: 22:43:59 29 03 2016
Connecting to GargoyleTest
[1247] Connected to WiFi
[1247] My IP: 192.168.10.226
[1247] Blynk v0.3.4
[5001] Connecting to blynk-cloud.com:8442
[5385] Ready (ping: 1ms).
[5743] Time sync: OK
[15742] Current time: 22:44:32 29 03 2016

Hi Costas,

I cut and paste your code but I am unable to get real time. See results

347644] Connecting to blynk-cloud.com:8442
[348270] Ready (ping: 1ms).
Should be connected to Blynk now
[349885] Current time: 00:05:49 01 01 1970
[349886] Disconnected
[357644] Connecting to blynk-cloud.com:8442
[358308] Ready (ping: 1ms).
Should be connected to Blynk now
[359920] Current time: 00:05:59 01 01 1970
[359921] Disconnected
[367644] Connecting to blynk-cloud.com:8442
[368238] Ready (ping: 0ms).
Should be connected to Blynk now
[369814] Current time: 00:06:09 01 01 1970
[369815] Disconnected

Please advise…

Regards
Les

@Badge RTC widget changed a few weeks ago. Look at the new example provided by Blynk and see how you go.

All Blynkers, I will repeat something I wrote on this site yesterday.

“Treat any Blynk sketch older than 1 month with caution as it is an ever changing environment.”

I did use the example widget code provided and got the same results. I did get some notification on a few odd occasions that I was sync’ed but this is no longer the case and at the time I was not probing the RTC time so I have no idea that it was working.

What I do find strange is that the Timer Widget works at the prescribed time and works beautifully. I don’t know where it is getting the real time from?

@Badge Les the Timer widget works independently of the RTC widget.

When you set the Timer the ON / OFF times you requested are stored on the server and then the signal sent to your hardware at the allocated times.

Post a minimal sketch of what you ahve if you are still having problems.

I will test further.
Maybe the TimerInput Widget should work on a similat format in the SimpleTimerInput rather than sending the current message…

OK I ran the exact example RTC from Blynk Lib (I only added access code) this is my result

[2245] Blynk v0.3.10 on NodeMCU
[5001] Connecting to blynk-cloud.com:8442
[5554] Ready (ping: 0ms).
Current time: 0:0:16 1 1 1970
Current time: 0:0:26 1 1 1970
Current time: 0:0:36 1 1 1970
Current time: 0:0:46 1 1 1970
Current time: 0:0:56 1 1 1970

Sketch below

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <TimeLib.h>
#include <WidgetRTC.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).

char auth[] = "xxx";
char ssid[] = "xxx";
char pass[] = "xxxx";
SimpleTimer timer;

WidgetRTC rtc;

BLYNK_ATTACH_WIDGET(rtc, V5);

// Utility function for digital clock display: prints preceding colon and leading 0
void printDigits(int digits)
{
  Serial.print(":");
  if (digits < 10) {
    Serial.print('0');
  }
  Serial.print(digits);
}

// Digital clock display of the time
void clockDisplay()
{
  // You can call hour(), minute(), ... at any time
  // Please see Time library examples for details

  String currentTime = String(hour()) + ":" + minute() + ":" + second();
  String currentDate = String(day()) + " " + month() + " " + year();
  Serial.print("Current time: ");
  Serial.print(currentTime);
  Serial.print(" ");
  Serial.print(currentDate);
  Serial.println();

  // Send time to the App
  Blynk.virtualWrite(V1, currentTime);
  // Send date to the App
  Blynk.virtualWrite(V2, currentDate);
}

void setup()
{
  Serial.begin(9600); // See the connection status in Serial Monitor
 Blynk.begin(auth, ssid, pass);

  while (Blynk.connect() == false) {
    // Wait until connected
  }

  // Begin synchronizing time
  rtc.begin();

  // Other Time library functions can be used, like:
  //   timeStatus(), setSyncInterval(interval)...
  // Read more: http://www.pjrc.com/teensy/td_libs_Time.html

  // Display digital clock every 10 seconds
  timer.setInterval(10000L, clockDisplay);
}

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

This was a pre war version. Manually install 0.4.4.

Updated still a problem

[2748]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
/
//_, /////_
/
__/ v0.4.3 on NodeMCU

[5001] Connecting to blynk-cloud.com:8442
[5952] Ready (ping: 0ms).
[10952] Connecting to blynk-cloud.com:8442
[11582] Ready (ping: 1ms).
Current time: 0:0:22 1 1 1970
Current time: 0:0:32 1 1 1970

I see you say 4.4
but this is what I get

0.4.4 has the new RTC widget, not 0.4.3.

I downloaded 0.4.4 zip file and replaced Lib and Tool files but still get the same result 0.4.3!
Please advise

[1749]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
/
//_, /////_
/
__/ v0.4.3 on NodeMCU

Close the IDE.
Cut and paste 0.4.3 libraries (all 6 of them) to somewhere for safe keeping. Don’t try to drag them anywhere.
Then delete 6 old libraries.
Paste in the 6 new libraries.
Reopen IDE and reflash your device.

That’s exactly what I did! Tried several times…

Paste IDE compiler output.
Does it say you have multiple libraries for the same thing?

OK finally got things working! V0.4.4 installed

5610]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
/
//_, /////_
/
__/ v0.4.4 on NodeMCU

[5680] Connecting to blynk-cloud.com:8442
[7452] Ready (ping: 1ms).
[12453] Connecting to blynk-cloud.com:8442
[12994] Ready (ping: 1ms).
[13535] Time sync: OK
Current time: 9:55:51 2 2 2017
Current time: 9:55:56 2 2 2017

The initial problem stemmed from http://www.blynk.io/demo/ maybe update the document

SETTING UP ARDUINO IDE
Install latest Arduino IDE.
Download latest Blynk release package: Blynk_Release_v0.3.10.zip. It contains 5 libraries, please copy them to Arduino Libraries folder. If you don’t know how to do this, please follow manual installation guide.

@Badge could you please indicate why you were struggling to install 0.4.4 as it may help others.

Edit: see you have posted the problem.

@Dmitriy could you perhaps ensure that all your documentation links to the real latest release folder rather than a specific release that will be out of date in a week or two.

I know it is useful to direct users to a specific zip file for them to click on but with Blynk being so progressive it causes more problems than it solves. The links should just be to the latest releases folder at https://github.com/blynkkk/blynk-library/releases

This way some new users might actually read the release notes and understand how the libraries are to be structured. If you provide a zip link they never see the release notes.

I suggest the same for other Blynkers posting to hackster, instructables etc, don’t provide zip links and warn users that any sketch you include might need revisions to work with the latest libraries.

@Pavel please fix.

@Pavel presumably your “Plant pot demo” sketches for iOS and Android are on GitHub and being updated to reflect any Blynk library changes.