Page 1 of 2

ESP32-S3 RTC accuracy

Posted: Tue Jul 18, 2023 9:17 am
by ESPIRIT
Hello All,

I am using the ESP32-S3 (ESP32-S3-WROOM-1U-N4R2), and we need an accurate RTC.
At the hardware I have connected a 32.378Hz crystal clock at pin 8 (IO15) and pin 9 (IO16).
We use the ABS07-32.768KHZ-T crystal and have load capacitors of 15pF.

The problem is that the clock is very inaccurate. We expect about 20ppm, but we measure about 850ppm difference.
Changing the stray capacitance does not make any difference. We tried 6.8pF instead of the 15pF, but still the same difference...

Visual GDB:
- IDF version: 4.4.2
- See attachments

Can anybody please assist me solving this problems?

Manny thanks!

Re: ESP32-S3 RTC accuracy

Posted: Tue Jul 18, 2023 9:57 am
by ESP_Sprite
Check the bootup messages; if the crystal is tried but fails calibration for the RTC, ESP-IDF will fallback to the (inaccurate) internal oscillator but will also complain in the bootup messages.

Re: ESP32-S3 RTC accuracy

Posted: Tue Jul 18, 2023 3:03 pm
by ESPIRIT
Hi,

I checked if the external crystal is running normally at my application firmware and that is the case.
So the RTC does not run at the internal oscillators.
I checked it by short circuiting the crystal. Then I get a message in my debug output, the internal oscillator is taking over.

Re: ESP32-S3 RTC accuracy

Posted: Wed Jul 19, 2023 12:43 am
by ESP_Sprite
How, specifically, do you measure the time drift? As in: duration of test, sleep mode active, how do you get the time, ...?

Re: ESP32-S3 RTC accuracy

Posted: Wed Jul 19, 2023 5:59 am
by ESPIRIT
The firmware does not goto sleep.
I reset the clock and 24hours later I check it.
In 24 hours the time drift is about a minute.
I retrieve the clock with the gettimeofday function.

Re: ESP32-S3 RTC accuracy

Posted: Wed Jul 19, 2023 6:03 am
by ESP_Sprite
This is from memory and it's been a while, but I don't think the ESP32 uses the RTC clock signal when not in deep sleep; it uses the (normally more accurate) 40MHz clock instead. Could there be something wrong with that crystal?

Re: ESP32-S3 RTC accuracy

Posted: Wed Jul 19, 2023 6:06 am
by ESPIRIT
Is there anybody who has implemented a 32kHz crystal clock at the ESP32-S3-WROOM-1U-N4R2?
If so, is your circuit accurate?
Can be please share your circuit with me? It would be very helpful...

Many thanks in advance!

Re: ESP32-S3 RTC accuracy

Posted: Wed Jul 19, 2023 6:10 am
by ESPIRIT
Well the whole idea is to use an accurate 32khz crystal clock for the RTC.
Normally these crystals are more accurate then the main clock. (I see that it actually is 10ppm, which is not bad...)
Now I am testing without going to deep sleep, but later deep sleep is a must.
So then we also need the 32kHz RTC.

Re: ESP32-S3 RTC accuracy

Posted: Wed Jul 19, 2023 12:41 pm
by ESPIRIT
Hello All,

I have found a problem which causes the deviation of the RTC clock.
It seems be be in software somewhere.

When I use the rtc_time_get() function the clock is accurate.
When I use the gettimeofday() function the clock deviation is about 700ppm.
The gettimeofday() is inaccurate both when I set calibration time to 0 or 5000.

So maybe someone can tell me why this difference occures in software??

Thanks!

Re: ESP32-S3 RTC accuracy

Posted: Thu Jul 20, 2023 2:41 am
by ESP_Sprite
Do you have some minimal example code that shows the issue?