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. Development
  3. Sleep time and external interrrupts

Sleep time and external interrrupts

Scheduled Pinned Locked Moved Development
9 Posts 3 Posters 2.4k Views 3 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.
  • karlheinz2000K Offline
    karlheinz2000K Offline
    karlheinz2000
    wrote on last edited by
    #1

    I have a sensor to count events (rain sensor). This sensor uses sleeps mode to save power. Any event triggers an external interrupt to wake up the sensor and increment the counter. After an certain time the sensor should send the counter value to the controller.
    I use int8_t sleep(int interrupt, int mode, unsigned long ms=0); to wake up either from external IRQ or timer. But if many events occure, the timer never triggers (and the sensor does not send values to controller).
    Is it possible to get the elapsed sleep time, when external IRQ triggers? Then I can calculate/estimate when it's time to send values to controller.

    mfalkviddM 1 Reply Last reply
    0
    • gohanG Offline
      gohanG Offline
      gohan
      Mod
      wrote on last edited by
      #2

      Are you referring when the sensor is wet and not reporting anything?

      1 Reply Last reply
      0
      • karlheinz2000K Offline
        karlheinz2000K Offline
        karlheinz2000
        wrote on last edited by
        #3

        No, I have something like this https://www.mysensors.org/build/rain, but try to get it battery powered.
        It generates a pulse after a certain amount of rain.

        1 Reply Last reply
        0
        • gohanG Offline
          gohanG Offline
          gohan
          Mod
          wrote on last edited by
          #4

          If it is a tipping bucket if you are receiving too many pulses you either have a bucket too small or you really have a storm raging outside 😀

          1 Reply Last reply
          0
          • karlheinz2000K karlheinz2000

            I have a sensor to count events (rain sensor). This sensor uses sleeps mode to save power. Any event triggers an external interrupt to wake up the sensor and increment the counter. After an certain time the sensor should send the counter value to the controller.
            I use int8_t sleep(int interrupt, int mode, unsigned long ms=0); to wake up either from external IRQ or timer. But if many events occure, the timer never triggers (and the sensor does not send values to controller).
            Is it possible to get the elapsed sleep time, when external IRQ triggers? Then I can calculate/estimate when it's time to send values to controller.

            mfalkviddM Offline
            mfalkviddM Offline
            mfalkvidd
            Mod
            wrote on last edited by
            #5

            @karlheinz2000 if you want to know the time elapsed while sleeping you either need a rtc or you need to ask another node (or the controller) about time. See "Fetching time from controller" at https://www.mysensors.org/download/sensor_api_20#requesting-data

            No timers are active during sleep.

            1 Reply Last reply
            0
            • karlheinz2000K Offline
              karlheinz2000K Offline
              karlheinz2000
              wrote on last edited by
              #6

              Is it possible to read ms from

              void hwInternalSleep(unsigned long ms)
              {
              	// Let serial prints finish (debug, log etc)
              #ifndef MY_DISABLED_SERIAL
              	MY_SERIALDEVICE.flush();
              #endif
              	while (!interruptWakeUp() && ms >= 8000) {
              		hwPowerDown(SLEEP_8S);
              		ms -= 8000;
              

              ?
              mySleepTime - ms , should be the elapsed sleep time?!

              mfalkviddM 1 Reply Last reply
              0
              • karlheinz2000K karlheinz2000

                Is it possible to read ms from

                void hwInternalSleep(unsigned long ms)
                {
                	// Let serial prints finish (debug, log etc)
                #ifndef MY_DISABLED_SERIAL
                	MY_SERIALDEVICE.flush();
                #endif
                	while (!interruptWakeUp() && ms >= 8000) {
                		hwPowerDown(SLEEP_8S);
                		ms -= 8000;
                

                ?
                mySleepTime - ms , should be the elapsed sleep time?!

                mfalkviddM Offline
                mfalkviddM Offline
                mfalkvidd
                Mod
                wrote on last edited by mfalkvidd
                #7

                Unfortunately there is no support for getting ms from hwInternalSleep but I guess the function could be modified. I like the idea. It wouldn't be able to account for time spent when woken up by interrupt, but that error would be max 8 seconds (on atmega328) which would be good enough for many applications.

                1 Reply Last reply
                0
                • karlheinz2000K Offline
                  karlheinz2000K Offline
                  karlheinz2000
                  wrote on last edited by
                  #8

                  @mfalkvidd any idea for a (quick and dirty:sunglasses: ) workaround? Just copy ms in hwInternalSleepin some global variable? Or will this not work? I'm more in hardware than software...

                  mfalkviddM 1 Reply Last reply
                  0
                  • karlheinz2000K karlheinz2000

                    @mfalkvidd any idea for a (quick and dirty:sunglasses: ) workaround? Just copy ms in hwInternalSleepin some global variable? Or will this not work? I'm more in hardware than software...

                    mfalkviddM Offline
                    mfalkviddM Offline
                    mfalkvidd
                    Mod
                    wrote on last edited by
                    #9

                    @karlheinz2000 a global variable should work. Quick and dirty :grimacing:
                    Make sure to name it something unique.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    20

                    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