Keep Boron online

Hi,

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).

This will help you determine the correct keepalive for your 3rd party sim card: https://github.com/mstan/keep-alive-tester

I am not using a 3rd party SIM, so if I understand you correct there is no reason for using Particle.keepAlive().

My Code is very simple:

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", &rxbuf[0], sizeof(DataPacket),Time.now()), PRIVATE);
    publishTime = millis();
  }
}

I sound like “SYSTEM_THREAD(ENABLED)” can solve my problem, so I will give it a try.

I didn't say that. It might help mitigate some possible reasons for your troubles but not all.
Particularly not questionable coding :wink:

I'm not sure what this is supposed to do

I even doubt this code will compile at all.

And as said, don't use Particle.keepAlive() that way with a Particle SIM.

Sorry for my bad code :frowning: Here is my code again)

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.

I will try and do some more logging.

Could it be related to, that I am not using “WITH_ACK” in my Particle.publish. Is there any timeout here?

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"?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.