How to set 3rd party credentials for the Cellular network? [SOLVED]

I see that you have a solution:
https://docs.particle.io/reference/firmware/electron/#setcredentials-
Whether this solution can be used with WebIDE? If once when you configure whether you can program Online?

1 Like

There is kind of a chicken and egg situation there… but it can work.

If you use the Particle SIM first, you can connect to the Web IDE and create your 3rd Party APN app.

When you flash that to your Electron it will reset and boot back up and still connect. This is because even though you have changed the APN, it will not be used by the modem until you force the modem to power cycle. We leave the modem powered up through OTA resets to make reconnecting faster.

So either disconnect all power, and re-apply. Or you can double-tap the MODE button for Soft Power Down which turns off the modem and STM32F205 microcontroller. Then press RESET to power it back up.

After power cycling you should see that the modem will not get past blinking GREEN as it tries to connect to the tower with your new 3rd Party APN, while you still have the Particle SIM installed. You can swap SIMs and simple press RESET now to connect using your new APN credentials. Make sure to keep this line of code in all future apps.


To program your 3rd party credentials offline, you can use the instructions posted in the Docs: https://docs.particle.io/reference/firmware/electron/#setcredentials-


Yet another way to setup your electron offline is through the official Setup process. When you enter your 3rd Party SIM, you will be presented with a nice tool that will allow you to add your APN, and it gives you back a compiled binary. Then you use the Particle CLI to flash this to your Electron over USB.

https://setup.particle.io/

5 Likes

Excellent answer, this is what I needed :slight_smile:
Whether the latest type with https://setup.particle.io/ is already active?

2 Likes

I have a 3rd party Sim and used the setup described above and created a custom binary file and flashed to my device. It works flawlessly and connects and can be reset from the button but if I remove USB power and unhook the battery, then when I reapply power it just blinks green forever until I reflash the firmware binary again. Any help would be appreciated.

AFAIK 0.4.8 had this issue that the settings were not persisted in flash and so you’d need to add something like this to every app you intend to run with that SIM

#include "cellular_hal.h"
STARTUP(cellular_credentials_set("broadband", "", "", NULL));

But exactly this has been discussed in the previous posts in this very thread (even with a link to the docs)
https://docs.particle.io/reference/firmware/electron/#setcredentials-

I’m not sure if this is already fixed in 0.5.0 - you can try the beta v0.5.0-rc.1

My mistake, I read through that but I was under the impression that if I downloaded the custom binary file then that was not necessary. I thought it was an either or situation. Interesting side note it worked without me using #include "cellular-hal.h and just used STARTUP(cellular_credentials_set(“broadband”, “”, “”, NULL)); Thanks for the help. Much appreciated.

1 Like

I started using the particle sim then switched to an ATT sim, after a lot of trial and error i got the sim working and could trigger the pin 7 led and such. after power cycle it seems to have forgotten the credentials. this was with 5.1 and offline serial firmware upgrade. now all i get is the flashing green. Im going to try and update the firmware again and add the:

#include "cellular_hal.h"
STARTUP(cellular_credentials_set("broadband", "", "", NULL));

interesting that @slimfetz did not need to do this…

cellular_credentials_set does not save the value in configuration flash. It must be in every program that you flash to your Electron that uses a 3rd party SIM.
The confusing part is that it’s written to RAM in the UBLOX module, so it will persist through flashing your own code as long as you don’t power down the Electron entirely. But it’s really not saved and the line should always be present.

I did not need the #include "cellular_hal.h"
You do however absolutely need the STARTUP(cellular_credentials_set(“broadband”, “”, “”, NULL));
Without this it will never work with a power cycle. This line of code is needed at the top of every new program you write.

thanks @Slimfetz, I will remove the #include bit. i have it working but will only flash OTA once after the serial firmware flash. It seems to ignore any subsequent OTA flashes. Maybe its my code or the #include "cellular…

I also have found mine will not flash OTA unless it is within like 30 seconds of pressing the reset button. If mine sits for hours or days and I try OTA it will not work. If I reset and as soon as it is breathing blue try it then it will work. Not sure why

