jpatrick62
Well-known member
Hello
Don't know if it's my mis-interpreting on how to use the DS1307RTC library or possibly that the DS1307RTC Teensy library is not compatible with
the PFC8523 RTC unit from Adafruit I was given. It looked to me as if I could use the Unix epoch time that I get from the NTP server and put
that time (in secs) in the time_t structure, which I thought the DS1307RTC could use to set the time. Unfortunately, I get a failed result from the
code test snippet shown below -
The Serial out debug is this:
Could not read RTC!
The epoch is 1537186292 seconds
RTC time set attempt failed...
Am I wrong in the library usage or is the DS1307RTC Teensy library incompatible with
the PFC8523 RTC unit from Adafruit?
Thanks!
Don't know if it's my mis-interpreting on how to use the DS1307RTC library or possibly that the DS1307RTC Teensy library is not compatible with
the PFC8523 RTC unit from Adafruit I was given. It looked to me as if I could use the Unix epoch time that I get from the NTP server and put
that time (in secs) in the time_t structure, which I thought the DS1307RTC could use to set the time. Unfortunately, I get a failed result from the
code test snippet shown below -
Code:
if (RTC.isRunning)
{
if (RTC.read(t))
{
Serial.println("RTC read");
}
else
{
Serial.println("Could not read RTC!");
if (_ntp.getNetTime() == TIME_PACKET_SUCCESS)
{
char temp[100] = { 0 };
sprintf(temp, "The epoch is %ld seconds", _ntp.getEpoch());
Serial.println(temp);
time_t tt = (long)_ntp.getEpoch();
if (RTC.set(tt) == true)
{
Serial.println("Time set in RTC!");
}
else
{
Serial.println("RTC time set attempt failed...");
}
}
}
}
The Serial out debug is this:
Could not read RTC!
The epoch is 1537186292 seconds
RTC time set attempt failed...
Am I wrong in the library usage or is the DS1307RTC Teensy library incompatible with
the PFC8523 RTC unit from Adafruit?
Thanks!