Cellular.command() always returns -1 on electron

Hi everybody,
I’ve been trying to use Cellular.command() to fetch the cellular location. The ublox chips on the electron have a nifty feature called CellLocate, which can return an approximate GPS location using triangulation.
Unfortunately, all my calls to Cellular.command() return -1 (timeout).

I followed the documentation example. My code is very simple:

int callbackULOCCELL(int type, const char* buf, int len, char* response) {
    sprintf(response, "ULOCCELL response: %s", buf);
    return WAIT;
loop() {
    char response[1024] = "";
    int code = Cellular.command(callbackULOCCELL, response, 10000, "AT+ULOCCELL?\r\n");

Any help would be appreciated.



I tried many different variations of the ULOCCELL but could never get it to work in Michigan, USA :cry:

This is my thread with uBlox support for your reference.

Ah, so it’s not just me :confused:
Are you using an electron 2G or 3G?
I’ll keep tinkering more…

I used the 3G for the ULOCCELL. I have a 2G but I haven’t tried with it.

@jvanier I recreated the weirdness you saw, Spain lat/lng and all. So its not only a MI problem. In the uBlox thread, the rmcn guy mentioned:

I would check with the device manufacturer if any factory default settings are changed that may affect the ability to use this feature

Any ideas on this one?

Not really, no. As ublox did not mention which settings might affect this feature I don’t think Particle will be able to tell if they changed them…

OK, I just tried the example given in the doc (https://docs.particle.io/reference/firmware/electron/#command-) and it doesn’t work either…

“SIM ICCID NOT FOUND!” is what I get.

I also tried a number of simple commands: none of them work.

That API doesn’t seem to work at all.

Any updates on the Cellular.command? Getting the ICCID and being able to access the AT commands in general for sending sms messages or other stuff should be basic functionality?


I think the particle SIM is only provisioned to connect to the particle servers. Hence we can’t reach the ublox cell locate servers. These will have an algorithm to estimate location using cell signal strength.

The same behavior happened with a different SIM so I don’t think the Particle SIM is to blame.

Hmmm. Maybe, but that seems like a silly limitation, especially in light of the built-in TCP and UDP classes that support connectivity to anywhere. Or does any of that traffic flow through the Particle servers before it goes to its real destination? If so, that seems terribly inefficient, not to mention adding an extra failure point to the network path.

It’s a possibility, but as I mentioned none of the “AT+” modem commands I tried work, including simple one to get the chips info (AT+GMI, AT+GMM).

Maybe something in the low-level firmware is locking the chip or the modem, and causes the commands to timeout?


1 Like

ICCID code works for me, but while I can call ULOC / ULOCCELL and get an ‘OK’ (-2) reply, i never get a URC with the actual location information in :frowning:

edit: Enabling a debug firmware shows that the UULOC URC is actually returned, but at least a couple of seconds after the call to Cellular.command() returns with OK.

Looks like maybe support for UULOC needs to be put into mdm_hal.cpp?

edit 2: In fact, hacking another entry into MDMParser::waitFinalResp does work to pick up the UULOC URC but I have no idea what to do with it at that point to get the info back to my app :smiley:

Hey All, just wanted to let you know to come and check out a Cell Locate test app here: Electron Cellular Locate Test App

Official API will be coming… but until then this has been working for me.

1 Like

I know this post is about a year old, but i’ve been on a similar situation.

Cellular must be turned on first if you are on MANUAL or SEMI_AUTOMATIC mode.

Cellular.on(); Must be specified at the start of your setup function.
You must also wait a little bit to the cellular to be turned on.

1 Like

This is amazingly helpful, thanks! I submitted a PR to capture this nuance: https://github.com/particle-iot/docs/pull/761.

or either one of Cellular.connect() or Particle.connect() which implicitly (should for some versions :wink: ) also turn the cellular module on.