Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. Calculation of time interval

Calculation of time interval

Scheduled Pinned Locked Moved Troubleshooting
5 Posts 2 Posters 1.3k Views 2 Watching
  • 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.
  • benyaB Offline
    benyaB Offline
    benya
    wrote on last edited by
    #1

    I am trying to calculate time interval by calling millis() function in loop().
    Looks like returned values are affected by smartSleep(). I mean time doesn't grow much during sleep.
    Is there a more reliable way to detect timeout?

    AWIA 1 Reply Last reply
    0
    • benyaB benya

      I am trying to calculate time interval by calling millis() function in loop().
      Looks like returned values are affected by smartSleep(). I mean time doesn't grow much during sleep.
      Is there a more reliable way to detect timeout?

      AWIA Offline
      AWIA Offline
      AWI
      Hero Member
      wrote on last edited by
      #2

      @benya the 'sleep' function causes the millis() timer to stop. Using an external clock (rtc) would be the best solution for low power operation. If you know how long you sleep you can do some calculations in the loop. Smartsleep() is not very predictable in this case ;)

      benyaB 1 Reply Last reply
      0
      • AWIA AWI

        @benya the 'sleep' function causes the millis() timer to stop. Using an external clock (rtc) would be the best solution for low power operation. If you know how long you sleep you can do some calculations in the loop. Smartsleep() is not very predictable in this case ;)

        benyaB Offline
        benyaB Offline
        benya
        wrote on last edited by
        #3

        @AWI If there is no RTC, should I opt to use requestTime() and receiveTime()?

        AWIA 1 Reply Last reply
        0
        • benyaB benya

          @AWI If there is no RTC, should I opt to use requestTime() and receiveTime()?

          AWIA Offline
          AWIA Offline
          AWI
          Hero Member
          wrote on last edited by
          #4

          @benya That would be a solution just be aware that you need to wail for reception of the time information.

          benyaB 1 Reply Last reply
          0
          • AWIA AWI

            @benya That would be a solution just be aware that you need to wail for reception of the time information.

            benyaB Offline
            benyaB Offline
            benya
            wrote on last edited by benya
            #5

            @AWI If node requests time and values before going to sleep, it will receive them upon return from smartSleep?

            void loop()
            {
              requestTime();
              request(1, V_STATUS); 
              request(2, V_STATUS);
              smartSleep(200);
            }
            
            void receive(const MyMessage &message)
            {
            ...
            }
            
            void receiveTime(unsigned long ts)
            {
            ...
            }
            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            15

            Online

            11.7k

            Users

            11.2k

            Topics

            113.1k

            Posts


            Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • MySensors
            • OpenHardware.io
            • Categories
            • Recent
            • Tags
            • Popular