Delay caused by

I’m currently using a command to send a variable to Ubidots in the middle of my loop. It’s working, but it seems to introduce a delay of roughly 500 ms each time it’s called. Using something like Particle.publish() does not seem to slow things down at all.

Is the delay occurring as the photon is waiting for a response? Is there a way of ignoring the response or otherwise eliminating the delay?

Happy to provide code details if this doesn’t end up being a basic answer.

For reference, this is the loop I’m running to measure the delay.

void loop() {

t1 = millis();

// send duration
request.body = "{\"value\":" + String(del) + "}";
request.path = "/api/v1.6/variables/56a445d376254238f60809eb/values?token="TOKEN;, response, headers);

t2 = millis();
del = t2-t1;

And here’s the ubidots result:

It’s averaging around 488ms/loops, with occasional spikes.

The Request function (used in POST and GET) has a 200ms delay intentionally built in to wait for server response. You can use #define LOGGING and watch the serial output of the HttpClient lib which includes response time tracking etc. It might prove helpful in locating where the delay is being built.