Asynchronous operation of the GSM class methods allows to run the task of connecting to the GSM infrastructure concurrently to the main job of your application. It means that your application does not block while actively waiting for the modem to answer etc. In order to do so, the application would trigger the begin() function in asynchronous mode so that it returns straight away. Now the application has to call the ready() function regularly that gives the GSM class processing time to handle the connection-process in the background. Its return value let the user application know if the task is finished and if it was successful or not. See the code below as an example how a asynchronous gsm.begin() process could be implemented. The status() method returns the current operation step the gsm-object is working on (e.g. ERROR, IDLE, CONNECTING, GSM_READY etc.)


gsm.begin(“PIN”, true, false);


“PIN” stands for the character array holding the SIM PIN number e.g. “1234”
true – the 2nd parameter decides to restart the modem (as described here)
false – the 3rd parameter starts the begin function in asynchronous mode (as described here)


begin() returns:
ERROR – in case of problems with the modem communication.

ready() returns:
0 – the process is still running
1– OK. Process was successfully finished
2– ERROR. Process could not be completed because an error occurred.

status() returns:
IDLE – modem process is idle
ERROR – an error occurred during the latest modem process (e.g. begin() operation failed)
GSM_READY – modem was successfully started and is registered in the GSM network
CONNECTING – modem is currently trying to register with the GSM network
GSM_OFF -modem is off.

Example Code

This example shows how to start the GSM connection process, attaching to the GSM infrastructure in an asynchronous way.

#include <DICENB.h>
GSM gsm;

void setup()
  gsm.begin("", true, false); // begin() in async mode
  // ready() does the modem begin() task in the background
  // so call it regularly until it returns != 0.
  while(gsm.ready() == 0) {
    // do other app things (async)
  if(gsm.ready() == 2)
    Serial.println("GSM initialised");

void loop()
  // once connected do something interesting

Notes and Warnings

See also