I Can Adjust Clock using arduino uno wilth esp8266 by Blynk?

Hi Dears
How I can adjust clock I mean change the minute increase or decrease by Blynk App using ardiuno uno , RTC module and esp8266 ?? Show the change time in LCD display . Any method for this . And which module need to use.
Please I’m looking for help.

I think you’re going to need to be much more specific about what you’re trying to achieve.

Do you mean you want to change the time on your mobile device (phone) that is running Blynk, or change time on the Arduino?
Does the Arduino have a RTC module attached?

Is the LCD that you’re referring to a physical one attached to the Arduino, or an LCD widget in the app?

What code are you running so far?

Pete.

Thanks dear
I mean if I use RTC in arduino and show the time in LCD module. I can use Blynk App on my phone to modify the time of RTC I mean adjust the clock. By increase or decrease the time and get the change of clock in LCD module.
Any way to do this Idea ? And How??

Yes and depends on your coding abilities. Blynk is a GUI interface with some built in GPIO control and IoT preferences, you still need to use code for more complete control than simply toggling GPIO pins.

Depending on your RTC, there may be ways of changing it’s settings on the fly. Google for that, and once you know how, then you can feed the required info in the required format (String? Numerical?) from a widget of some sort… Terminal, Text input or possibly even the Time Input Widget… then your code would transfer that input to the RTC.

 I used this code I get output Time and date on my phone but now I want adjust the time How I can???
       #define BLYNK_PRINT Serial
        #include <SPI.h>
        #include <Ethernet.h>
        #include <BlynkSimpleEthernet.h>
        #include <TimeLib.h>
        #include <WidgetRTC.h>
        char auth[] = "YourAuthToken";
        BlynkTimer timer;
        WidgetRTC rtc;

        void clockDisplay()
        {
          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);
        }

        BLYNK_CONNECTED() {
          rtc.begin();
        }

        void setup()
        {
          Serial.begin(9600);

          Blynk.begin(auth);
          setSyncInterval(10 * 60); // Sync interval in seconds (10 minutes)

          timer.setInterval(10000L, clockDisplay);
        }

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

If any way to solve my project
Thanks…

I asked you the question:

To which you replied:

Not a very clear answer, but one that implied to me (and it seems @Gunner) that you were indeed using an RTC module connected to your Arduino. Something like a DS1302.

However, from your code it appears that you’re simply using an RTC widget in your app and reading the time from that in your Arduino code.
If that’s the case then the RTC widget time can’t be adjusted (other than selecting the appropriate time zone from the widget) as the time comes from the server.

If you want people to help you then you should spend more time explaining your requirements and answer questions clearly and accurately.

Pete.

1 Like

Yes change time on the Arduino
Doesn’t have RTC on Arduino in this code just RTC widget
LCD is a physical one attached to the Arduino

So, no Hardware RTC… well since the Arduino doesn’t track the time, why not use the already supplied example and instead of Serial printing the time & date (supplied by the server) just print it to your LCD?

https://examples.blynk.cc/?board=Arduino%20Uno&shield=ESP8266%20WiFi%20Shield&example=Widgets%2FRTC

If the hour(), minute(), second() are integers you may be able to manipulate them before displaying it. Although I am not certain if you can do this, but might be worth a try.
As an example:

void adjClockDisplay()
        {
         int hourADJ = hour()+2; //add 2 hours
         int minADJ = minute()+2; //add 2 minutes
         int secADJ = second()+2; //add 2 seconds

          Serial.print("Adjusted time: ");
          Serial.print(hourADJ);
          Serial.print(":");
          Serial.print(minADJ);
          Serial.print(":");
          Serial.println(secADJ);
          
      
        }

Again this may or may not work. Just throwing it out there.

I’m still not clear about what you’re trying to achieve and why.
Why do you want the LCD to display a different time to the server time?

Pete.

1 Like

Thanks dear for help

I try to do project
If I have a clock in the wall (LCD )same time not accurate
If I need to make it accurate by my phone.
No need to remove the clock from wall just by wifi

I hope now clear

Crystal :roll_eyes:

2 Likes

What you mean? :thinking:

Exactly!

1 Like

@Moosa If you simply want an accurate clock (from Arduino/ESP/LCD) to hang on the wall, then use the example, output to the LCD and let the Blynk server supply the accurate time… no need to manually adjust.

Thanks dear
If I want manually How I can do??!!

With a physical RTC module

I have physical RTC
How I can do?!
Please I want help

We don’t do it for you :stuck_out_tongue_winking_eye: Start with Googling for examples for your RTC, get it to work without Blynk, then start adding in the Blynk control options like I suggested… at that point we are better equipped to give further suggestions.

Thank you all
I used this code
but I do’t know where the mistake

   #define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
//........................
#include <Wire.h>
#include <RTClib.h>
#include <LiquidCrystal_I2C.h>
//************************************//
LiquidCrystal_I2C lcd(0x3F,20,4); 
RTC_DS1307 RTC;
//************Button*****************//
int P1=6; // Button SET MENU'
int P2=7; // Button +
int P3=8; // Button -
//************Variables**************//
int hourupg;
int minupg;
int yearupg;
int monthupg;
int dayupg;
int menu =0;
//.............................
char auth[] = "*****************************************************";
char ssid[] = "*************";
char pass[] = "*****************";
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // TX, RX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);


