#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SPI.h>
//#include <Ethernet.h>
//#include <BlynkSimpleEthernet.h>
#include <TimeLib.h>
#include <WidgetRTC.h>
#include <Servo.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F,16,2);
Servo servo;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "";
const char* ssid = ""; //ใส่ชื่อ SSID Wifi
const char* password = ""; //ใส่รหัสผ่าน
BlynkTimer timer;
WidgetRTC rtc;
BLYNK_WRITE(V3) {
servo.write(param.asInt());
}
// 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);
lcd.begin(); // initialize the lcd
lcd.backlight();
lcd.setCursor(0,0);
lcd.print(currentTime);
lcd.setCursor(0,1);
lcd.print(currentDate);
}
BLYNK_CONNECTED() {
// Synchronize time on connection
rtc.begin();
}
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, password);
// 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 1 seconds
timer.setInterval(1000L, clockDisplay);
servo.attach(2);
}
void loop()
{
Blynk.run();
timer.run();
}
this the results start by
0 : 0 : 0
1 / 1 / 1970