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