I'm coding for an ESP32 that receives data through MQTT to set its deep sleep time. The problem is that sometimes the ESP32 will not sleep for the requested time. It is fine for smaller times < 1hr, but when asking for > 4hrs it usually sleeps for 5 seconds.
My suspicion is that the ULL multiplication is not yielding the correct result.
Currently, the device receives a String with the number of seconds to deep sleep. I convert the string to ULL using strtoull
. I'm setting the deep sleep time like this:
#define MICRO_SEC_FACTOR (1000000ULL)
uint64_t nap;
nap = strtoull(args[1], NULL, 10);
esp_sleep_enable_timer_wakeup((nap * MICRO_SEC_FACTOR);
Is there a way to ensure that the multiplication will yield the uint64_t that the function expects? I've tried casting but had the same results.