You may need to adjust the cellular keep alive times for 3rd party SIM cards. With the Particle SIM it is 23 minutes, but with other carriers it can be as low as 30 seconds. Usually it’s somewhere in between, typically a couple of minutes.

You just need to call Particle.keepAlive(), typically during setup(). The setting is not saved, so you need to include it in any program you write, along with the APN setting. The value is the number of seconds between keep alive pings. Each ping uses 121 bytes of data.

Particle.keepAlive(300);

https://docs.particle.io/reference/firmware/electron/#particle-keepalive-

The reason OTA flash will fail is that the cellular network is shutting down the incoming UDP port to the Electron, thereby preventing traffic from the cloud to the Electron, such as the OTA flash request, from working after the port is closed.

1 Like

Thank you @slimfetz and @rickkas7, i dumped most of my code and started fresh with your suggestions and things are working now. I think since my code applied math to channels currently without inputs it was crunching really small numbers for temp, humidity, pressures,voltages and the like tying up all the resources. Honestly i was hoping for a more straightforward transition from photon to electron but its been anything but. I appreciate everyone’s input, happy to be moving forward with a cellular platform with a 20GB cap as opposed to 10MB. It has its place but while developing its difficult to keep usage that low, thankfully we are working with open source hardware and a community of helpful enthusiasts!

1 Like

My problem with the web based setup (https://setup.particle.io/) is, that my 3rd party SIMs ICCID is only 10 numbers long. The “continue” button never gets enabled. Is there a way to set up my new electron without having to use the supplied SIM card/insert my credit card information?

1 Like

If you are using a 3rd party SIM, and it has been activated, yes, you can set up an Electron without using the setup.particle.io web site.

You need to find out the APN for your 3rd party SIM card mobile provider (and possibly your country).

Then you need a program that sets the APN for your 3rd party SIM card using cellular_credentials_set.

https://docs.particle.io/reference/firmware/electron/#setcredentials-

Using the [source to Tinker] (https://docs.particle.io/guide/getting-started/examples/electron/#tinker) is a good idea. Add the cellular_credentials_set call and you will need to compile this and flash it via USB, since you’re not online yet and can’t flash OTA.

Now the Electron should be breathing cyan.

Hold down the MODE button until it blinks blue, then issue the CLI command:

particle identify

Save the device ID that is returned; you will need that in the next step.

Reset the Electron and wait for it to breathe cyan again. Then issue the command:

particle device add YOUR_DEVICE_ID

Now the Electron should be associated with your account and you should be online!

Since you’re using a 3rd party SIM card, you will probably also need to use Particle.keepAlive(), as well.

https://docs.particle.io/reference/firmware/electron/#particle-keepalive-

Thanks for your (very) quick reply. Coming from photon I wasn’t aware that you could flash an electron without it being claimed for your account first.
In the end the only thing I really needed was the particle identify command, which showed me the complete ICCID. My provider truncated the number printed on the card for some reason.

2 Likes

You can also flash a Photon before being claimed.

1 Like

I was not aware. Can you point me towards the documentation where this is explained?

That’s not explicitily documented, but since the claiming only connects your device to your cloud account, non-cloud connected features (like usb flashing) will work as they don’t use the cloud account.

Hello.

I’m having trouble setting up my electron with 3rd party sim card. I’ve followed the instructions, disabled PIN, set the APN and tried different keepalive values down to 5 seconds but my electron won’t connect. It mostly blinks green but every once in a while it will breathe cyan for about a second (two blinks) then go back to blinking green.

Here’s the code:

// Connects to a cellular network by APN only
#include "cellular_hal.h"
STARTUP(cellular_credentials_set("internet", "", "", NULL));

void setup() {
  pinMode(D7, OUTPUT);
  Particle.keepAlive(300);
}

void loop() {
  digitalWrite(D7, HIGH);
  delay(500);
  digitalWrite(D7, LOW);
  delay(500);
}

Any ideas what’s wrong?

BTW, though the code is supposed to blink the D7 led it never does that.

EDIT: Is there a way to enable serial debugging to see what’s going on under the hood?
EDIT2: Couldn’t stand it anymore and paid for particle’s SIM so nvm.