LinkIt ONE - Long delay(); issue

Hello there,

I have an issue with LinkIt ONE. Look at the code below:

// Time intervals
#define API_DATA_INT 10000

// Define variables
LWiFiClient c;
int request_start = 0;

void setup()
   // ...some code...

void loop()
  request_start = millis();
  int request_delay = ((request_start + API_DATA_INT) - millis());
  while(request_delay > 0)
    if(request_delay < 1000) {
    } else {
    request_delay = request_delay - 1000;

The idea of the code is to print the battery level every ten seconds. First I tried to execute:


But I realized that this does not work. That’s why I decided to split the interval of 10000 milliseconds into 10 delays of 1000 milliseconds each. I ran the code and it worked very well for the first 15 to 20 iterations and it suddenly stopped. Seven to eight minutes later the device started again. After about 15-20 and sometimes more iterations, the devices stops and after about 7-8 minutes it starts again. This behaviour continues until the battery is completely exhausted.

So, my questions are:

(1) Why do we have such behaviour? I don’t find any logical explanation.
(2) How can we have a delay of 10000 milliseconds without such interruption of 7-8 minutes?


Could you please try using delayMicroseconds() API instead of delay.

As per the following information – "The delay() is using a scheduling system inside the framework, which is based on the tick scheduler. Each tick is 4.615ms. Therefore, the delay() has a lower precision. "

Thanks and Warm Regards.