0
\$\begingroup\$

We know computer and another device like microcontroller is not accurate in ticking clock comparing to wall clock that using cesium atom.

I heard RTC module is purpose to making accurate the ticking.

But microcontroller that I used is Espressif family which they have built-in Wi-Fi module.

I mean, I can just syncron the time with using Network Time Protocol aka NTP for every few period for example syncroun every 1 hour. So that's mean the MCU will retrieve data from NTP server every 1 hours relative calculated with using millis() function.

So do I still need RTC module?

Yes the disadvantage of using NTP is need online while RTC still can be used in offline. But once the device is online, it will syncroun again following NTP server.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Many IOT devices have no RTC or battery backed RTC. They will simply pull time from the network. \$\endgroup\$
    – Passerby
    Commented Apr 28, 2022 at 6:19
  • 1
    \$\begingroup\$ it depends when you want the time. If your device can only do meaningful things when online, then you never need more than NTP. If you can do useful things offline, like create new files that need dating and comparing with existing, then you will need RTC. \$\endgroup\$
    – Neil_UK
    Commented Apr 28, 2022 at 7:06
  • 1
    \$\begingroup\$ assuming you're talking about the esp32, this (docs.espressif.com/projects/esp-idf/en/latest/esp32/…) suggests that the high resolution timer has an error of around 10ppm, which is only 0.8 sec per day, or 36ms per hour (probably significantly more error at higher temps though) - this is a pretty small drift, comparable to many RTC, so unlikely to be an issue for you \$\endgroup\$
    – BeB00
    Commented Apr 28, 2022 at 8:40
  • \$\begingroup\$ the reason you might want an RTC is if you wanted to save power (this clock is only high accuracy when not in sleep mode), or if you wanted to be able to have a high reliability (if your esp32 resets, it wont know what time it is without an RTC) \$\endgroup\$
    – BeB00
    Commented Apr 28, 2022 at 8:41

2 Answers 2

2
\$\begingroup\$

Only talking about the ESP32: The internal RTC is quite useful because it keeps running even when the ESP32 reboots (via any kind of software reset, watchdog reset, crashes,...).

It makes totally sense to combine RTC with NTP because the RTC is not that precise and should be adjusted once in a while (e.g. once a day).

NTP is also neccessary to initialize the RTC after power up, because the RTC time does not survive power cycles and hardware resets via the Reset button (aka "power-on reset").

\$\endgroup\$
0
\$\begingroup\$

As long as the ESP has a network connection, you can update the time periodically with it. Then the ESP will calculate the time based on the processor cycles. Since this is not 100% accurate, there may be larger deviations over a longer period of time.

But if you update the clock every hour via NTP, this is negligible.

I think I read that with an Atmega328 the deviation at 24h is about 7 minutes.

\$\endgroup\$
2
  • \$\begingroup\$ I would hardly call an error of 20 seconds or so in an hour "negligible". If your Atmega runs fast you have the problem of trying to go back in time with your real-time processes. \$\endgroup\$ Commented Apr 28, 2022 at 9:22
  • \$\begingroup\$ You are right, of course, but one should differentiate depending on the application. \$\endgroup\$
    – valeum
    Commented Apr 28, 2022 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.