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. What really sleep() do please ?

What really sleep() do please ?

Scheduled Pinned Locked Moved Development
5 Posts 2 Posters 64 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.
  • D Offline
    D Offline
    DenisJ
    wrote on last edited by
    #1

    Hi there all,
    I just finish a simple node using a barebone Atmega328p.
    I program the bootloader MiniCore at 8Mhz internal clock.
    I use a BME280 for temp/humidity and RFM69HC for radio.
    All work great :-)
    78414ba3-313d-4fa0-bd9e-a77072b610d7-image.png

    Now I'm on the software part of sleep.
    I just use Sleep(30000) in order to test it.
    What I receive in the log(parser) is:

    Sleep node, duration 30000 ms, SmartSleep=0, Int1=255, Mode1=255, Int2=255, Mode2=255
    Set transport to sleep
    Node woke-up, reason/IRQ=-1 (-2=not possible, -1=timer, >=0 IRQ)
    Set transport to standby
    Sent Message ...etc...
    

    So I wonder what sleep() do please ? ...it use a watchdog internal timer in order to wake up ?
    I have try to use a "LowPower.h" lib but the compiler give me an error:

    multiple definition of `__vector_6'
    

    ...like already have this piece of code in the MySensor lib.

    So if I understand the watchdog internal timer is the best solution to make sleep all strange thinks inside Atmega328p.
    Is I still understand it can't do it more than 8sec.

    Can anyone please help me to understand ?

    Thanks a lot
    Denis

    YveauxY 1 Reply Last reply
    1
    • D DenisJ

      Hi there all,
      I just finish a simple node using a barebone Atmega328p.
      I program the bootloader MiniCore at 8Mhz internal clock.
      I use a BME280 for temp/humidity and RFM69HC for radio.
      All work great :-)
      78414ba3-313d-4fa0-bd9e-a77072b610d7-image.png

      Now I'm on the software part of sleep.
      I just use Sleep(30000) in order to test it.
      What I receive in the log(parser) is:

      Sleep node, duration 30000 ms, SmartSleep=0, Int1=255, Mode1=255, Int2=255, Mode2=255
      Set transport to sleep
      Node woke-up, reason/IRQ=-1 (-2=not possible, -1=timer, >=0 IRQ)
      Set transport to standby
      Sent Message ...etc...
      

      So I wonder what sleep() do please ? ...it use a watchdog internal timer in order to wake up ?
      I have try to use a "LowPower.h" lib but the compiler give me an error:

      multiple definition of `__vector_6'
      

      ...like already have this piece of code in the MySensor lib.

      So if I understand the watchdog internal timer is the best solution to make sleep all strange thinks inside Atmega328p.
      Is I still understand it can't do it more than 8sec.

      Can anyone please help me to understand ?

      Thanks a lot
      Denis

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

      @DenisJ MySensors implements sleep() for AVR using the watchdog. As you know, the watchdog can only sleep for at most 8 seconds, so long sleeps are divided into smaller watchdog sleeps by MySensors. Sleeping for eg 30 seconds is divided into 3x8 seconds, 1x 4 seconds and 1x2 seconds. This is all done by the library, in the single call to sleep() without you needing to worry about it :muscle:

      http://yveaux.blogspot.nl

      1 Reply Last reply
      1
      • D Offline
        D Offline
        DenisJ
        wrote on last edited by
        #3

        @Yveaux said in What really sleep() do please ?:

        Sleeping for eg 30 seconds is divided into 3x8 seconds, 1x 4 seconds and 1x2 seconds.

        Whoau... this is exact what I was think to do :-)
        But if MySensors is do this in automatic... well it's wonderful :-)

        Do you know ... is do an automatic sleep also for the RFM69 please ?
        Thanks a lot.
        Denis

        YveauxY 1 Reply Last reply
        0
        • D DenisJ

          @Yveaux said in What really sleep() do please ?:

          Sleeping for eg 30 seconds is divided into 3x8 seconds, 1x 4 seconds and 1x2 seconds.

          Whoau... this is exact what I was think to do :-)
          But if MySensors is do this in automatic... well it's wonderful :-)

          Do you know ... is do an automatic sleep also for the RFM69 please ?
          Thanks a lot.
          Denis

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

          @DenisJ yes, it does not depend on the radio, but on the arduino platform

          http://yveaux.blogspot.nl

          1 Reply Last reply
          1
          • D Offline
            D Offline
            DenisJ
            wrote on last edited by
            #5

            Ok great :-)
            Thanks a lot again
            Denis

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


            18

            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