void setup()
{

  Serial.begin(9600);

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  Blynk.begin(auth, wifi, ssid, pass);
//..............................................
 lcd.init();
  lcd.backlight();
  lcd.clear();

 pinMode(P1,INPUT);
  pinMode(P2,INPUT);
pinMode(P3,INPUT);

  Serial.begin(9600);
  Wire.begin();
  RTC.begin();

  if (! RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    // Set the date and time at compile time
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }
  
  int menu=0;
}
 
 //....................................................


void loop()
{
//.......................................
// check if you press the SET button and increase the menu index
  if(digitalRead(P1))
  {
   menu=menu+1;
  }
  if (menu==0)
    {
     DisplayDateTime(); // void DisplayDateTime

    }
  if (menu==1)
    {
    DisplaySetHour();
    }
  if (menu==2)
    {
    DisplaySetMinute();
    }
  if (menu==3)
    {
    DisplaySetYear();
    }
  if (menu==4)
    {
    DisplaySetMonth();
    }
  if (menu==5)
    {
    DisplaySetDay();
    }
  if (menu==6)
    {
    StoreAgg(); 
    delay(500);
    menu=0;
    }
    delay(100);
}

void DisplayDateTime ()
{
// We show the current date and time
  DateTime now = RTC.now();

  lcd.setCursor(0, 1);
  lcd.print("Hour:");
  if (now.hour()<=9)
  {
    lcd.print("0");
  }
  lcd.print(now.hour(), DEC);
  hourupg=now.hour();
  lcd.print(":");
  if (now.minute()<=9)
  {
    lcd.print("0");
  }
  lcd.print(now.minute(), DEC);
  minupg=now.minute();
  lcd.print(":");
  if (now.second()<=9)
  {
    lcd.print("0");
  }
  lcd.print(now.second(), DEC);

  lcd.setCursor(0, 0);
  lcd.print("Date: ");
  if (now.day()<=9)
  {
    lcd.print("0");
  }
  lcd.print(now.day(), DEC);
  dayupg=now.day();
  lcd.print("/");
  if (now.month()<=9)
  {
    lcd.print("0");
  }
  lcd.print(now.month(), DEC);
  monthupg=now.month();
  lcd.print("/");
  lcd.print(now.year(), DEC);
  yearupg=now.year();
}

void DisplaySetHour()
{
// time setting
  lcd.clear();
  DateTime now = RTC.now();
  if(digitalRead(P2)==HIGH)
  {
    if(hourupg==23)
    {
      hourupg=0;
    }
    else
    {
      hourupg=hourupg+1;
    }
  }
   if(digitalRead(P3)==HIGH)
  {
    if(hourupg==0)
    {
      hourupg=23;
    }
    else
    {
      hourupg=hourupg-1;
    }
  }
  lcd.setCursor(0,0);
  lcd.print("Set time:");
  lcd.setCursor(0,1);
  lcd.print(hourupg,DEC);
  delay(200);
}

void DisplaySetMinute()
{
// Setting the minutes
  lcd.clear();
  if(digitalRead(P2)==HIGH)
  {
    if (minupg==59)
    {
      minupg=0;
    }
    else
    {
      minupg=minupg+1;
    }
  }
   if(digitalRead(P3)==HIGH)
  {
    if (minupg==0)
    {
      minupg=59;
    }
    else
    {
      minupg=minupg-1;
    }
  }
  lcd.setCursor(0,0);
  lcd.print("Set Minutes:");
  lcd.setCursor(0,1);
  lcd.print(minupg,DEC);
  delay(200);
}
  
void DisplaySetYear()
{
// setting the year
  lcd.clear();
  if(digitalRead(P2)==HIGH)
  {    
    yearupg=yearupg+1;
  }
   if(digitalRead(P3)==HIGH)
  {
    yearupg=yearupg-1;
  }
  lcd.setCursor(0,0);
  lcd.print("Set Year:");
  lcd.setCursor(0,1);
  lcd.print(yearupg,DEC);
  delay(200);
}

void DisplaySetMonth()
{
// Setting the month
  lcd.clear();
  if(digitalRead(P2)==HIGH)
  {
    if (monthupg==12)
    {
      monthupg=1;
    }
    else
    {
      monthupg=monthupg+1;
    }
  }
   if(digitalRead(P3)==HIGH)
  {
    if (monthupg==1)
    {
      monthupg=12;
    }
    else
    {
      monthupg=monthupg-1;
    }
  }
  lcd.setCursor(0,0);
  lcd.print("Set Month:");
  lcd.setCursor(0,1);
  lcd.print(monthupg,DEC);
  delay(200);
}

void DisplaySetDay()
{
// Setting the day
  lcd.clear();
  if(digitalRead(P2)==HIGH)
  {
    if (dayupg==31)
    {
      dayupg=1;
    }
    else
    {
      dayupg=dayupg+1;
    }
  }
   if(digitalRead(P3)==HIGH)
  {
    if (dayupg==1)
    {
      dayupg=31;
    }
    else
    {
      dayupg=dayupg-1;
    }
  }
  lcd.setCursor(0,0);
  lcd.print("Set Day:");
  lcd.setCursor(0,1);
  lcd.print(dayupg,DEC);
  delay(200);
}

void StoreAgg()
{
// Variable saving
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("SAVING IN");
  lcd.setCursor(0,1);
  lcd.print("PROGRESS");
  RTC.adjust(DateTime(yearupg,monthupg,dayupg,hourupg,minupg,0));
  delay(100);
//...............................
  
  Blynk.run();
}

Now how I can use blynk app to Clock Set Date Time?