RTC not pulling time from server

[0] Using static IP
[1300] IP:192.168.1.50
[1300]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
/
//_, /////_
/
__/ v0.4.3 on Arduino Nano

[1412] Free RAM: 1168
[5001] Connecting to blynk-cloud.com:8442
[5117] <[02|00|01|00]
[5117] <27851b7651394c86b4e4aa4066ec7341
[5170] >[00|00|01|00|C8]
[5170] Ready (ping: 50ms).
[5176] <[11|00|01|00]e
[5200] <ver[00]0.4.3[00]h-beat[00]10[00]buff-in[00]256[00]dev[00]Arduino Nano[00]cpu[00]ATmega328P[00]con[00]W5100[00]build[00]Jan 17 2017 14:02:47[00]
[5360] <[10|00|02|00|06]
[5387] <vr[00]255
[5406] >[00|00|01|00|C8]
[5450] >[00|00|02|00|02]
Current time: 0:0:15 1 1 1970
[15406] <[14|00|03|00|0B]
[15407] <vw[00]1[00]0:0:15
[15428] <[14|00|04|00|0D]
[15456] <vw[00]2[00]1 1 1970
[15488] <[06|00|05|00|00]
[15561] >[00|00|05|00|C8]
Current time: 0:0:25 1 1 1970

/*************************************************************
  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Blynk community:            http://community.blynk.cc
    Social networks:            http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************
  Blynk can provide your device with time data, like an RTC.
  Please note that the accuracy of this method is up to several seconds.

  App project setup:
    RTC widget (no pin required)
    Value Display M widget on V1
    Value Display M widget on V2

  WARNING :
  For this example you'll need SimpleTimer library:
    https://github.com/jfturcot/SimpleTimer

  And also this Time keeping library:
    https://github.com/PaulStoffregen/Time

  This code is based on an example from the Time library:
    https://github.com/PaulStoffregen/Time/blob/master/examples/TimeSerial/TimeSerial.ino
 *************************************************************/

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#define BLYNK_DEBUG  
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.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[] = "27851b7651394c86b4e4aa4066ec7341";
IPAddress device_ip  (192, 168,   1,  50);
IPAddress dns_ip     (  8,   8,   8,   8);
IPAddress gateway_ip (192, 168,   1,   1);
IPAddress subnet_mask(255, 255, 255,   0);
SimpleTimer timer;

WidgetRTC rtc;

// 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(month()) + " " + day() + " " + 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()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, "blynk-cloud.com", 8442, device_ip, dns_ip, gateway_ip, subnet_mask);

  // 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();
}

The same here.
Not getting time from Server
Using local server v .21.7
I updated to latest library and now nothing compiles

RTC widget required some time to kick start. So to solve this problem you can use conditions which will check does the time &date. update or not.
For example .
If(year!=1970)
{
//Do you rtc tasks
}

You need 0.4.4 for that code.

That fixed it,
thank you

Hi. The same problem with local and cloud server. Library 0.4.4…No sync.

@Arsen I did what I thought would be a quick test yesterday. Like a numpty I was forgetting to add the RTC widget.

If you have included the widget and have the correct versions of “everything” have you looked into setSyncInterval?

Various posts on this site covering setSyncInterval.

Of course widget was added, and I
tried setsync, no result. The older scetch version with pin widget RTC working good.

@Arsen which app version?

2 7 1. Version app doesn’t matter, in com port monitor wrong data.

Blynk v0.3.7 at the picture… Not v0.4.4…??

2 Likes

yep…Thanx!

Well spotted @psoro and @Arsen app version does matter.
If the Serial Monitor you provide for us shows a library that doesn’t work with the new RTC widget then I would assume you haven’t installed the correct libraries.

If you are still having problems sketch and Serial Monitor (showing correct library) please.

1 Like