Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Restore RTC value after Pysense go_to_sleep

    Scheduled Pinned Locked Moved Expansion Board
    pysensertcrtc memory
    2 Posts 2 Posters 403 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G Offline
      gabrielapb
      last edited by gabrielapb

      In boot.py I am using rtc.ntp_sync to set up automatic fetch. If I put Pysense to sleep, I lose the automatic datetime info after it wakes up.

      Is there any way to restore RTC value without having to start the whole process of connecting to WiFi and syncing again?

      I am using Lopy4 + Pysense

      J 1 Reply Last reply Reply Quote 0
      • J Offline
        jcaron @gabrielapb
        last edited by

        @gabrielapb You could try the following:

        • save the current timestamp to NVS before going to sleep
        • on wake-up:
          • retrieve the saved timestamp from NVS
          • retrieve the "remaining sleep" from the Pysense using pysense.get_sleep_remaining
          • current timestamp is approximately saved + sleep interval - remaining

        Note this won't get you a very precise time (as it doesn't take into account boot time, and I'm not sure of the accuracy of the Pysense clock), and the offset to the real time will increase with the number of sleep periods, but it's helpful to have at least of rough idea of the time until you can get the actual time through other means.

        The alternative is to use the module's deep sleep rather than the Pysense's deep sleep, but that may not be possible depending on your actual use case.

        1 Reply Last reply Reply Quote 2

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • 1 / 1
        • First post
          Last post

        Pycom on Twitter

        Pycom