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 sleep the Arduino but still have it respond to the Vera?

How to sleep the Arduino but still have it respond to the Vera?

Scheduled Pinned Locked Moved Troubleshooting
23 Posts 6 Posters 13.0k 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.
  • T Offline
    T Offline
    twosh
    wrote on last edited by
    #13

    Earlier I tried using gw.sleep(2, CHANGE, 1000); but that didn't work then. Should I use it another way? And how do I make sure I listen for interrupts on both the D2 and D3 pins?

    1 Reply Last reply
    0
    • BulldogLowellB Offline
      BulldogLowellB Offline
      BulldogLowell
      Contest Winner
      wrote on last edited by
      #14
      attachInterrupt( )
      

      attachInterrupt( )

      1 Reply Last reply
      0
      • marceltrapmanM Offline
        marceltrapmanM Offline
        marceltrapman
        Mod
        wrote on last edited by
        #15

        @BulldogLowell Isn't that the part that the MySensors libs (should) take care of?

        Fulltime Servoy Developer
        Parttime Moderator MySensors board

        I use Domoticz as controller for Z-Wave and MySensors (previously Indigo and OpenHAB).
        I have a FABtotum to print cases.

        BulldogLowellB 1 Reply Last reply
        0
        • marceltrapmanM marceltrapman

          @BulldogLowell Isn't that the part that the MySensors libs (should) take care of?

          BulldogLowellB Offline
          BulldogLowellB Offline
          BulldogLowell
          Contest Winner
          wrote on last edited by
          #16

          @marceltrapman said:

          @BulldogLowell Isn't that the part that the MySensors libs (should) take care of?

          Good point.

          Does gw.sleep( ) accept both interrupts?

          1 Reply Last reply
          0
          • hekH Offline
            hekH Offline
            hek
            Admin
            wrote on last edited by
            #17

            I see now that documentation is lacking the dual external pin sleep function (metal note). You'll find it in MySensors.h.

            1 Reply Last reply
            1
            • T Offline
              T Offline
              twosh
              wrote on last edited by
              #18

              Hi @hek and thanks for the info!

              However, I'm not sure that I find anything regarding listening for both D2 and D3-pins in MySensors.h, I only find:

              */**
              	 * Sleep (PowerDownMode) the Arduino and radio. Wake up on timer or pin change.
              	 * See: http://arduino.cc/en/Reference/attachInterrupt for details on modes and which pin
              	 * is assigned to what interrupt. On Nano/Pro Mini: 0=Pin2, 1=Pin3
              	 * @param interrupt Interrupt that should trigger the wakeup
              	 * @param mode RISING, FALLING, CHANGE
              	 * @param ms Number of milliseconds to sleep or 0 to sleep forever
              	 * @return true if wake up was triggered by pin change and false means timer woke it up.
              	 */
              	bool sleep(int interrupt, int mode, unsigned long ms=0);
              

              Which is the same as the documentation, right?

              1 Reply Last reply
              0
              • hekH Offline
                hekH Offline
                hek
                Admin
                wrote on last edited by
                #19

                https://github.com/mysensors/Arduino/blob/master/libraries/MySensors/MySensor.h#L244

                1 Reply Last reply
                1
                • T Offline
                  T Offline
                  twosh
                  wrote on last edited by twosh
                  #20

                  Ah, there it is! I was looking at his:
                  https://github.com/mysensors/CodeBender/blob/master/MySensor.h

                  Big thanks @hek ! I'll try this when I get home!

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    twosh
                    wrote on last edited by
                    #21

                    Hi again!

                    I've tried different approaches now with the gw.sleep(); func without success, using CHANGE, RISING or FALLING. No reaction either from tag or the Vera.

                        // Wait for card/tag to leave reader    
                        while(nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &key[0], &currentKeyLength)); 
                        // gw.sleep(2000);
                      }
                      gw.sleep(0, CHANGE, 1, CHANGE, 0); // int8_t sleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2, unsigned long ms=0);
                    }
                    

                    I've also tried adding this to setup();

                      interrupts();
                    

                    as well as this:

                      attachInterrupt(0, loop, CHANGE);
                      attachInterrupt(1, loop, CHANGE);
                    

                    Nothing happens. It just continues to sleep...

                    1 Reply Last reply
                    0
                    • YveauxY Offline
                      YveauxY Offline
                      Yveaux
                      Mod
                      wrote on last edited by
                      #22

                      According to the ATMega's datasheet only a Low-LEVEL interrupt can reliably wake the ATMega from sleep. See also http://forum.mysensors.org/topic/250/how-do-i-use-the-interrupt/5

                      http://yveaux.blogspot.nl

                      1 Reply Last reply
                      1
                      • T Offline
                        T Offline
                        twosh
                        wrote on last edited by
                        #23

                        I'm back to choosing between no sleep, and the sleep(); function posted above. I can't get gw.sleep(); to work with either one or two interrupts, with or without declaring interrupts(); and/or attachInterrupt();.

                        I'm ready to try more stuff if anyone got any ideas, but with my own limited understanding of both hardware in general and arduino in particular it feels like I'm running on fumes here. :o

                        Thanks everyone for your contribution, and @hek - you've done a great job with MySensors! :clap:

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


                        22

                        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