1
votes

does anybody know, if a node.dsleep() function in Lua have an upper limit? I mean the maximal time of sleep. I tried to set it for several minutes and it was with no problem, pretty accurate. But when I need to set it up on 4 hours, it isn't reliable and ESP wakes mostly after 30 minutes.

Thanks for the answers!

Kaki

1

1 Answers

2
votes

This appears to be a firmware limitation.

Per the NodeMCU documentation:

node.dsleep() Enters deep sleep mode, wakes up when timed out.

The maximum sleep time is 4294967295us, ~71 minutes. This is an SDK limitation. Firmware from before 05 Jan 2016 have a maximum sleeptime of ~35 minutes.

This appears to be caused by the limitations of a 32-bit integer. 4294967295 is the maximum number that an unsigned 32-bit integer can store. From the information, we can assume that, prior to the mentioned firmware update, this was originally a signed integer with a maximum 2147483647us sleep time. This translates to 35 minutes and 47.5 seconds.