I have a program that is running on a Photon. I noticed that the Photon loses connectivity for 1 second. It is intermittent but noticeable. Generally speaking, it reconnects back in about 1 second.
What may be causing that? Any input to help resolve this problem is appreciated.
Sorry for that, but we have answered this kind of question already hundreds of times with all sorts of possible reasons, but if you show your code we might spot the one reason that applies to your issue and saves us the extra reiteration of all the non-issues.
Any code that keeps the flow trapped (e.g. loops) and doesn't call Particle.process() or delay() (which implicitly calls Particle.process()) - among others.
With your input from the previous message, I found out why the Photon was losing connectivity and recycling.
The reason is that I am using the Thingspeak library (writeFields) function and was using this function with small intervals (I found out that Thingspeak likes updates to be more than 15 seconds apart).
However, in my application, I receive data from a sensor at uncontrolled intervals (depending on the Environment). So is there an example that shows how I can queue the .writeField statements to give Thingspeak a chance to accept them?
In a different application that did not use Thingspeak (just Particle.Publish), I used the PublishQueue library. However, in this case, I am not sure what to do.
I would appreciate any help in that regard and thanks in advance.
I haven’t got an off the shelf solution, but if you look at the implementation of the Particle.publish() queue you could reuse that code to implement your own Thingspeak queue.
Or maybe @thingspeak can chime in on this.
There are a few examples in the ThingSpeak documentation that show how to collect several samples in a buffer and then post them all as a bulk update. You can bulk update about every 15 seconds with multiple messages. Here is an example for a particle photon. For your application, you can asynchronously store your updates and then send the bulk update request when your buffer gets to a certain length.