RTC and Time Alarms error

Hi guys

I found this code here on the forum, but for the life of me I`m still getting errors.

Can someone point me in the right direction as I`m losing hair over this!.

Error is

error: 'setSyncProvider' was not declared in this scope

Thanks in advance Alan

Code: [Select]

#include <Wire.h>         //http://arduino.cc/en/Reference/Wire (included with Arduino IDE)
#include "RTClib.h"
#include <Time.h>         //http://www.arduino.cc/playground/Code/Time 
RTC_DS1307 RTC;
//RTC_DS3231 RTC;

uint32_t syncProvider()
{
  return RTC.now().unixtime();  //either format works
 // DateTime now = RTC.now();
 // uint32_t s = now.unixtime();
 // return s;
}

void setup(void)
{
  Serial.begin(9600);
  Wire.begin();
  RTC.begin();
  setSyncProvider(syncProvider);   // the function to get the time from the RTC
  if(timeStatus() != timeSet)
    Serial.println("Unable to sync with the RTC");
  else
    Serial.println("RTC has set the system time");     
}

void loop(void)
{
  timeDateDisplay(); 
  delay(1000);
}

void timeDateDisplay(void)
{
 
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.print(' ');
  Serial.print(month());
  Serial.print("/");
  Serial.print(day());
  Serial.print("/");
  Serial.print(year());
  Serial.println();
  Serial.print("Unix Time ");
  Serial.println(now());
  Serial.println();
}

void printDigits(int digits)
{
  // utility function for digital clock display: prints preceding colon and leading 0
  Serial.print(':');
  if(digits < 10)
    Serial.print('0');
  Serial.print(digits);
}
//#include <Time.h>         //http://www.arduino.cc/playground/Code/Time
#include<TimeLib.h>

The naming of this library was changed due to some capitalization issues in Windows where it could not distinguish between between time.h and Time.h. time.h is a standard c/c++ library and Time.h was the Arduino library.

Current library examples use the #include <TimeLib.h>

Hi Cattledog, same error

Your code compiles successfully for me. Please post the exact error message. I would also suggest reloading or updating the Time library through the library manager. It is listed as Time by Michael Margolis in the Library Manager.

Apologies, its not the same error, now its saying

invalid conversion from 'uint32_t ()() {aka unsigned int ()()}' to 'getExternalTime {aka long int (*)()}' [-fpermissive]

Hi Cattledog

Yes your right it now works.

I still ran into an error which was

invalid conversion from 'uint32_t ()() {aka unsigned int ()()}' to 'getExternalTime {aka long int (*)()}' [-fpermissive]

But its because my board is a Wemos D1 mini ESP8266, I tried with a UNO and it works fine.

Would you know how to make it work on that board?

Cheers Alan

But its because my board is a Wemos D1 mini ESP8266, I tried with a UNO and it works fine.
Would you know how to make it work on that board?

//uint32_t syncProvider()
time_t syncProvider()

You sir are an absolute top man!

Thank you so much, if I could buy you a beer I would :wink:

Big Cheers