RTC milliseconds

I am trying the RTC for the first time.
The time can be set and read, however when I call ‘rtc.Now’, the timestamp always has 0 milliseconds.
Is there a solution for this?

Please help us help you.

What board and what firmware are you running.

A sample of the code you are using would also help.

From the .NET documentation for DateTime.MIllisecond

Gets the milliseconds component of the date represented by this instance.

Milliseconds is not the total elapsed time in milliseconds. The value varies form 0…999.

That is normal and expected. The RTC ticks every second but what you need is the system time, which ticks at 100ns.

Welcome to the community

Thanks for the fast response.
That mistery is solved then. I will try to use System Time

Best regards

1 Like

What I see with this clock is that the accuracy is less good. The clock lags approximately 100 ms every 10 s (I suppose this may vary due to tolerances on the crystal)
Is there a possibility to compensate this?

The challenge here is you want milliseconds accuracy over several seconds. Perhaps read the system tick and compensate that?

@Dat_Tran does 1% sound correct? One second every 100?

Shouldn’t RTC be more accurate than system clock ?

No, 100 sec < 2 min. We have tested much longer than that and it is still accurate.

What device and what firmware, are you using custom board?

I’m using a FEZ Feather.
Firmware version is

In the mean time, I have done some testing with the 4 FEZ feather devices that I have.
The time lag is smaller then I first thought: For all devices the time lag is 40 ms (± 5 ms) every 10 s.
I would like the time lag to be smaller, but for now I can increase the frequency of time synchronisation messages.

Right, I don’t remember what version exactly, but this version is very old and, yes, we had system time is not accurate in the past.

With 2.1.0-prevew1 or 2 is more accurate, we don’t see any different second in few hours.

That’s interesting … I’m trying it out.

I have switched to firmware v2.1.0.2000 and libraries with version v2.1.0-preview2. Now the System Clock lags only a few ms per minute!
Thanks for this solution. It works really well now!

1 Like