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. How to get time a sensor has slept

How to get time a sensor has slept

Scheduled Pinned Locked Moved Troubleshooting
9 Posts 6 Posters 1.8k Views 5 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.
  • H Offline
    H Offline
    Heizelmann
    wrote on last edited by
    #1

    I would like to use sleep function with wakeup from interrupt or timeout. The function only returns the wakeup reason. Is there a possibility to get the time slept when the wakup came from interrupt? The reason is that I would like to process the inteerupt an then recall the sleep with only th remsing time from the inital sleep time.

    mfalkviddM 1 Reply Last reply
    0
    • H Heizelmann

      I would like to use sleep function with wakeup from interrupt or timeout. The function only returns the wakeup reason. Is there a possibility to get the time slept when the wakup came from interrupt? The reason is that I would like to process the inteerupt an then recall the sleep with only th remsing time from the inital sleep time.

      mfalkviddM Online
      mfalkviddM Online
      mfalkvidd
      Mod
      wrote on last edited by
      #2

      @Heizelmann almost all Arduinos stop all timers when sleeping (because timers need power), so it is not possible for the mcu to know how much time it has slept.

      There are a few tricks though. See these threads and see if any of the suggested solutions would work for you.
      https://forum.mysensors.org/post/71715
      https://forum.mysensors.org/topic/5284/sleep-time-is-not-actual-sleep-time/
      https://forum.mysensors.org/topic/6837/sleep-time-accuracy/
      https://forum.mysensors.org/topic/7216/test-time-with-timeawaresensor-sketch/

      H 1 Reply Last reply
      0
      • Nca78N Offline
        Nca78N Offline
        Nca78
        Hardware Contributor
        wrote on last edited by
        #3

        I think the most simple solution is to use an RTC. For example DS1302, it uses little power and runs at low voltage which is great for battery powered sensors. Precision is also good enough if you are not sleeping for days.

        1 Reply Last reply
        0
        • rmtuckerR Offline
          rmtuckerR Offline
          rmtucker
          wrote on last edited by
          #4

          Or use the Nrf5 which can keep time while sleeping 😉

          1 Reply Last reply
          0
          • M Offline
            M Offline
            manutremo
            wrote on last edited by
            #5

            If your Mysensors gateway is reporting to a domoticz server (or other system which supports it), you can request the present time from the controller, before and after sleeping, as indicated here:

            https://www.mysensors.org/download/sensor_api_20#requesting-data

            1 Reply Last reply
            0
            • mfalkviddM mfalkvidd

              @Heizelmann almost all Arduinos stop all timers when sleeping (because timers need power), so it is not possible for the mcu to know how much time it has slept.

              There are a few tricks though. See these threads and see if any of the suggested solutions would work for you.
              https://forum.mysensors.org/post/71715
              https://forum.mysensors.org/topic/5284/sleep-time-is-not-actual-sleep-time/
              https://forum.mysensors.org/topic/6837/sleep-time-accuracy/
              https://forum.mysensors.org/topic/7216/test-time-with-timeawaresensor-sketch/

              H Offline
              H Offline
              Heizelmann
              wrote on last edited by Heizelmann
              #6

              @mfalkvidd said in How to get time a sensor has slept:

              There are a few tricks though. See these threads and see if any of the suggested solutions would work for you.
              https://forum.mysensors.org/post/71715

              That is exact the same issue .Thanks for pointing to this. I didn't found this.

              1 Reply Last reply
              1
              • rejoe2R Offline
                rejoe2R Offline
                rejoe2
                wrote on last edited by
                #7

                I'm not sure if I really understood the problem, but also have several nodes with interrupt-bases actions (like motion).
                Isn't the easiest way to get around that kind of problems to not use the sleep-with-interrupt-funcionality but a seperate ISR instead? Like the Water Meter Pulse Sensor example?
                In case remaining sleep time could be too long (eg. for wind alerts), also adding (conditioned) sending functionality to an ISR is possible.

                Controller: FHEM; MySensors: 2.3.1, RS485,nRF24,RFM69, serial Gateways

                H 1 Reply Last reply
                0
                • rejoe2R rejoe2

                  I'm not sure if I really understood the problem, but also have several nodes with interrupt-bases actions (like motion).
                  Isn't the easiest way to get around that kind of problems to not use the sleep-with-interrupt-funcionality but a seperate ISR instead? Like the Water Meter Pulse Sensor example?
                  In case remaining sleep time could be too long (eg. for wind alerts), also adding (conditioned) sending functionality to an ISR is possible.

                  H Offline
                  H Offline
                  Heizelmann
                  wrote on last edited by
                  #8

                  @rejoe2 For battery power saving you need sleep().

                  rejoe2R 1 Reply Last reply
                  0
                  • H Heizelmann

                    @rejoe2 For battery power saving you need sleep().

                    rejoe2R Offline
                    rejoe2R Offline
                    rejoe2
                    wrote on last edited by
                    #9

                    @Heizelmann My answer also presumed using sleep() in the main loop, but to combine it with a seperate ISR. This concept seems to work, at least this was my conclusion when reading the mentioned PulseCounter-sketch, that can be configured as sleeping or non-sleeping node.

                    But I may be wrong, all my nodes are on power supplies until now...

                    Controller: FHEM; MySensors: 2.3.1, RS485,nRF24,RFM69, serial Gateways

                    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.0k

                    Posts


                    Copyright 2019 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