Receive Voice Call Example

Receive Voice Call Example

This example shows you how to receive voice call using a GSM Shield2.


  • Arduino board
  • Arduino GSM Shield 2
  • Microphone abd speaker
  • SIM card


Arduino GSM Shield mounted on Arduino board 
Mount your GSM Shield 2 on an Arduino board, insert the SIM card into dedicated slot and connect it to your pc using the USB cable.


To using this sketch you must include the"GSM.h" library, and you must indicate the PIN number of your SIM card. 
After you can upload this example in your Arduino board. When the loading is completed you must wait to receive a voice call. 
The sketch uses the "answerCall()" function to initiate the voice connection with the caller . 
Once received the call, it is shown the number caller using the "retrieveCallingNumber()" function, finally the call is terminated using "vcs.hangCall()". 
These function are contained in the "GSM.h" library.

You'll need to attach a speaker and microphone to hear the call and to send your voice.

The complete code and its detailed description are shown down.

Receive Voice Call
This sketch, for the Arduino GSM shield, receives voice calls,
displays the calling number, waits a few seconds then hangs up.
* GSM shield
* Voice circuit. Refer to to the GSM shield getting started guide
* SIM card that can accept voice calls
With no voice circuit the call will connect, but will not send or receive sound
created Mar 2012
by Javier Zorzano
This example is in the public domain.
// Include the GSM library
#include <GSM.h>
// Insert the PIN number of your SIM card, if your SIM hasn't PIN, you can leave it blank :
#define PINNUMBER ""
// Initialize the library instance
GSM gsmAccess;
GSMVoiceCall vcs;
// Array to hold the number for the incoming call
char numtel[20];
void setup()
// Initialize Serial communications and wait for port to open:
while (!Serial) {
  ; // Wait for serial port to connect. Needed for Leonardo only
Serial.println("Receive Voice Call");
// Create a local variable to track the connection status
boolean notConnected = true;
// Start GSM shield
// If your SIM has PIN, pass it as a parameter of begin() in quotes
while (notConnected)
  if (gsmAccess.begin(PINNUMBER) == GSM_READY)
    notConnected = false;
    Serial.println("Not connected");
// This makes sure the modem correctly reports incoming events
Serial.println("Waiting for a call");
void loop()
// Check the status of the voice call
switch (vcs.getvoiceCallStatus())
  case IDLE_CALL: // Nothing is happening
  case RECEIVINGCALL: // Yes! Someone is calling us
    Serial.println("RECEIVING CALL");
    // Retrieve the calling number
    vcs.retrieveCallingNumber(numtel, 20);
    // Print the calling number
    // Answer the call, establish the call
  case TALKING: // In this case the call would be established
    Serial.println("TALKING. Press enter to hang up.");
    while ( != '\n')
    Serial.println("Hanging up and waiting for the next call.");