ESP32 Clock Accuracy

RE: Arduinon Uno loses time sync

The esp 32 is not going to keep accurate time for long periods of time. You either have to synchronize with an internet time source periodically or use something like an RTC to get accurate timing.

It should. Any ESP32 that I have ever seen, runs from a quartz crystal. In fact, I have an ESP32 clock that uses NTP. It took me a long time to realize it was losing wifi, because the time was still close after a few weeks of being out of sync.

The person asked about something running over a long period of time. Over the course of 30 days the clock will drift by 52 seconds. Every one of those milliseconds that it loses every so often adds up to real time if it runs long enough.
https://rntlab.com/question/how-the-clock-is-implemented-in-esp32/

Please read the original post. It is concerned with a time frame of a few hours. The described problem is an unwelcome reset, not time drift.

And the intention was that it is going to run BEYOND a few hours. The point being, the ESP32 does not have an RTC so the clock is not accurate over time.

You really need to do some research. The ESP32 does have a hardware RTC. Also the point is moot, since the original post has nothing to say about timing accuracy.

Now who's splitting hairs? Fine. The ESP32 does not have an ACCURATE RTC. Happy?

1 Like

I'm not splitting hairs. I am explaining technical details of an MCU. The point is simply irrelevant to the question that was asked, and very likely inapplicable to a solution.

Also, I never said you were splitting hairs...

Then we are just going to have to disagree. Because if the OP thinks that the timing of the ESP32 is going to be accurate over the long term, the solution to why the board is resetting is completely irrelevant. A lot of time could be wasted trying to solve that problem when in the end the time isn't accurate over the long-term anyway.

1 Like

Well, a quartz CPU crystal like that is usually accurate to about +/- 10PPM. That is not bad. It's close to what a bare, non temperature compensated RTC ASIC can do.

It's up to the OP to explain whether this completely separate issue will be crucial to the project.

Actually, there is strong possibility that it is a hardware related problem, it's very common to see motors play havoc with the MCU.

OP may be in a time zone where people are going to sleep...

It was stated that this is being used for astrophotography, so unless the OP is near the poles, or in space, long-term is unlikely to be more than a few hours. There is already a lot of potential drift built into the code by using delay() instead of millis() timing, and not accounting for any background processing that may cause the delay to run long, or consume unpredictable amounts of time between delays.

@ryancasler please try to stay on-topic.

The title of the thread is ESP32 Clock Accuracy. So, what's the topic?

The accuracy of the ESP32 clock so where does the Uno come into it ?

https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/system_time.html?highlight=rtc%20accuracy

1 Like

Then why???
image

This snippet is split from the original thread. You'll notice the link in the first post with the "RE". I foolish assumed that was an obvious indication that this had been taken from another thread. I guess next time I'll include something like this...

THE OFF-TOPIC JUNK BELOW WAS SPLIT FROM THE ORIGINAL THREAD JUST IN CASE YOU'RE CONFUSED ABOUT THE LINK AT THE VERY TOP

The topic there, the topic of concern, the topic you and @anon57585045 failed to stay on, was "Arduino Uno".

I kept this snippet in case you and @anon57585045 wanted to continue discussing the ESP32 clock. I assume its accuracy is of interest to the forum at large. But it is of no interest to hassaanzaheer.

Sorry, I simply didn't notice the change of subject in the original thread.

1 Like

I'm not sure why you expect an ESP32, with a crystal accurate enough to generate WiFi signals, will be less accurate than a (random) RTC with a (random) 32kHz crystal.

(Ok - actually the ESP32 has an "RTC peripheral" that can operate off of a lower-precision internal clock, OR an external 32kHz crystal that is separate from the main CPU crystal used to derive WiFi signals. Which brings up the question of which clock the Arduino/ESP32-SDK/FreeRTOS implementation of millis() and etc actually uses, whether the internal clock is "tuned" off of the CPU clock (it IS apparently adjustable), and more. Most ESP32 modules and boards do not seem to have a 32kHz crystal, but adding one seems simpler (cheaper, anyway) than adding an RTC module.)

1 Like

At last, an explanation.........