Accuracy of RTC



  • Has any testing been done on the accuracy of the RTC, especially while in deep-sleep mode? How accurate is the wake-up time that's passed in the deep_sleep() call?

    Will the external 32KHz crystal be supported in the near future? And if so, what is the expected accuracy of the RTC with the crystal?

    PS - I'm not clear on what clock source is used by the ESP32 in deep-sleep mode, especially if there is no external 32KHz crystal.



  • @jmarcelino My goal is to make a watch, so I unfortunately don't have space for that. I guess I will have to wait and see what the devs do, and maybe make my own micropython port.



  • @BluCode
    I recommend you use an external RTC for now for those applications.

    For example the DS1307 is easy to interface over I2C and very very cheap (full module inc external eeprom can be had for <$1 http://www.ebay.com/itm/Arduino-I2C-RTC-DS1307-AT24C32-Real-Time-Clock-Module-For-AVR-ARM-PIC-SMD-/170910326110

    Also it's self-battery powered, it'll keep the time for many years with issues caused by firmware upgrades or others.



  • If at all possible it would be great if there was an option to keep the RTC powered during deepsleep, as I will be using my board in an application the needs to know the time (or some relativity accurate estimation of the time) immediately after waking from deepsleep, in some cases without internet.



  • @loboris
    Thanks, was just catching up with the ESP32 forum myself.

    "Note that we are observing issues on some boards with 32k xtal startup time... That's part of the reason why you don't see 32k xtal support in master yet. We are now working these issues."

    https://www.esp32.com/viewtopic.php?p=7269#p7269

    So wait and see I guess.



  • @jmarcelino said in Accuracy of RTC:

    @loboris very interesting, thank you for sharing that.

    Did you try it with the Pycom boards and a crystal on P19 + P20?

    I've tested it with SparkFun ESP32 Thing. The 32.768 Khz crystal is connected to 32K_XP&32K_XN pins (P19+P20 on Pycom) so it should work on Pycom boards the same.
    The changes has to be made in couple of source files, I think it's better to wait the esp-idf team to finish the job. I've tested it with deep-sleep example and it works much better than with 150KHz wich has error of ~10%.



  • @jmarcelino said in Accuracy of RTC:

    In either case I don't think there is, for now, an intention to keep the time updated on the RTC while in deep sleep. The recently announced deepsleep shield for example seems to turn everything off.

    Yes but only for the pycom device revisions with the hardware issue. Of course soon there will be new revisions and some of us run on other hardware so hopefully it is flexible.



  • @loboris very interesting, thank you for sharing that.

    Did you try it with the Pycom boards and a crystal on P19 + P20?



  • In the latest esp-idf there is the code for enabling RTC with external 32.768 crystal, but there are still some bugs and incompleteness. components/esp32/cpu_freq.c, for example, has a bug (probably left there intentionally because of incompleteness in other code). I have tested it, and very precise time is kept during the deep sleep, so I expect the complete code to be available soon.
    There is also an option in menuconfig to select external 32.768 xtal.



  • @littlebat
    That may well be true and thank you for your thoughts on it. The ESP32 documentation isn't very clear and I was going by this http://esp-idf.readthedocs.io/en/latest/api/system/deep_sleep.html

    "RTC controller has a built in timer which can be used to wake up the chip after a predefined amount of time. Time is specified at microsecond precision, but the actual resolution depends on the clock source selected for RTC SLOW_CLK. See chapter “Reset and Clock” of the ESP32 Technical Reference Manual for details about RTC clock options.

    This wakeup mode doesn’t require RTC peripherals or RTC memories to be powered on during deep sleep."

    In either case I don't think there is, for now, an intention to keep the time updated on the RTC while in deep sleep. The recently announced deepsleep shield for example seems to turn everything off.



  • @jmarcelino No I don't think that's true. The RTC counter IS used for deep sleep and the "simple timer" is just a threshold register which is loaded with the current RTC value + timer value.

    https://github.com/espressif/esp-idf/tree/master/examples/protocols/sntp



  • @Eric24
    The RTC doesn't operate in the deep sleep with timer wake up mode. The ESP32 only maintains a simple timer for the wake up trigger.

    The wake up time for the deep sleep is specified in microseconds, but I believe the clock for that is only 150 KHz.
    It's all in the "Reset and Clock" section of the ESP32 Technical Reference.

    Also at wake up the ESP32 will have to reboot and reload the MicroPython task including your code so there'll be a relatively large and possibly variable delay depending on firmware version and other startup factors.

    The hardware does support higher power modes with the full RTC enabled but not the software yet. If you need accurate time you could use an external RTC chip or re-syncing time, for example via NTP, at start.


Log in to reply
 

Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.