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. Bug Reports
  3. sleep(0) in V2.1 doesn't sleep indefinitely anymore. Used to powerdown and sleep in V1.5

sleep(0) in V2.1 doesn't sleep indefinitely anymore. Used to powerdown and sleep in V1.5

Scheduled Pinned Locked Moved Bug Reports
3 Posts 2 Posters 149 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.
  • G Offline
    G Offline
    GaryStofer
    wrote on last edited by
    #1

    For battery powered nodes that need to completely sleep between events sleep(0) could be used in V1.5 in conjunction with the pin change interrupts on portC of an ATmega 328p. It would gracefully power down the radio and then enter the CPU into sleep mode until a pin change event on port C woke it up. In V2.1 sleep(0) simply returns. PortC pin-change mode is needed because INT0 and INT1 only work on either falling or raising level changes but not on either edge at the same time on the 328p .

    I modified the file MyHwAVR.cpp as follows to restore the missing functionality back into V2.1 : Lines 150 and up:

    int8_t hwSleep(unsigned long ms)
    {
    
    
    	if (ms>0) {
    		// sleep for defined time
    		hwInternalSleep(ms);
    		return MY_WAKE_UP_BY_TIMER;
    	} else {  // Fix for missing feature that allowed (in 1.5.1) to use the pin chnage interrupt with a sleep(0) to completely power down the system
    		// sleep until ext interrupt triggered
    		hwPowerDown(SLEEP_FOREVER);
    		return 0;
    	}
    
    
    }
    

    Let me know if this is the correct venue to bring this to the attention of the code maintainers, or if I should go and furnish a git pull request or something like that.

    Or if this has been addressed in post V2.1.1 releases
    Thanks
    gary

    mfalkviddM 1 Reply Last reply
    0
    • G GaryStofer

      For battery powered nodes that need to completely sleep between events sleep(0) could be used in V1.5 in conjunction with the pin change interrupts on portC of an ATmega 328p. It would gracefully power down the radio and then enter the CPU into sleep mode until a pin change event on port C woke it up. In V2.1 sleep(0) simply returns. PortC pin-change mode is needed because INT0 and INT1 only work on either falling or raising level changes but not on either edge at the same time on the 328p .

      I modified the file MyHwAVR.cpp as follows to restore the missing functionality back into V2.1 : Lines 150 and up:

      int8_t hwSleep(unsigned long ms)
      {
      
      
      	if (ms>0) {
      		// sleep for defined time
      		hwInternalSleep(ms);
      		return MY_WAKE_UP_BY_TIMER;
      	} else {  // Fix for missing feature that allowed (in 1.5.1) to use the pin chnage interrupt with a sleep(0) to completely power down the system
      		// sleep until ext interrupt triggered
      		hwPowerDown(SLEEP_FOREVER);
      		return 0;
      	}
      
      
      }
      

      Let me know if this is the correct venue to bring this to the attention of the code maintainers, or if I should go and furnish a git pull request or something like that.

      Or if this has been addressed in post V2.1.1 releases
      Thanks
      gary

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

      Thanks @garystofer

      Looks to me like this was fixed in https://github.com/mysensors/MySensors/pull/1113

      You seem to be using very old code :)

      G 1 Reply Last reply
      0
      • mfalkviddM mfalkvidd

        Thanks @garystofer

        Looks to me like this was fixed in https://github.com/mysensors/MySensors/pull/1113

        You seem to be using very old code :)

        G Offline
        G Offline
        GaryStofer
        wrote on last edited by GaryStofer
        #3

        @mfalkvidd No, the issue with sleep(0) still exists in V2.3.2. That is the version that the ArDuino Library installer installs currently . -- Work around is to call hwPowerDown(WDTO_SLEEP_FOEREVER) as in above code if you want the battery to last more than a day.

        GS

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


        11

        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