Problem to convert RTC to seconds

Hello everybody,
I have a problem converting the time from rtc to s. For me he always spits only e.g. at 21:51 = 13,124. Although it would have to be 3600 * 21 + 60 * 51 = 78.660.
What did I do wrong?

    #define BLYNK_PRINT Serial
    #define EspSerial Serial
    #define BLYNK_PRINT Serial
    #define ESP8266_BAUD 115200

    #include <SPI.h>
    #include <ESP8266_Lib.h>
    #include <BlynkSimpleShieldEsp8266.h>
    #include <TimeLib.h>
    #include <WidgetRTC.h>

    char auth[] = "---";
    char ssid[] = "---";
    char pass[] = "---";

    BlynkTimer timer;

    WidgetRTC rtc;

    ESP8266 wifi(&EspSerial);
    String currentTime;
    String currentDate;
    long Time;
    void clockDisplay()

    Time = 3600*hour() + 60* minute();
       currentTime = String(hour()) + ":" + minute() + ":" + second();
       currentDate = String(day()) + " " + month() + " " + year();
      Serial.print("Current time: ");
      Serial.print(" ");
      // Send time to the App

      Blynk.virtualWrite(V4, hour());

      Blynk.virtualWrite(V5, minute());

      Blynk.virtualWrite(V6, Time);


    void setup()
      // Debug console
      Blynk.begin(auth, wifi, ssid, pass);
      timer.setInterval(10000L, clockDisplay);

    void loop()

Please don’t duplicate your topics/posts… i have removed the 2nd redundant topic

Why not simply use this:

      Blynk.virtualWrite(V6, second());

Sorry. I didnt know where to post it. Im new.
And I think if you use seconds() you will just get a number of 0 to 59 and not all seconds counted together.
But I will try it
Thx for the quick response

To be sure, group things together. Arduino and mathematical functions can be a pain in the a$$.

Time = (3600*hour()) + (60* minute());

Yes, 0-59 of course… but you never said anything about total amount of seconds in a time-frame… that is something completely different. and not necessarily an RTC (or Blynk) issue.

For example if you want to know how long your MCU has been running since last boot, then you can use millis() as is done in the Push Data example (in the Sketch Builder).

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, millis() / 1000);

There are probably many other ways to count seconds… most non-Blynk specific, so take a stroll around Google for more ideas.

I have the solution!
3600*21 is to Long for int an to calculate with unsigned Long you have to do Time = 21 * 3600L.
Thank for all of your replies.

1 Like