-->
Page 1 of 2

maximum sleep / waking up from deep-sleep too early?

PostPosted: Wed Jan 27, 2016 12:48 pm
by vanderbreye
I send my ESP-01 to deepsleep after a request.
Everything works fine, but for sleep-times > 5 Minutes, things get weird:
The ESP wakes up after 7-10 Minutes, although i defined:

Code: Select all ESP.deepSleep(86400000000, WAKE_RF_DEFAULT);
  delay(500);


But it SHOULD sleep for 1 Day (86400*1000*1000)... :(
Could this be a problem of INT/LONG behaviour?

i tried as well
Code: Select all long microDay = 24L * 60L * 60L * 1000L * 1000L;
  ESP.deepSleep(microDay, WAKE_RF_DEFAULT);

but without success.

Is this somehow possible?

Re: maximum sleep / waking up from deep-sleep too early?

PostPosted: Wed Jan 27, 2016 1:21 pm
by WereCatf
The ESP is a 32-bit processor and the maximum value for a 32-bit unsigned integer is 4294967295 or 0xffffffff, or 71 minutes. 86400000000, however, is a lot more than that and when truncated to 32-bits would result in 500654080 or 0x1DD76000, or 8 minutes.

Re: maximum sleep / waking up from deep-sleep too early?

PostPosted: Thu Jan 28, 2016 5:56 am
by vanderbreye
GREAT SCOTT!
Thank you, that's it! ;)
(Imho it's a bad idea to take MICROSECONDS for a deep-sleep function, though...)

Re: maximum sleep / waking up from deep-sleep too early?

PostPosted: Sun Jan 31, 2016 5:46 am
by anythingwithawire
I currently have one that sleeps 30 minutes, but 60 minutes gives an overflow as a compiler error in my sketch, maybe the function value is signed somewhere.