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. Adaptive sleep time

Adaptive sleep time

Scheduled Pinned Locked Moved Development
7 Posts 4 Posters 1.3k Views 4 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.
  • gohanG Offline
    gohanG Offline
    gohan
    Mod
    wrote on last edited by
    #1

    I am looking into a way to proportionally increase the sleep time as the voltage of the battery/supercap decreases. I have tried with map function but I think I messed up and getting weird results. I am looking for suggestions to make something flexible that can be set to a minimum sleep time and a max. At the moment a made something that works in fixed steps but it is not very elegant nor very flexible

    M 1 Reply Last reply
    0
    • gohanG gohan

      I am looking into a way to proportionally increase the sleep time as the voltage of the battery/supercap decreases. I have tried with map function but I think I messed up and getting weird results. I am looking for suggestions to make something flexible that can be set to a minimum sleep time and a max. At the moment a made something that works in fixed steps but it is not very elegant nor very flexible

      M Offline
      M Offline
      manutremo
      wrote on last edited by
      #2

      @gohan At first approach, I would say the map function should be the way to go.. what is it that it's working weird?

      gohanG 1 Reply Last reply
      1
      • raptorjrR Offline
        raptorjrR Offline
        raptorjr
        wrote on last edited by
        #3

        Would it be possible to divide the sleeptime with the voltage? As the voltage is getting lower the sleeptime will be higher?

        Start with a number that after dividing sems good. Then it will automatically increase when voltage decrease.

        1 Reply Last reply
        0
        • M manutremo

          @gohan At first approach, I would say the map function should be the way to go.. what is it that it's working weird?

          gohanG Offline
          gohanG Offline
          gohan
          Mod
          wrote on last edited by
          #4

          @manutremo I don't have the code with me, but if you are kind enough could you post a map function that you think could work.

          M 1 Reply Last reply
          0
          • gohanG gohan

            @manutremo I don't have the code with me, but if you are kind enough could you post a map function that you think could work.

            M Offline
            M Offline
            manutremo
            wrote on last edited by manutremo
            #5

            @gohan If I understood correctly what you are trying to achieve, do you think this could work?

            #define VOLT_MAX 3.7
            #define VOLT_MIN 3.0
            #define SLEEP_MAX 100000
            #define SLEEP_MIN 10000
            
            void setup() {
              // put your setup code here, to run once:
            
            }
            
            void loop() {
              // put your main code here, to run repeatedly:
            
            float v,p,s;
            
            v=3.5;          // Result from volt reading routine
            
            p=(v-VOLT_MIN)/(VOLT_MAX-VOLT_MIN);
            
            p=constrain(p, 0, 100);
            
            s=map(p, 0, 100, SLEEP_MAX, SLEEP_MIN);
            
            sleep (s, true);             // true for smartsleep, false if otherwise
            }
            
            1 Reply Last reply
            1
            • gohanG Offline
              gohanG Offline
              gohan
              Mod
              wrote on last edited by
              #6

              Thanks a lot, I'll look at it in the next days. Today I woke up at 5 am and returned home at 8pm... My neurons are not very cooperative at the moment 😅

              mfalkviddM 1 Reply Last reply
              0
              • gohanG gohan

                Thanks a lot, I'll look at it in the next days. Today I woke up at 5 am and returned home at 8pm... My neurons are not very cooperative at the moment 😅

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

                @gohan so it's actually you who needs a set sleep time based on energy levels? ;-)

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


                19

                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