Does Cellular.on() block loop execution?

Hi all,

I’m starting a new project and I plan to use sleep mode and only power up cellular to transmit some data every 15 minutes or so, sampling a sensor more frequently in between and storing values to be transmitted later in RAM. As such I plan to use the Cellular.on() and functions as part of my loop process every 15 minutes.

What I’m worried about is this statement from the docs:

When turning on the Cellular module, it will go through a full re-connect to the Cellular network which will take anywhere from 30 to 60 seconds in most situations.

It’s not clear to me whether that 30 to 60 seconds halts the execution of loop. I hope it doesn’t and that my code can carry on, expecting that eventually Cellular.ready() will return true and I can, at that point, transmit my accumulated data and do Is that how it works as of 0.6.0?

@vicatcu, make sure to specify SYSTEM_THREAD(ENABLED) so the user code runs in its own thread.

Thanks @peekay123, I can confirm for anyone else who might be wondering, that this sort of thing works, insofar as millis() gets printed without interruption every 500ms while the RGB LED indicates going through the connection process.


unsigned long previousMillis = 0;        // will store last time LED was updated
const long interval = 60000;           // interval at which to blink (milliseconds)

void setup(void){
  Serial.println("Hello World!");;

bool cellular_connected = false;
bool expected_cellular_connected = true;

void loop(void){
  unsigned long currentMillis = millis();
  cellular_connected = Cellular.ready();

  if(cellular_connected == expected_cellular_connected){
      Serial.println("Notification that Cellular is Connected, Turning Cellular Off");;
      expected_cellular_connected = false;
      Serial.println("Notification that Cellular is not Connected");
      expected_cellular_connected = true;

  if (currentMillis - previousMillis >= interval) {
    // save the last time you blinked the LED
      Serial.println("Turning Cellular On.");
      previousMillis = currentMillis;


However, once this code was loaded, I needed to put the Electron into safe mode in order to re-flash it successfully over USB, otherwise I would always get “expected_cellular_connected = false” in response to “particle compile electron .” even though the blue light is blinking.