Good Afternoon everyone I have been researching this issue for a little while now about three days and I can't figure out why but the RTC on the Teensy 3.6 displays everything correctly other then the hour time.
I'm new to programming and I'm having a lot of fun. I normally like to figure things out for myself but i'm having a hard time with this issue
Current time is 13:37 and the RTC on the teensy 3.6 shows this time below.
17:37:42: 24/3/2019
Also here is my github for the project if this helps https://github.com/Dellyjoe/RTC_Light_Timer
I'm really just using the example code so i'm not sure what is really wrong.
I'm new to programming and I'm having a lot of fun. I normally like to figure things out for myself but i'm having a hard time with this issue
Current time is 13:37 and the RTC on the teensy 3.6 shows this time below.
17:37:42: 24/3/2019
Also here is my github for the project if this helps https://github.com/Dellyjoe/RTC_Light_Timer
I'm really just using the example code so i'm not sure what is really wrong.
Code:
#include <Arduino.h>
#include <rtc.h>
//******************************************Setup*****************************//
void intrtc()
{
// set the Time library to use Teensy 3.0's RTC to keep time
setSyncProvider(getTeensy3Time);
Serial.begin(115200); // Setting up the Serial Terminal
while (!Serial)
; // Wait for Arduino Serial Monitor to open
delay(100);
if (timeStatus() != timeSet)
{
Serial.println("Unable to sync with the RTC");
}
else
{
Serial.println("RTC has set the system time");
}
}
//******************************************Setup*****************************//
//******************************************Main******************************//
void displaytime()
{
intrtc();
if (Serial.available())
{
time_t t = processSyncMessage();
if (t != 0)
{
Teensy3Clock.set(t); // set the RTC
setTime(t);
}
}
digitalClockDisplay();
//delay(1000);
}
//******************************************Main******************************//
//*****************************************Functions**************************//
void digitalClockDisplay()
{
// digital clock display of the time
Serial.print(hour());
Serial.print(":");
Serial.print(minute());
Serial.print(":");
Serial.print(second());
Serial.print(": ");
Serial.print(day());
Serial.print("/");
Serial.print(month());
Serial.print("/");
Serial.print(year());
Serial.println();
}
time_t getTeensy3Time()
{
return Teensy3Clock.get();
}
unsigned long processSyncMessage()
{
unsigned long pctime = 0L;
const unsigned long DEFAULT_TIME = 1553130740; // March 20, 2019 9:12:20 PM
if (Serial.find(TIME_HEADER))
{
pctime = Serial.parseInt();
return pctime;
if (pctime < DEFAULT_TIME)
{ // check the value is a valid time (greater than Jan 1 2013)
pctime = 0L; // return 0 to indicate that the time is not valid
}
}
return pctime;
} //*****************************************Functions**************************//