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. Sleep forever without INTERRUPT, how?

Sleep forever without INTERRUPT, how?

Scheduled Pinned Locked Moved Troubleshooting
5 Posts 2 Posters 1.4k 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.
  • F Offline
    F Offline
    flopp
    wrote on last edited by
    #1

    According to Sleeping-section here
    http://www.mysensors.org/download/sensor_api_15#the-full-api

    I need to use this

    bool sleep(int interrupt, int mode, unsigned long ms=0);
    

    if I want to sleep forever
    I tried with out interrupt and mode but if I put 0 as ms it sleeps for 0 ms.

    I can of course use 10000000000000 ms but if there is a function for sleep forever it is much better to use that.

    Why cant I use 0 like this

    void sleep(unsigned long ms);
    

    Anyone know?

    BartEB 1 Reply Last reply
    0
    • F flopp

      According to Sleeping-section here
      http://www.mysensors.org/download/sensor_api_15#the-full-api

      I need to use this

      bool sleep(int interrupt, int mode, unsigned long ms=0);
      

      if I want to sleep forever
      I tried with out interrupt and mode but if I put 0 as ms it sleeps for 0 ms.

      I can of course use 10000000000000 ms but if there is a function for sleep forever it is much better to use that.

      Why cant I use 0 like this

      void sleep(unsigned long ms);
      

      Anyone know?

      BartEB Offline
      BartEB Offline
      BartE
      Contest Winner
      wrote on last edited by
      #2

      @flopp You can use sleep(0, FALLING, 0); and just do not trigger the interrupt pin.

      But why would you wait forever? Can 't you just power off?

      1 Reply Last reply
      0
      • F Offline
        F Offline
        flopp
        wrote on last edited by
        #3

        I am building a sketch like this and as soon as i touch the pin it restarts
        http://forum.mysensors.org/topic/3355/count-car-starts
        And dont want to power off after each start. I SLEEP_TIME to 24 hours

        BartEB 1 Reply Last reply
        0
        • F flopp

          I am building a sketch like this and as soon as i touch the pin it restarts
          http://forum.mysensors.org/topic/3355/count-car-starts
          And dont want to power off after each start. I SLEEP_TIME to 24 hours

          BartEB Offline
          BartEB Offline
          BartE
          Contest Winner
          wrote on last edited by
          #4

          @flopp using while(1) {} will also implement a wait-for-ever but will NOT cause the processor to save battery power but if you do NOT run on batteries this does not matter. The only way to get out this loop is a reset.

          while ( 1 ) { }
          
          F 1 Reply Last reply
          0
          • BartEB BartE

            @flopp using while(1) {} will also implement a wait-for-ever but will NOT cause the processor to save battery power but if you do NOT run on batteries this does not matter. The only way to get out this loop is a reset.

            while ( 1 ) { }
            
            F Offline
            F Offline
            flopp
            wrote on last edited by
            #5

            @BartE
            Thanks that will be very useful in my sketch
            I am not running batteries

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


            25

            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