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. Wait function with interrupt

Wait function with interrupt

Scheduled Pinned Locked Moved Development
6 Posts 3 Posters 814 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.
  • SnyfirS Offline
    SnyfirS Offline
    Snyfir
    wrote on last edited by
    #1

    Hello everybody,

    Why there is no function wait() with interrupt like sleep(const uint8_t interrupt, const uint8_t mode, const uint32_t sleepingMS = 0, const bool smartSleep = false) ?

    I can't use sleep because it's a repeater noed.
    Should i use basic interrupt function of arduino ?

    Thank you for your help.

    YveauxY 1 Reply Last reply
    0
    • SnyfirS Snyfir

      Hello everybody,

      Why there is no function wait() with interrupt like sleep(const uint8_t interrupt, const uint8_t mode, const uint32_t sleepingMS = 0, const bool smartSleep = false) ?

      I can't use sleep because it's a repeater noed.
      Should i use basic interrupt function of arduino ?

      Thank you for your help.

      YveauxY Offline
      YveauxY Offline
      Yveaux
      Mod
      wrote on last edited by
      #2

      @snyfir said in Wait function with interrupt:

      Should i use basic interrupt function of arduino ?

      Yes

      MySensors handles interrupts during sleep only to be able to wake up again.
      During wait the node stays awake and can use the regular interrupt mechanism.

      http://yveaux.blogspot.nl

      1 Reply Last reply
      0
      • SnyfirS Offline
        SnyfirS Offline
        Snyfir
        wrote on last edited by
        #3

        I have in the setup() function:

        attachInterrupt(digitalPinToInterrupt(3), keyboardInterrupt, FALLING);
        

        and in the loop() function:

        wait(60000)
        

        The function keyboardInterrupt() is being call when the pin 3 is set to ground but the wait(60000) is not exit. Or i want the programme to sleep (but still receive mesage) until an interrupt append in the pin 3.

        How can i do that ?

        mfalkviddM 1 Reply Last reply
        0
        • SnyfirS Snyfir

          I have in the setup() function:

          attachInterrupt(digitalPinToInterrupt(3), keyboardInterrupt, FALLING);
          

          and in the loop() function:

          wait(60000)
          

          The function keyboardInterrupt() is being call when the pin 3 is set to ground but the wait(60000) is not exit. Or i want the programme to sleep (but still receive mesage) until an interrupt append in the pin 3.

          How can i do that ?

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

          @snyfir there are many ways to do it, maybe the easiest is something like this: in keyboardInterrupt, set a global variable to true, like this:
          interruptOccurred=true

          Change your wait line to something like this:

          for (uint16_t counter=0; counter++;counter<600&&interruptOccurred==false) {
            wait(100);
          }
          if (interruptOccurred) {
            interruptOccurred = false;
            // Do whatever should happen on interrupt here
            ...
          }
          
          
          SnyfirS 1 Reply Last reply
          0
          • mfalkviddM mfalkvidd

            @snyfir there are many ways to do it, maybe the easiest is something like this: in keyboardInterrupt, set a global variable to true, like this:
            interruptOccurred=true

            Change your wait line to something like this:

            for (uint16_t counter=0; counter++;counter<600&&interruptOccurred==false) {
              wait(100);
            }
            if (interruptOccurred) {
              interruptOccurred = false;
              // Do whatever should happen on interrupt here
              ...
            }
            
            
            SnyfirS Offline
            SnyfirS Offline
            Snyfir
            wrote on last edited by
            #5

            @mfalkvidd i am so surprised there is no function in MySensors to put arduino to sleep without disable receipt function of the NRF24L01+ module.

            Before using MySensors i was using Mirf library. I was able to put arduino to sleep and when a new message arrived, with the IRQ pin and interruption it wake up the arduino to deal with the new message arrived.

            It seems not possible to do that with MySensors library.

            mfalkviddM 1 Reply Last reply
            0
            • SnyfirS Snyfir

              @mfalkvidd i am so surprised there is no function in MySensors to put arduino to sleep without disable receipt function of the NRF24L01+ module.

              Before using MySensors i was using Mirf library. I was able to put arduino to sleep and when a new message arrived, with the IRQ pin and interruption it wake up the arduino to deal with the new message arrived.

              It seems not possible to do that with MySensors library.

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

              @snyfir the radio uses so much power in listening mode that sleeping the mcu will not help much. To get low power, the radio must be turned off.

              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