I have an application running on a Boron. It is a datalogger which send data to Particle cloud every minut. Once every day it seems like the Boron is ofline for 10 min. How do I keep the Boron online?
//My Code
void setup()
{
Particle.keepAlive(10 * 60); // send a ping every 10 min.
}
Are you using a 3rd party SIM?
If so, I doubt your provider will give you 10 minutes keep alive, you need to find out what value is acceptable for the provider.
If not, you don’t want to use Particle.keepAlive().
However, we cannot answer this question as you don’t provide any info about the probable cause for the lost connection.
If it’s due to your code, we’d need to see your code.
If it’s bad signal or some other external reason you probably won’t be able to do anything against that in code. You simply cannot have a connection when there is none.
What you can do is making your code resilient against connection losses. The first line of defense would be using SYSTEM_THREAD(ENABLED).
SYSTEM_THREAD(ENABLED)
unsigned long publishTime = millis();
void setup()
{
//Particle.keepAlive(10 * 60); // send a ping every 10 min.
}
void loop()
{
if (millis() - publishTime > 60000) { //Once every min.
Particle.publish("devicedata", "Temperature", PRIVATE);
publishTime = millis();
}
}
I have tried with SYSTEM_THREAD(ENABLED), but that didn’t help. Since a removed keepAlive the offline time is exactly 23 min. When I used keelAlive set to 10 min, the offline time was 10 min. That is why I thought it was something related to keepalive.
If your code regularly produces cloud output (e.g. Particle.publish()) the keep alive logic will not be required and I'd say the 23 minutes may be a mere coincidence with the default keep alive period.
Nope, that flag is fully optional.
Do you see all published events for 23 minutes in console and then nothing after that?
What does the RGB LED do while the connection is "lost"?