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