-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[deepSleep] Make deepSleep work again with 2.5.0 and refactor delay var #2217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Make deepSleep work again with Core 2.5.0. Changed ESP.deepSleep() to ESP.deepSleepInstant(). Refactor delay variable to dsdelay to avoid conflicts with the delay() function. Added a delay(100) before going to sleep to give the node time to send the last log messages.
added #ifdefs to make build happy also for versions <2.5.0
Maybe you can also add a check for the
Then we can also try to extend the max. deepsleep in ESPeasy's settings to allow longer deepsleep. N.B. in the code we have some kind of flush built in before entering deep sleep: Lines 547 to 560 in 4d2a76a
|
I'll have a look at the The flush does not seem to work for the log which is on line 177 |
OK, so maybe we should "fix" that in |
Allow to specify sleep times up deepSleepMax() on core 2.5.0
Hmm, the core 2.5.0 builds fail with this:
It's a bit harsh, but in this case I can understand it, since the resulting value of |
Of course . Right, sorry... It was too late I guess,, I did not yet review it t thoroughly... Sorry for that.. Will amend it tomorrow! |
Fix type errors of #999e43a and (hopefully) cast all types correctly now.... Keep deep sleep delay below INT_MAX for parameter storage compatibility.
@TD-er wrote:
Basically I agree, but when I understand the code correctly, the So basically if you want to have that in |
Then we should include a timeout there. |
Sure I think it depends on the point of view... If you want to have deepSleep units because they run on battery and save energy you probably don't want to wait too long before shutdown, even if not all logs are done or all clients disconnected. On the other habnd you want to make sure, that at least the values are sent to the controller... seems to be kind of a trade-off here... |
The 'old' limit of 4294 seconds was 2^32 usec. By casting it to an uint32, you may get unexpected results when multiplying it by 10^6 again. So better to use uint64 as variable and work on that one, now the deepsleep functions support uint64.
I just pushed a new commit to it. About the 'trade-off', I am not saying we shouldn't wait. Only try to wait as much as needed to get all buffers flushed and no longer. |
sure, thanks!! I'm jsut compiling and installing now.. will report if it works.. looks more or less the same for me, done a bit differently... except that you allocate a the adding of the max possible value to the web interface I also changed but did not yet commit/push it ;) same thought though... |
The memory usage isn't an issue here, since it is just very local and on the stack too. (allocation on the heap takes time, on the stack doesn't) The main issue why I changed it to do all on the 64-bit value was because of this: ESP.deepSleepInstant((uint32_t)dsdelay * 1000000, WAKE_RF_DEFAULT); In this call, any value of |
great! up to now it seems to run without issues...at least this part... |
OK, so I can merge it? |
from my point of view yes, It compiles also in the Arduino framework and runs on my nodes for about 2 hours now, including deepSleep nodes.. |
@Barracuda09 I was almost certain I did change that one too, but apparently not. |
@TD-er I understand the 32 bit overflow of microseconds that gives uint32_t a maximum of 4294 seconds (or approx 71 minutes). Previously I was wrongly thinking we were able to go to a 64 bit value but I guess it's actually just 33 bits. Does this mean the new maximum sleep is around 8590 seconds (approx 143 minutes)? I am using the new code set at 18000 seconds (5 hours) with the expectation of the ESP8266 waking after 143 minutes. Two hours to wait before I have the results. |
@pieman64 See the links I posted in this reply: #2217 (comment) |
Thanks @TD-er |
I got 3 hours 33 minutes from my first run as shown from the blurb below:
|
The second cycle was broadly similar to the first but slightly shorter at about 3.5 hours. Unfortunately the third cycle failed and after 7 hours the ESP8266 was still sleeping. I have dropped the 18,000 seconds to 12,000, which in theory is 3 hours 20 minutes. Due to the poor time keeping of these devices the first cycle with these settings was timed at 3 hours and 8 minutes. The second cycle was 3 hours and 14 minutes. It has just started the third cycle and I will see if it wakes this time. |
The internal clock is not that accurate. |
Maybe we can extend the time by working with loops like the guys from LowPowerLab do? |
Make deepSleep work again with Core 2.5.0. Changed ESP.deepSleep() to ESP.deepSleepInstant().
Refactor delay variable to dsdelay to avoid conflicts with the delay() function.
Added a delay(100) before going to sleep to give the node time to send the last log messages.