Adaptive sleep time
-
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
-
@gohan At first approach, I would say the map function should be the way to go.. what is it that it's working weird?
-
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.
-
@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.
-
@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 }
-
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
-
@gohan so it's actually you who needs a set sleep time based on energy levels?
Suggested Topics
-
Arduino Celebrates 10 years (Malmö/Sweden)
Announcements • 29 Mar 2014, 17:08 • hek 29 Mar 2014, 17:08 -
MQTT-Help me understand about the MQTT Gateway.
Development • 29 days ago • dpcons 18 days ago -
Home Assistant/MySensors quirks
Development • 14 days ago • OldSurferDude 14 days ago -
Saving last known good state, but not in EEPROM
Development • 30 Jan 2024, 18:46 • OldSurferDude 15 Jan 2025, 08:51 -
Radio waking up for no reason.
Development • 4 Jul 2020, 21:09 • Sasquatch 15 Jan 2025, 08:33 -
Counting Incoming and Outgoing Messages from a Gateway
Development • 10 Dec 2024, 21:57 • Trand 14 Dec 2024, 20:23