Daniel
Daniel

Reputation: 3

MicroPython typical sleep times in while loops for ESP32-S3

Another question from my side. This time it is a little more hardware related. I asked myself why the sleep times within while loops in many examples are set to 0.1s. For this is quite a long time. Typically, the task runtimes in the ECUs I work with are 1 ms, 2 ms, 5 ms, and so on.... As the ESP has a 32-bit CPU running at 240 MHz this should also be also possible, I think. Is this about power consumption, or cooling or misused as debouncing? I don't get the point of why many applications are running so "slow". Do you have an answer?

Upvotes: 0

Views: 59

Answers (1)

Jon Nordby
Jon Nordby

Reputation: 6289

It is not really possible to answer why some unspecified code has used a particular value for their sleep calls. Use whatever value you see fit for your application. There is nothing really particular to MicroPython in this regard.

The primary case where a high sleep value is desirable is when using light/deep-sleep, to maximize power saving. And there are also minimum wakeup times, it may not be possible to deepsleep for shorter than 1 ms periods (this is hardware dependent).

Upvotes: 0

Related Questions