BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Example code to get RTC data on blynk

I m using nodemcu generic ESP8266 module . i am trying to get data from RTC DS1307 and put in blynk app. Is there any example code for interface nodemcu and DS1307

Yes plenty Have you looked?

Here is some of the code I use but not a complete project. If you want to see how I used it take a look at my digital scale project. wifi scale project

//days and months information
const char*  daystrings[7]  =  {"Sun", "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat"};
const char*   monthstrings[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
int days[7]; 
int today;

String  currentTime;
String  currentDate;
String  currentMonth;
String  currentDay;

    // get the time and the day
    void getCurrentTime() {
      currentTime = String(String(hour()) + ":" + twoDigits(minute()) + ":" + twoDigits(second()));
      currentMonth = monthstrings[month() - 1];
      currentDate = String(day());
      currentDay = daystrings[weekday() - 1];
    }
BLYNK_CONNECTED() {
  rtc.begin();                              // Synchronize time on connection
}
BLYNK_CONNECTED() {
  rtc.begin();                              // Synchronize time on connection
  //  bridge_master.setAuthToken(reader_token); // Token of reader
  Blynk.syncVirtual(adjpin, indexpin, knownweightpin);
}

// get the time and the day
void getCurrentTime() {
  currentTime = String(hour()) + ":" + twoDigits(minute());
  currentMonth = monthstrings[month() - 1];
  currentDate = String(day());
  currentDay = daystrings[weekday() - 1];
}

If you’re wanting to use a hardware RTC rather than the Blynk RTC widget then that’s a non-Blynk question. There are plenty of examples outside this forum of how to set/read/synchronise a hardware RTC module.
You need to decide if you’re going to synchronise the module with Blynk’s RTC or with an NTP server. If you go for Blynk’s server then there are Sketch Builder examples of how to obtain the time from the RTC widget.

Pete.