WidgetRTC with not good time

Hello,

I use a personnel server for blynk.

I wanted to use WidgetRTC but the date is not correct:
it starts from 0:
Current time: 0: 0: 52 1 1 1970

What is the procedure for it to be updated directly?

/*************************************************************

  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 widget on V1
    Value Display widget on V2

  WARNING :
  For this example you'll need 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
 *************************************************************/

// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud
// See the Device Info tab, or Template settings
#define BLYNK_TEMPLATE_ID           "TMPLxxxxxx"
#define BLYNK_DEVICE_NAME           "Device"
#define BLYNK_AUTH_TOKEN            "**********************************"


// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial


#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <TimeLib.h>
#include <WidgetRTC.h>

char auth[] = BLYNK_AUTH_TOKEN;

#define W5100_CS  10
#define SDCARD_CS 4

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

BLYNK_CONNECTED() {
  // Synchronize time on connection
  rtc.begin();
}

void setup()
{
  // Debug console
  Serial.begin(115200);

  pinMode(SDCARD_CS, OUTPUT);
  digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card

  Blynk.begin(auth, IPAddress(192,168,1,100), 8080);

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

  setSyncInterval(10 * 60); // Sync interval in seconds (10 minutes)

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

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


Thank you

Library version?

Pete.

Hi

Blynk 1.0.1
#include <TimeLib.h>. 1.6.0

Is that what you wanted to know?

it’s a personnel serveur with Blynk inside .

thank you

No, I want to know which version of the Blynk library you have installed when you compiled the code.

Your sketch includes a Blynk IoT template ID and device name, yet you are running a legacy local server, which doesn’t use template ID and device name. If you are also iso g the IoT version of the Blynk library rather than the legacy library then this could be the cause of your issue, hence my question.

Pete.

I had 0.6.1, when you asked I installed 1.0.1 then re-uploaded but it still does not work

You should be using 0.6.1 with legacy local server.

Do you have the RTC widget in your app, and have you set the timezone correctly in the widget?
Is your local server set to the correct time?

Pete.

It works with the RTC Widget
I did not understand that it was necessary to use the widget

this may seem logical but it is not mentioned in the example.

@PeteKnight thank you very much for taking the time to answer me

Yes it is…

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

Pete.

Ah yes :pensive:

I have another question, why is 10 seconds behind UTC time?
my personal server is on time and there is no delay on the sketch