#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.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[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
char ssid[] = "xxxx";
char pass[] = "xxxxxxxxxxxxxx";
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();
Blynk.virtualWrite(V1, currentTime);
Blynk.virtualWrite(V2, currentDate);
}
//void slem()
//{
//if(digitalRead(D0)==LOW){
//(Blynk.virtualWrite(V5, 0));
//}else{
//(Blynk.virtualWrite(V5, 255));
//}
//if(digitalRead(D5)==LOW){
//(Blynk.virtualWrite(V6, 0));
//}else{
//(Blynk.virtualWrite(V6, 255));
//}
//}
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
rtc.begin();
timer.setInterval(1000L, clockDisplay);
}
void loop()
{
if(digitalRead(D0)==LOW){
(Blynk.virtualWrite(V5, 0));
}else{
(Blynk.virtualWrite(V5, 255));
}
if(digitalRead(D5)==LOW){
(Blynk.virtualWrite(V6, 0));
}else{
(Blynk.virtualWrite(V6, 255));
}
Blynk.run();
timer.run();
}
lamp on start timer
lamp off stop