Electron 3rd-party SIM tips

This is an Excellent write-up! Thanks for this :smiley:

2 Likes

Thanks Rick!

@rickkas7

Thank you Rick for such a nice article. :+1:

Are you planning to make this article as part of Electron Documentation?

Regards
Mahesh

2 Likes

Thank you for a great tutorial. Helped me a lot being new to the platform.

Using both AUTOMATIC mode and SEMI AUTOMATIC mode (to save reconnection data), I have seen that publish also seems to fail quite a bit without sufficiently short keep alive period with 3rd party SIM.

Hi @rickkas7. Ta for the library… I will be using it to test with a 3rd party sim and gain some insight into the quirks of the Cellular calls.

I don’t know if anyone has offered this potential correction, and I’m yet to sort our a github logon to do it via that channel, so you may wish to review the switch statement in function CellularHelperCommonResponse per below:
case TYPE_BUSY:
typeStr = "TYPE_NODIALTONE";
break;
I presume this is an error, but maybe not.

[Edit] Although, I suspect no-one would ever be affected by it, as the M2M sim has no calling capability, of course, so TYPE_BUSY is a non-event (excuse the pun).

Cheers,
Andrew

Yes, TYPE_BUSY is a copy paste error. I’ve corrected it in Github and the next time I update the library in the community libraries it will have the change.

Is there a minimum upload/download speed that the 3rd party SIM must support? For example, I have a GSM mobile SIM with 64 KBps upload speed. Would that work with the Electron (U260 model- 850/1900 MHz) ? Thank you

Hi @rickkas7, thanks for the write-up!

So I’m having the problem of breathing deep blue, then goes into listening mode. Funny thing is that my electron was working properly and all of a sudden it stopped working, I assumed it was the pins holding the sim card, I tried gently pulling them out, put my sim card again and it’s not working.

Any help please?!

If it’s really breathing blue the most likely reason is the code putting the device into that state.

https://docs.particle.io/guide/getting-started/connect
e.g via Cellular.disconnect() or in a non-AUTOMATIC mode not calling Cellular.connect() or Particle.connecct().

Two quick questions. In the US are the MOVISTAR sims for the Electron 3G sitting on the AT&T network? I think yes. Also, from a “fleet of products” management perspective what are we missing if we choose to go with 3rd party sims?

The Electron 3G with the Particle SIM will use either AT&T or T-Mobile.

The main difference is that 3rd-party SIMs are only supported for developer accounts (up to 100 devices) and small product roll-outs (under 100 devices).

If you are rolling out a product at scale, you will have to pay the device cloud fee (US$2.99/month) even if you use a 3rd-party SIM card.

@rickkas7 I am using manual system mode, system thread, and a 3rd party sim, when I call Cellular.connect on first boot, it never connects (flashes green continuously) even though I have STARTUP(cellular_credentials_set(blahblahblah)) AND cellular_credentials_set in the application code, but after one reboot (pressing reboot button or calling System.reset()) it will connect very quickly (if power is removed completely, it will fail on first boot again). Can you think of any reason why this could be? Do I need to get funky with calling Cellular.off/on/connect and cellular_credentials_set in some specific order? It’s been bothering me for weeks and I am completely stumped.

@ColinVT - the short answer is yes, probably.

The people here are helpful, but you probably need to show what you've done, already, rather than expect them to shoot in the dark.

An extract from your code, perhaps, showing what you've tried?

I have a system that runs in the same mode, and 'gets funky' with iterating through the Cellular and Particle calls to establish 'cloud' connection (breathing cyan).

1 Like

On a cold boot it can take some minutes (up to 5) for the modem to connect to the cellular provider. you have to allow for that.

When it is reset, only the microcontroller is reset so the modem remains connected to the provider and therefore connects quickly.

