Go Down

Topic: Inaccurate RTC (Read 3084 times) previous topic - next topic


Measured over 24 hours with a time reference device (GPS clock) the MkrZero RTC is grossly out of whack, exhibiting a 30 ppm drift rate (a mediocre watch would be in the 5 to 1 ppm range).
I know the RTC can be frequency-adjusted but the RTCZero library does not offer that option and I have a hard time turning what I read in the SAMD21 documentation into effective instructions.
Can anyone help ?


Almost 600 reads and no answer probably signals that this topic is of little interest to Arduino users. However I'll report what I have found so far, hoping that it may be useful to another lonesome maker somewhere, who foolishly believes, like I did, that the Mkr0 RTC may be of any use.

1- Having tested 3 Mkr0s I confirm the poor performance of the combination crystal + RTC (the RTC is not the only one to be blamed).

2- The frequency correction register may be read or written to by using the variable name :   REG_RTC_FREQCORR,  to be found well hidden in (hold your breath):


and defined as :
#define REG_RTC_FREQCORR           (*(RwReg8 *)0x4000140CU) /**< \brief (RTC) Frequency Correction.

It can take a value of +/-127, each unit adding or substracting 1 ppm to the oscillation period.
3- Regardless of how the circuit is powered, battery, USB, Vin, every time an SD card is inserted the RTC is reset to 0 (date 00/00/00, time 00 :00 :00).

4- Every time the Mkr0 is reset (for example when loading a program) ) the RTC « loses » about 1.6 second.

5- Minor, but not mentioned in the RTC0 lib : the RCT codes the year value on 6 bits, ie 17 is fine but 2017 is not. The SAMD21 documentation defines Year as « a value counting the offset from a reference value that must be defined in software » (and must be a leap year if you want leap years to be handled properly).

Conclusion :

- If you need accurate, dependable time keeping don't count on the the Mkr0 RTC. A DS3231 rated at 2ppm and easily adjustable to less than .5 ppm is a better choice and with a 3-volt back up battery it is totally immune to the processor's hiccups.

- On the other hand if all you need is an alarm defined as « 3 days, 6 hours and 27 seconds from now, give or take 15 seconds » the RTC is fine (but don't fiddle with that SD card !).


Hi jmkymoe

Thanks for your post here. I just started working with the MKRZero and the internal RTC. Not much information on the web and your post also does not sound that good regarding the internal RTC. At least it contains a lot of usefull hints.

One strage thing for a RTC beginner (like me): I have to install the external lib RTCZero, right?



if timing is so critical then it makes more sense to add ethernet or WiFi and use NTP as the source.

No more worries.

Even most of today's computers / tablets / phones will loose or have errors in timing were it not for the fact that most get it directly from the internet.

Seen a tablet loose an hour after not being connected for a few weeks and self rectify the moment its switched on with an available connection.

Seen computers loose all track of date and time when the internal battery gets to replacement point.

Its not a new issue with technology or Arduinos in particular.
It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.


Thanks for a very helpful post, jmkymoe ! It answered all my questions but one:

Does anyone know if you can power the RTC with a dedicated battery? Not the Li-Po that powers the whole board, but a separate coin cell for the RTC only?


hi mhopeng,

You can buy lots of RTC's that are battery powered, just look on eBay or Amazon, anywhere they sell Arduino or Arduino like boards should have some like Adafruit or SparkFun and many others. They are powered by its own battery (may not be included). The units I have are Tiny RTC I2C module but they are based on the DS1307 chip and use a CR1225 battery.


Go Up