RTLL8722DM_mini rtc not getting set properly

Hello

I a m using NTPClient to get unix epoch and setting ( setting real time clock RTC ) it using following code

unsigned long epochTime = timeClient.getEpochTime();
and then I use

rtc.Write(epochTime);

and then I am using following code to read back values I just wrote ( after few statements )
Serial.print("read back ecpoch = ");
Serial.println(rtc.Read());

and read back value is way off , what I am doing wrong…?

-Thanks
-Alok

1 Like

Hi @Alok_Kumar_Mishra

I think its mentioned in the library author’s note,

This function doesn’t return time in the same format as the getFormattedTime() function, so you will have to pay attention to how its formatting, detailes of the code can be found here

Hello,

thanks for code referral, but my question is after using rtc,Write(NTPclient.getEpochTime()) read back values should differ by few seconds , but in my case it is different by factors of thousands , for example using ntp time I am getting followings

date and time =22/12/2021 1:41:44
Seconds since Jan 1 1970 = 1640137304
and after writing to relal time clock I when I read back I am getting
read back ecpoch = 1608514904 ,why it is so much difference , I am not able to comprehend…?

-Thanks
-Alok

here is code from file .//Library/Arduino15/packages/realtek/hardware/AmebaD/3.0.10/libraries/RTC/src/rtc.cpp

/**

  • @brief Get current timestamp in seconds from RTC.
  • @param none
  • @retval value: The current timestamp in seconds which is calculated from
  •          1970.1.1 00:00:00.
    

*/
int32_t RTC::Read(void) {
return (rtc_read() - 508055296);
}

I am using function Read() ,and could somebody tell me why 508055296 subtracted …? rtc_read already returns time in seconds from 1 Jan 1970 midnight

-Thanks
-Alok

OK, I used rtc_write (…) ( rtc c api library calls ) followed by rtc_read() now return epoch is correct, can someone determine is there a problem C++ RTC api…?

-Thanks
-Alok

1 Like

We will take a look soon~

Hi @Alok_Kumar_Mishra

Thanks for raising the issue, please note that your findings have already been verified and rectified at PR#71,

You may update your RTC library accordingly or wait for next release to update(might take a while)