What I was trying to explain was that for instance:
1.) Cold boot device, wait until it is flashing green (attempting to connect to cellular)
2.) Let it blink green for about 5 seconds
3.) Press the reset button
4.) The device will again boot and flash green but now for no more than 10-20 seconds maximum before rapid cyan -> breathing cyan-> normal operation.

However on a cold boot, if you simply let the device run and don’t press reset (or any other type of soft reset), it will flash green for minutes on end before timing out and restarting the connection, after which it will connect quickly as described above. There is clearly a hangup somewhere here because in the above instance where the device is soft rebooted, the modem has only been on for no more than 30-45 seconds, however in the instance where it is cold booted with no soft reset, it will blink green for minutes with no success. I have worked around this for the moment by having an event handler upon the device beginning a connection attempt which will time out after 20 seconds (if the connection successful handler is not triggered) and reboot the device, which has worked just fine (since these devices are rarely cold booted).

Also here is the code I’m currently using to connect, however I didnt paste it originally as I’ve tried many different options and was mainly looking for a known-working example from someone else so that I could rule out the order in which I’m calling these functions as the culprit.
Here is my getConnected function:

int getConnected()
{
  Cellular.on();
  Particle.disconnect();

  DBG_SERIAL_CONSOLE.printlnf("Allowing cell modem to initialize...");
  delay(modemTurnOnDelayTime());

  while (!setupCellCredentials(&cellCredentials)) {
     delay(10);
  };
  delay(100);


  DBG_SERIAL_CONSOLE.println("[Cell]: setting credentials");
  DBG_SERIAL_CONSOLE.println("APN: " + String(cellCredentials.APN_name));
  DBG_SERIAL_CONSOLE.println("user name: " + String(cellCredentials.userName));
  DBG_SERIAL_CONSOLE.println("password: " + String(cellCredentials.passWord));
  DBG_SERIAL_CONSOLE.println("keep alive: " + String(cellCredentials.keepAlive));

  cellular_credentials_set(cellCredentials.APN_name, cellCredentials.userName, cellCredentials.passWord, NULL);

  DBG_SERIAL_CONSOLE.println("Calling Cellular.connect");

  Cellular.connect();

  while (!Cellular.ready()) {
     delay(10);
  };

  delay(100);

  // Connect to cloud. This is necessary because manual mode is turned on.
  DBG_SERIAL_CONSOLE.println("Calling Particle.connect");

  Particle.connect();

  while (!Particle.connected()) {
     delay(10);
  };

  Particle.keepAlive(cellCredentials.keepAlive);

  DBG_SERIAL_CONSOLE.println("[Particle] connected");
}

From watching serial, I can confirm that it does successfully detect the correct sim & settings from the card, even on cold boot.

We’d need to see how things happen chronologically in your code.
Your snippet does not show what SYSTEM_MODE() you are using nor does it show at which point in time you call cellualr_credentials_set()

Sorry, I thought I had already mentioned this, I am using this for setting up of the cell credentials:

However this issue is still present if I completely cut out that portion, and just set the exact cell credentials in STARTUP() as described in the electron's docs. The workaround I have been using is working fine and this is not a priority whatsoever at this point as I've adapted our firmware for use on the Boron and Argon which we will be moving toward in the near future (and I do not have this issue using the same order of functions on the boron). Anyways, the reason I say this is that I don't want people spending time and brainpower helping me with this since it's more of just a minor nuisance to me when other people probably have far more pressing issues (and as it doesn't seem to be impacting anyone else, its likely some wonky thing I'm causing inadvertently).

1 Like

Hi,

I have just added these lines to my code in order to use 3rd party sim card but not successful, is there any thing i can do,

#include "Particle.h"
STARTUP(cellular_credentials_set("goto.virginmobile.uk", "", "", NULL));

void setup()
{
Particle.keepAlive(120);
}

its still flashing green then to listening mode (dark blue) and cannot connect to cloud,

this electron i used was using particle sim card, so its already sat up.

your advice please

thanks

Was that device fully setup before?
If not, try particle usb setup-done

yes its already fully setup