RTC Example not compiling

HI, Im trying to use the RTC widget, but it is not compiling, I’m using an Esp32 and my IDE version is 1.8.5…
is somebody having this problem too?

I fixed your topic category.

We can’t guess… or see over your shoulder :stuck_out_tongue_winking_eye:

Please post (properly formatted) your code that displays the issue.

This is the code

#define BLYNK_PRINT Serial


#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.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[] = "YourAuthToken";

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();

  // Send time to the App
  Blynk.virtualWrite(V1, currentTime);
  // Send date to the App
  Blynk.virtualWrite(V2, currentDate);
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth);

  // Begin synchronizing time
  rtc.begin();

  // Other Time library functions can be used, like:
  //   timeStatus(), setSyncInterval(interval)...
  // Read more: http://www.pjrc.com/teensy/td_libs_Time.html

  // Display digital clock every 10 seconds
  timer.setInterval(10000L, clockDisplay);
}

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

you have an ’ in front of this. That will generate an error

It doesnt work without too

Without an error log output this code isn’t much worth in this case :wink:

Please… more details… what is the EXACT error?

Arduino: 1.8.5 (Windows 10), Placa:"ESP32 Dev Module, Default, QIO, 80MHz, 4MB (32Mb), 921600, None"

E:\Documents\arduino-1.8.5\libraries\blynk-library-master\examples\Widgets\RTC\RTC.ino:44:21: fatal error: TimeLib.h: No such file or directory

compilation terminated.

exit status 1
Erro compilando para a placa ESP32 Dev Module

Este relatório teria mais informações com
"Mostrar a saida detalhada durante a compilação"
opção pode ser ativada em "Arquivo -> Preferências"

And this is a root cause. Do you have it installed? It should be visible in library manager if it is. How have you installed Blynk library, as normally TimeLib.h it is included in package?

It is not in library manager, how can i get it?

Then You have not installed full Blynk Library release, where it exists. Sure it can be installed manually/independently from library manager in Arduino Ide too, but I insist on installing full Blynk release package.
this might help: http://help.blynk.cc/getting-started-library-auth-token-code-examples/how-to-install-blynk-library-for-arduino

This confused me too at one point :slight_smile: The name of the library is actually “Time” not “TimeLib”. Make sure you have the latest library containing both Time.h & TimeLib.h

If you look inside Time.h you will find ONLY this:
#include "TimeLib.h"
:smiley:
But both are included in package for compatibility. That is why it is best to install all those from release.

It worked… I downloaded the full blynk library, thank you guys

1 Like

Is there any problem on using RTC on esp32? cause on my is showing 1970

No issues that I am aware of… I use it in this and other projects on an ESP32

The 1970 basically means it is not yet synchronized with the “Internet” time.

Search this forum for 1970 and look at the various topics on this issue.