Tutorial.GSMExamplesSendSMS History

Hide minor edits - Show changes to markup

March 11, 2013, at 10:39 AM by Scott Fitzgerald -
Changed lines 265-278 from:
February 02, 2013, at 10:15 AM by Scott Fitzgerald -
Changed lines 27-28 from:

SIM cards may have a PIN number that unlocks their functionality. Define the PIN for your SIM. If your SIM has no PIN, you can leave it blank :


SIM cards may have a PIN number that enables their functionality. Define the PIN for your SIM. If your SIM has no PIN, you can leave it blank :

Changed lines 74-75 from:

In loop, use a switch statement to control the flow of the program. getvoiceCallStatus() will return its state when it is called.


Create a function named readSerial of type int. You'll use this to iterate through input from the serial monitor, storing the number you wish to send an SMS to, and the message you'll be sending. It should accept a char array as an argument.

Changed line 77 from:

void loop()


int readSerial(char result[])

Deleted lines 78-79:
  switch (vcs.getvoiceCallStatus()) 
Changed lines 81-82 from:

If getvoiceCallStatus() returns IDLE_CALL, there is nothing happening.


Create a variable to count through the items in the serial buffer, and start a while loop that will continually execute.

Changed lines 84-86 from:
    case IDLE_CALL: 

  int i = 0;
Changed lines 89-92 from:

If getvoiceCallStatus() returns RECEIVINGCALL, someone is calling you. Use retrieveCallingNumber() to store the incoming number to the numtel array you created, and print it to the serial monitor.

Use answerCall() to initiate the voice conection with the caller.


As long as there is serial information available, read the data into a variable named inChar.

Changed lines 92-102 from:

      Serial.println("RECEIVING CALL");

      vcs.retrieveCallingNumber(numtel, 20);


    while (Serial.available() > 0)
      char inChar = Serial.read();
Changed lines 97-100 from:

Once you have answered the call, getvoiceCallStatus() will return TALKING. The sketch will wait for a newline character to trigger hangCall() and terminate the connection.

Close the switch statement.


If the character being read is a newline, terminate the array, clear the serial buffer and exit the function.

Changed lines 100-108 from:
    case TALKING:

      Serial.println("TALKING. Enter line to interrupt.");
      Serial.println("HANG. Waiting Call.");      
      if (inChar == '\n')
        result[i] = '\0';
        return 0;
Changed lines 108-109 from:

Add a small delay before continuing with the loop:


If the incoming character is an ASCII character other than a newline or carriage return, add it to the array and increment the index. Close up the while loops and the function.

Changed lines 111-117 from:
        result[i] = inChar;
Changed lines 121-124 from:

In loop, create a char array named remoteNumber to hold the number you wish to send an SMS to. Invoke the readSerial function you just created, and pass remoteNumber as the argument. When readSerial executes, it will populate remoteNumber with the number you wish to send the message to.

Changed lines 124-125 from:

/* SMS sender

Added lines 155-159:
February 02, 2013, at 09:50 AM by Scott Fitzgerald -
February 02, 2013, at 09:31 AM by Scott Fitzgerald -
February 02, 2013, at 09:31 AM by Scott Fitzgerald -
Changed lines 1-6 from:

Examples > Send SMS

Using the GSM Shield to Make Calls

This example shows how to use the GSM Shield and Library to make voice calls. Please click here for more information on the GSM library.


Examples > GSM library

Send SMS

This sketch send a SMS message from an Arduino with a connected GSM shield. using the serial monitor, you'll enter the number to connect with, and the message to send.

Changed lines 23-25 from:

The code below is configured for use with a GSM/GPRS shield. In the variable declaration area, you need to instantiate both the GSM and GSMVoiceCall classes. Inside setup(), call GSM.begin(), with the PINNUMBER of your SIM card as parameter. GSM.begin() will return whether the shield managed to connect to the GSM network or not.

In the loop(), the input from the Serial Monitor is used to tell the GSM Shield a phone number to call to. The code waits until the call is over before performing any other actions.

Changed lines 136-239 from:
Changed line 245 from:
November 16, 2012, at 07:58 PM by Scott Fitzgerald -
Added lines 1-34: