I’m having an issue where after some time (seems to be randomly between few minutes to hours) my Electron loses cell connectivity, and does not reconnect. I’m a bit at a loss on where to begin debugging this issue, let alone to know what code to share with you all.
Here are some basic questions:
- What SYSTEM_MODE are you running? and is SYSTEM_THREAD enabled?
- Are you using delay() in your code at all?
- What code are you using to control cloud connectivity (if any) and what kind of safeguards have you implemented to prevent cloud operations when the connection drops?
Usually, you want to post your full code or if using WebIDE you can do a “Share this revision” and post the link here. If too large, you can post the relevant code that covers the questions above.
Thanks @ninjatill. My code is quite large, but here’s what I think are the relevant answers and snippets.
SYSTEM_MODE(MANUAL);
SYSTEM_THREAD(ENABLED);
-
No delay()'s
void setup()
{
Particle.connect();
}
void loop()
{
Particle.process();
}
I’m actually using Azure for cloud connectivity, but I connect to particle for SW updates. This all started because I’m dropping my MQTT connection to Azure, but I’m finding that it seems to be due to losing all cellular connectivity. All of my attempts to communicate via any cloud connection are wrapped:
if( Particle.connected() )
{
// do some stuff
}
Since I’m using MANUAL mode, do I need to call Particle.connect() if Particle.connected() ever returns false?
If setup()
is the only time you are calling Particle.connect(), then I would probably switch to SYSTEM_MODE(SEMI_AUTOMATIC)
. Semi-automatic will handle any reconnection attempts automatically. You still call Particle.connect()
in setup()
like you already are.
Unless there's a lot more to your loop()
, Particle.process();
is not necessary as it automatically gets called in between iterations of loop()
. You would typically call Particle.process()
inside of long running loop structures or wait points in your code.
Thanks @ninjatill I will try updating the SYSTEM_MODE as you suggested. Agreed on the calls to Particle.process(), I only added that recently while trying to debug this issue.
Even if this allows me to reconnect automatically, any thoughts on how I can determine why I’m losing connection in the first place? I realize the connection isn’t guaranteed, but when I lose connection, I’m not moving or changing the antenna or anything, and my signal strength and everything look good leading up to the loss of connection. I’m suspicious something else is still going on here.
When running with SYSTEM_THREAD(ENABLED)
both SYSTEM_MODE(MANUAL)
and SYSTEM_MODE(SEMI_AUTOMATIC)
are identical. No need to call Particle.process()
for manual mode when threading.
Likewise, they only affect default startup state. Once Particle.connect()
is called they are also equivalent to SYSTEM_MODE(AUTOMATIC)
.
What Sim card, Particle or 3rd party? Do you have decent signal strength? You could take and log rssi readings beyond just using the diagnostics view on the console.
Currently using the Particle SIM card.
I added RSSI and some other debug info - will see if that leads to anything.
Another thought, you can flash @rickkas7’s electron cloud debug code for better diagnostics of why the cloud is dropping:
I seem to have fixed the problem. I am connecting to both the Particle cloud (for OTA) and to Azure (for my project). I haven’t bothered to try to debug the root cause, but it seems these two connections don’t play nice together.
Hey @jdizzle - I’m wondering if you have fully resolved this? I am also seeing some on-and-off connectivity issues but have not had my hands on a device to do further diagnosis. I found another recent thread w/ similar issues Cellular network warning outdated session data. We are working w/ support but am wondering if others in the community are still seeing problems / making others aware they are not the only ones seeing what might be a similar issue. Our devices had been running steadily for some time and recently started experiencing connectivity problems / showing ‘Outdated Session Data’ on console.