You are on page 1of 41

GSM (Global System for Mobile communication) is a digital mobile telephony

system that is widely used in Europe and other parts of the world. GSM uses a
variation of time division multiple access (TDMA) and is the most widely used
of the three digital wireless telephony technologies (TDMA, GSM, and CDMA).
GSM digitizes and compresses data, then sends it down a channel with two
other streams of user data, each in its own time slot. It operates at either the
900 MHz or 1800 MHz frequency band.
Mobile services based on GSM technology were first launched in Finland in
1991. Today, more than 690 mobile networks provide GSM services across
213 countries and GSM represents 82.4% of all global mobile connections.
According to GSM World, there are now more than 2 billion GSM mobile
phone users worldwide. GSM World references China as "the largest single
GSM market, with more than 370 million users, followed by Russia with 145
million, India with 83 million and the USA with 78 million users."
Since many GSM network operators have roaming agreements with foreign
operators, users can often continue to use their mobile phones when they
travel to other countries. SIM cards (Subscriber Identity Module) holding home
network access configurations may be switched to those will metered local
access, significantly reducing roaming costs while experiencing no reductions
in service.
GSM, together with other technologies, is part of the evolution of wireless
mobile telemmunications that includes High-Speed Circuit-Switched Data
(HSCSD), General Packet Radio System (GPRS), Enhanced Data GSM
Environment (EDGE), and Universal Mobile Telecommunications Service
(UMTS).
GSM controlled robot or SMS controlled robot is a wireless robot which performs the
necessary actions by receiving a set of instructions in the form a Short Message Service
(SMS). In this project we can control the robot directions like forward, backward, left and

right by sending SMS from the mobile. Earlier, we have already seen the working of a
DTMF Controlled Robot without using Microcontroller.
This project mainly consists of 2 sections, one is mobile unit and the other one is robot
unit. The GSM modem which is fixed at the robot receives the messages sent by the
mobile and gives the instructions to the microcontroller to control the robot directions. In
this project, we interface 8051 microcontroller with GSM SIM 300. The protocol used for
the communication between controller and GSM modem is UART (Universal
Asynchronous Receiver-Transmitter). This system continuously checks for message to
take the decision for controlling the robot.
Voice recognition:

VOICE RECOGNITION SYSTEM


using microcontroller
Bilal Malik 1 Year Ago No Comments

Voice recognition system involves a biometric technology. This technology is


getting very popular nowadays for security purposes and for electronics
projects among engineering students. The individuals are easily identified
through it and the chances of theft and fraud are reduced. Other methods of
biometric identification are iris/eye scan, fingerprints, face scan, hand print,
voice print, handwriting etc. Through the biometric voice recognition system,
the unique voice characteristics of an individual can be recognized. This
security system has a wide range of applications and uses as for ATM
manufacturers, automobile manufacturers and in cell phone security access
system to eliminate any sort of theft or fraud. It is also have many
applications in embedded based applications.

Voice recognition system


The voice recognition system is the devices capacity to understand spoken
instructions. It is acutally a type of embedded system. When used with a
computer an ADC is used which converts varying analog voice signals into
digital pulses or digital signals, to be easily understood by the computer. The
hard drive already has the forms of speech stored in it. The voice signal is
decoded and checked against the stored forms. Sometimes due to the
presence of other voices and noises, the output does not come out to be
accurate.

Getting Started with the


Arduino GSM Shield
The Arduino GSM shield allows an Arduino board to connect to the
internet, send and receive SMS, and make voice calls using the GSM
library.
The shield will work with the Arduino Uno out of the box. The shield
will work with the Mega, Mega ADK, Yun, and Leonardo boards
with a minor modification. The Due is not supported at this time.
The GSM library is included with Arduino IDE 1.0.4 and later.

What is GSM

What is GPRS

Network operator requirements

SIM cards

Notes on the Telefonica/Movilforum SIM included with the shield

Connecting the Shield

GSM Library

Testing the modem and network connection

Sending a SMS message

Connecting to the internet

Making voice calls

Next steps

What is GSM
GSM is an international standard for mobile telephones. It is an
acronym that stands for Global System for Mobile Communications.
It is also sometimes referred to as 2G, as it is a second-generation
cellular network.
To use GPRS for internet access, and for the Arduino to request or
serve webpages, you need to obtain the Access Point Name (APN)
and a username/password from the network operator. See the
information in Connecting to the Internet for more information about
using the data capabilities of the shield.
Among other things, GSM supports outgoing and incoming voice
calls, Simple Message System (SMS or text messaging), and data
communication (via GPRS).
The Arduino GSM shield is a a GSM modem. From the mobile
operator perspective, the Arduino GSM shield looks just like a mobile
phone. From the Arduino perspective, the Arduino GSM shield looks
just like a modem.

What is GPRS
GPRS is a packet switching technology that stands for General
Packet Radio Service. It can provide idealized data rates between
56-114 kbit per second.
A number of technologies such as SMS rely on GPRS to function.
With the GSM shield, it is also possible to leverage the data
communication to access the internet. Similar to the Ethernet
and WiFi libraries, the GSM library allows the Arduino to act as a
client or server, using http calls to send and receive web pages.

Network operator requirements


To access a network, you must have a subscription with a mobile
phone operator (either prepaid or contract), a GSM compliant device
like the GSM shield or mobile phone, and a Subscriber Identity
Module (SIM) card. The network operator provides the SIM card,
which contains information like the mobile number, and can store
limited amounts of contacts and SMS messages.
To use GPRS for internet access, and for the Arduino to request or
serve webpages, you need to obtain the Access Point Name (APN)
and a username/password from the network operator. See the
information in Connecting to the Internetfor more information about
using the data capabilities of the shield.

SIM cards
In addition to the GSM shield and an Arduino, you need a SIM card.
The SIM represents a contract with a communications provider. The
communications provider selling you the SIM has to either provide
GSM coverage where you are, or have a roaming agreement with a
company providing GSM coverage in your location.
It's common for SIM cards to have a four-digit PIN number
associated with them for security purposes. Keep note of this
number, as it's necessary for connecting to a network. If you lose
the PIN associated with your SIM card, you may need to contact your
network operator to retrieve it. Some SIM cards become locked if an
incorrect PIN is entered too many times. If you're unsure of what the
PIN is, look at the documentation that came with your SIM.
Using a PUK (PIN Unlock Code), it is possible to reset a lost PIN with
the GSM shield and an Arduino. The PUK number will come with your
SIM card documentation.

Look at the PIN Management example in the "tools" folder, bundled


with the GSM library for an example of how to manage your PIN
number with the PUK.
There are a few different sizes of SIM cards; the GSM shield accepts
cards in the mini-SIM format (25mm long and 15mm wide).

Notes on the Telefonica/Movilforum SIM


included with the shield
The GSM shield comes bundled with a SIM from
Telefonica/Movilforum that will work well for developing machine to
machine (M2M) applications. It is not necessary to use this specific
card with the shield. You may use any SIM that works on a network
in your area.
The Movilforum SIM card includes a roaming plan. It can be used on
any supported GSM network. There is coverage throughout the
Americas and Europe for this SIM, check the Movilforum service
availability page for specific countries that have supported
networks.
Activation of the SIM is handled by Movilforum. Detailed instructions
on how to register and activate your SIM online and add credit are
included on a small pamphlet that comes with your shield. The SIM
must be inserted into a powered GSM shield that is mounted on an
Arduino for activation.
These SIM card come without a PIN, but it is possible to set one
using the GSM library's GSMPIN class.
You cannot use the included SIM to place or receive voice calls.
You can only place and receive SMS with other SIMs on the
Movilforum network.

It's not possible to create a server that accepts incoming requests


from the public internet. However, the Movilforum SIM will accept
incoming requests from other SIM cards on the Movilforum network.
For using the voice, and other functions of the shield, you'll need to
find a different network provider and SIM. Operators will have
different policies for their SIM cards, check with them directly to
determine what types of connections are supported.

Connecting the Shield


If you are using an Arduino Uno, follow the instructions below. If you
are using an Arduino Mega, Mega ADK, Yun, or Leonardo, you
must follow these instructions. The GSM shield is not currently
supported on the Due.
To use the shield, you'll need to insert a SIM card into the holder.
Slide the metal bracket away from the edge of the shield and lift the
cradle up.

Insert the SIM in the plastic holder so the metal contacts are facing
the shield, with the notch of the card at the top of the bracket.

Slide the SIM all the way into the bracket

Push the SIM to the board and slide the metal bracket towards the
edge of the shield to lock it in place.

Once the SIM is inserted, mount it on top of an Arduino board.

To upload sketches to the board, connect it to your computer with a


USB cable and upload your sketch with the Arduino IDE. Once the
sketch has been uploaded, you can disconnect the board from your
computer and power it with an external power supply.

Digital pins 2, 3 and 7 are reserved for communication between the


Arduino and modem and cannot be used by your sketches.
Communication between the moden and Arduino is handled by
the Software Serial library on pins 2 and 3. Pin 7 is used for the
modem reset.
When the yellow status LED turns on, it means the modem is
powered, and you can try connecting to the network.
Developer versions of the GSM shield required you to press press
the Power button on the shield for a few moments to turn the

modem on. If you have an early version of the shield, and it does not
turn on automatically, you can solder a jumper to the CTRL/D7 pad
on the reverse side of the board, and it will turn on when an
attached Arduino receives power.

The shield should work in any area with GSM coverage. Before
buying the shield please verify that there is this kind of coverage
where you plan to use it.

GSM Library
The GSM library handles communication between Arduino and the
GSM shield. The majority of functions are for managing data, voice,
and SMS communication. There are also a number of utilities for
managing information about the modem and the SIM card's PIN. See
the library reference pages for more information and a complete set
of examples.

Testing the modem and network


connection
This sketch will check the modem's IMEI number. This number is
unique to each modem, and is used to identify valid devices that can
connect to a GSM network. Once the number has been read from
the modem, the Arduino will print out the network carrier it is
connected to, and the signal strength of the network over the serial
port.
// import the GSM library
#include <GSM.h>
// PIN Number
#define PINNUMBER ""
// initialize the library instance
GSM gsmAccess(true);
// include a 'true' parameter for debug enabled
GSMScanner scannerNetworks;
GSMModem modemTest;
// Save data variables
String IMEI = "";
// serial monitor result messages
String errortext = "ERROR";
void setup()
{
// initialize serial communications
Serial.begin(9600);
Serial.println("GSM networks scanner");
scannerNetworks.begin();
// connection state
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;

else
{
Serial.println("Not connected");
delay(1000);
}
}
// get modem parameters
// IMEI, modem unique identifier
Serial.print("Modem IMEI: ");
IMEI = modemTest.getIMEI();
IMEI.replace("\n","");
if(IMEI != NULL)
Serial.println(IMEI);
// currently connected carrier
Serial.print("Current carrier: ");
Serial.println(scannerNetworks.getCurrentCarrier());
// returns strength and ber
// signal strength in 0-31 scale. 31 means power > 51dBm
// BER is the Bit Error Rate. 0-7 scale. 99=not detectable
Serial.print("Signal Strength: ");
Serial.print(scannerNetworks.getSignalStrength());
Serial.println(" [0-31]");
}
void loop()
{
// scan for existing networks, displays a list of networks
Serial.println("Scanning available networks. May take some seconds.");
Serial.println(scannerNetworks.readNetworks());
// currently connected carrier
Serial.print("Current carrier: ");
Serial.println(scannerNetworks.getCurrentCarrier());
// returns strength and ber
// signal strength in 0-31 scale. 31 means power > 51dBm
// BER is the Bit Error Rate. 0-7 scale. 99=not detectable
Serial.print("Signal Strength: ");
Serial.print(scannerNetworks.getSignalStrength());
Serial.println(" [0-31]");
}

[Get Code]

Sending a SMS message


Once you have connected to your network with the sketch above,
you can test some of the other functionality of the board. This
sketch will connect to a GSM network and send a SMS message to a
phone number of your choosing.
#include <GSM.h>
#define PINNUMBER ""
// initialize the library instance
GSM gsmAccess; // include a 'true' parameter for debug enabled
GSM_SMS sms;
// char array of the telephone number to send SMS
// change the number 1-212-555-1212 to a number
// you have access to
char remoteNumber[20]= "12125551212";
// char array of the message
char txtMsg[200]="Test";
void setup()
{
// initialize serial communications
Serial.begin(9600);
Serial.println("SMS Messages Sender");
// connection state
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;
else
{
Serial.println("Not connected");
delay(1000);

}
}
Serial.println("GSM initialized");
sendSMS();
}
void loop()
{
// nothing to see here
}
void sendSMS(){
Serial.print("Message to mobile number: ");
Serial.println(remoteNumber);
// sms text
Serial.println("SENDING");
Serial.println();
Serial.println("Message:");
Serial.println(txtMsg);
// send the message
sms.beginSMS(remoteNumber);
sms.print(txtMsg);
sms.endSMS();
Serial.println("\nCOMPLETE!\n");
}

[Get Code]

Connecting to the internet


In addition to the SIM card and a data plan, you will need some
additional information from your cellular provider to connect to the
internet. Every cellular provider has an Access Point Name (APN)
that serves as a bridge between the cellular network and the
internet. Sometimes, there is a username and password associated
with the connection point. For example, the Movilforum APN is
sm2ms.movilforum.es, but it has no password or login name.

This page lists a number of carrier's information, but it may not be


up to date. You may need to get this information from your service
provider.
The sketch below will connect to arduino.cc/latest.txt and print out
its contents.
NB: Some network operators block incoming IP traffic. You should be
able to run client functions, such as the sketch below, with no
issues.
// include the GSM library
#include <GSM.h>
// PIN number if necessary
#define PINNUMBER ""
// APN information obrained from your network provider
#define GPRS_APN
"GPRS_APN" // replace with your GPRS APN
#define GPRS_LOGIN
"login" // replace with your GPRS login
#define GPRS_PASSWORD "password" // replace with your GPRS password
// initialize the library instances
GSMClient client;
GPRS gprs;
GSM gsmAccess;
// This example downloads the URL "http://arduino.cc/latest.txt"
char server[] = "arduino.cc"; // the base URL
char path[] = "/latest.txt"; // the path
int port = 80; // the port, 80 for HTTP
void setup()
{
// initialize serial communications
Serial.begin(9600);
Serial.println("Starting Arduino web client.");
// connection state
boolean notConnected = true;
// Start GSM shield
// pass the PIN of your SIM as a parameter of gsmAccess.begin()
while(notConnected)
{

if((gsmAccess.begin(PINNUMBER)==GSM_READY) &
(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
notConnected = false;
else
{
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect(server, port))
{
Serial.println("connected");
// Make a HTTP request:
client.print("GET ");
client.print(path);
client.println(" HTTP/1.0");
client.println();
}
else
{
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop()
{
// if there are incoming bytes available
// from the server, read them and print them:
if (client.available())
{
char c = client.read();
Serial.print(c);
}
// if the server's disconnected, stop the client:
if (!client.available() && !client.connected())
{
Serial.println();
Serial.println("disconnecting.");
client.stop();
// do nothing forevermore:
for(;;)

;
}
}

[Get Code]

Making voice calls


Through the modem, it is possible to make voice calls. In order to
speak to and hear the other party, you will need to add a speaker
and microphone.

On the underside of the shield, there are through-holes


labeled M1P and M1N. These are the positive and negative voice
input pins for a microphone. The through-holes
labeled S1P and S1N are the positive and negative voice output
pins, to which you need to connect a speaker.
On page 43 of the modem documentation, there is an example voice
and sound circuit that will connect to an earphone:

The following sketch allows you to place a voice call. Using the serial
monitor, you can enter the remote phone number and terminate the
call. When you see the READY message, type a phone number. Make
sure the serial monitor is set to send a just newline when you press
return.
#include <GSM.h>
// PIN Number
#define PINNUMBER ""
// initialize the library instance
GSM gsmAccess; // include a 'true' parameter for debug enabled
GSMVoiceCall vcs;
String remoteNumber = ""; // the number you will call
char charbuffer[20];
void setup()
{
// initialize serial communications

Serial.begin(9600);
Serial.println("Make Voice Call");
// connection state
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;
else
{
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("GSM initialized.");
Serial.println("Enter phone number to call.");
}
void loop()
{
// add any incoming characters to the String:
while (Serial.available() > 0)
{
char inChar = Serial.read();
// if it's a newline, that means you should make the call:
if (inChar == '\n')
{
// make sure the phone number is not too long:
if (remoteNumber.length() < 20)
{
// show the number you're calling:
Serial.print("Calling to : ");
Serial.println(remoteNumber);
Serial.println();
// Call the remote number
remoteNumber.toCharArray(charbuffer, 20);

// Check if the receiving end has picked up the call

if(vcs.voiceCall(charbuffer))
{
Serial.println("Call Established. Enter line to end");
// Wait for some input from the line
while(Serial.read()!='\n' && (vcs.getvoiceCallStatus()==TALKING));
// And hang up
vcs.hangCall();
}
Serial.println("Call Finished");
remoteNumber="";
Serial.println("Enter phone number to call.");
}
else
{
Serial.println("That's too long for a phone number. I'm forgetting it");
remoteNumber = "";
}
}
else
{
// add the latest character to the message to send:
if(inChar!='\r')
remoteNumber += inChar;
}
}
}

The GSM stands for Global System for Mobile communications. This is a global
standard which is followed by the GSM modules inside the cellular phones which
enables them to be connected with any mobile network around the globe. In certain
applications the microcontroller based systems has to be connected with the GSM
network which will enable a user to control the system by sending messages or making
a call. The systems can also send messages to the user to alert or inform about the
status of the system running.
In all such cases a separate GSM module is used rather than using the mobile phones.
The advantage of using a GSM communication with a system or device is that the user
can control the system wirelessly no matter how far it is kept compared to any other
wireless communication, provided that both the user and the device should be in a
cellular coverage area.
This particular project demonstrates how to interface a GSM module and send SMS
to other mobile numbers using an Arduino board. The AVR microcontroller boards
which are provided with all the basic circuitry for the operation of the microcontroller

which has been flashed with the Arduino boot-loader are called Arduino boards. The
Arduino IDE is so simple to use that anyone who has basic knowledge of c
programming can quickly get started with it. The project on how to get started with the
Arduino explains about the steps required to get start with an Arduino board. The
Arduino can communicate with the other devices using its digital I/O, serial port, I2C
port, SPI port etc. and in this project the GSM module is interfaced using the serial port
of the Arduino board.

How to Interface GSM Module


to Arduino-Send and Receive
SMS
Last Updated on December 23, 2016 by jojo in Arduino with 59 Comments
In this article, we are going to see how to interface GSM Module to Arduino. There are different
kinds of GSM modules available in market. We are using the most popular module based
on Simcom SIM900 and Arduino Uno for this tutorial. Interfacing a GSM module to Arduino is
pretty simple. You only need to make 3 connections between the gsm module and arduino. So lets
get to business!
A GSM Module is basically a GSM Modem (like SIM 900) connected to a PCB with different types
of output taken from the board say TTL Output (for Arduino, 8051 and other microcontrollers) and
RS232 Output to interface directly with a PC (personal computer). The board will also have pins or
provisions to attach mic and speaker, to take out +5V or other values of power and ground
connections. These type of provisions vary with different modules.
Lots of varieties of GSM modem and GSM Modules are available in the market to choose from. For
our project of connecting a gsm modem or module to arduino and hence send and receive sms
using arduino its always good to choose an arduino compatible GSM Module that is a GSM
module with TTL Output provisions.

GSM Module Buyers Guide are you looking to buy a GSM module? There are a
handful of product variants for GSM module like SIM900, SIM300, SIM800 etc. We
have created this buyers guide to help you select the right GSM module for your project
needs.

Notes on GSM Module


1. We use SIM900 GSM Module This means the module supports communication in 900MHz
band. We are from India and most of the mobile network providers in this country operate in the
900Mhz band. If you are from another country, you have to check the mobile network band in your
area. A majority of United States mobile networks operate in 850Mhz band (the band is either
850Mhz or 1900Mhz). Canada operates primarily on 1900 Mhz band. Please read this wiki entry
on GSM Frequency Bands around the World.
2. Check the power requirements of GSM module GSM modules are manufactured by different
companies. They all have different input power supply specs. You need to double check your GSM
modules power requirements. In this tutorial, our gsm module requires a 12 volts input. So we feed it
using a 12V,1A DC power supply. I have seen gsm modules which require 15 volts and some other
types which needs only 5 volts input. They differ with manufacturers. If you are having a 5V module,
you can power it directly from Arduinos 5V out.
Note:- GSM Modules are manufactured by connecting a particular GSM modem to a PCB and then
giving provisions for RS232 outputs, TTL outputs, Mic and Speaker interfacing provisions etc. The
most popular modem under use is SIM 900 gsm modem from manufacturer SIMCom. They also
manufacture GSM Modems in bands 850, 300 and other frequency bands.
3. Check for TTL Output Pins in the module You can feed the data from gsm module directly to
Arduino only if the module is enabled with TTL output pins. Otherwise you have to convert
the RS232 data to TTL using MAX232 IC and feed it to Arduino. Most of the gsm modules in market
are equipped with TTL output pins. Just ensure you are buying the right one.
So thats all about the gsm module basics. Now lets power it up!

Booting the GSM Module!


1. Insert the SIM card to GSM module and lock it.
2. Connect the adapter to GSM module and turn it ON!
3. Now wait for some time (say 1 minute) and see the blinking rate of status LED or network LED
(GSM module will take some time to establish connection with mobile network)
4. Once the connection is established successfully, the status/network LED will blink continuously
every 3 seconds. You may try making a call to the mobile number of the sim card inside GSM
module. If you hear a ring back, the gsm module has successfully established network connection.
Okay! Now lets see how to connect a gsm module to Arduino!

Connecting GSM Module to Arduino


There are two ways of connecting GSM module to arduino. In any case, the communication between
Arduino and GSM module is serial. So we are supposed to use serial pins of Arduino (Rx and Tx).
So if you are going with this method, you may connect the Tx pin of GSM module to Rx pin of
Arduino and Rx pin of GSM module to Tx pin of Arduino. You read it right ? GSM Tx > Arduino
Rx and GSM Rx > Arduino Tx. Now connect the ground pin of arduino to ground pin of gsm
module! So thats all! You made 3 connections and the wiring is over! Now you can load different
programs to communicate with gsm module and make it work.
Note:- The problem with this connection is that, while programming Arduino uses serial ports to load
program from the Arduino IDE. If these pins are used in wiring, the program will not be loaded
successfully to Arduino. So you have to disconnect wiring in Rx and Tx each time you burn the
program to arduino. Once the program is loaded successfully, you can reconnect these pins and
have the system working!
To avoid this difficulty, I am using an alternate method in which two digital pins of arduino are used
for serial communication. We need to select two PWM enabled pins of arduino for this method. So
I choose pins 9 and 10 (which are PWM enabled pins). This method is made possible with
the SoftwareSerial Library of Ardunio. SoftwareSerial is a library of Arduino which enables serial
data communication through other digital pins of Arduino. The library replicates hardware functions
and handles the task of serial communication.
I hope you understood so far! Lets get to the circuit diagram! So given below is the circuit diagram to
connect gsm module to arduino and hence use the circuit to send sms and receive sms using
arduino and gsm modem.

Make the connections as shown! Now lets get to the coding part. The program has two objectives as
described below:1) Send SMS using Arduino and GSM Module to a specified mobile number inside the program
2) Receive SMS using Arduino and GSM Module to the SIM card loaded in the GSM Module.
The Program
#include <SoftwareSerial.h>

SoftwareSerial mySerial(9, 10);

void setup()
{

mySerial.begin(9600); // Setting the baud rate of GSM Module


Serial.begin(9600);

// Setting the baud rate of Serial Monitor (Arduino)

delay(100);
}

void loop()
{
if (Serial.available()>0)
switch(Serial.read())
{
case 's':
SendMessage();
break;
case 'r':
RecieveMessage();
break;
}

if (mySerial.available()>0)
Serial.write(mySerial.read());

void SendMessage()
{
mySerial.println("AT+CMGF=1");

//Sets the GSM Module in Text Mode

delay(1000); // Delay of 1000 milli seconds or 1 second


mySerial.println("AT+CMGS=\"+91xxxxxxxxxx\"\r"); // Replace x with mobile number
delay(1000);
mySerial.println("I am SMS from GSM Module");// The SMS text you want to send
delay(100);
mySerial.println((char)26);// ASCII code of CTRL+Z
delay(1000);
}

void RecieveMessage()
{
mySerial.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS
delay(1000);
}

so thats the program/code to make arduino send sms and receive sms using gsm module! Lets get
to explanation of program!
The Program Explanation
We begin by including SoftwareSerial library into the program. In the next line, we create
a constructor of SoftwareSerial with name mySerial and we pass the digital pin numbers as
parameters. The actual format is like SoftwareSerial mySerial (Rx, Tx);
So in our code, pin number 9 will act as Rx of Arduino and 10 will act as Tx of Arduino. Lets get to
the configuration part of program inside setup. The first task is to set baud rates of SoftwareSerial
library to communicate with GSM module. We achieve this by invoking mySerial.begin function. Our
second task is to set the baud rate of Arduino IDEs Serial Monitor. We do this by
invoking Serial.begin function. Both should be set at the same baud rate and we use 9600
bits/second here in our tutorial. Configuration part is over with setting baud rates and its good to give
a small delay of 100 milli seconds.
Now lets get to the actual program inside loop(). To make things simpler, I have developed a user
input based program. The program seeks user input via serial monitor of Arduino. If the input
is s the program will invoke function to send an sms from GSM module. If the user input is r, the
program will invoke the function to receive a live SMS from GSM module and display it on serial
monitor of Arduino. The whole program is as simple as that!
Serial.available() checks for any data coming through serial port of arduino. The function returns
the number of bytes available to read from serial buffer. If there is no data available, it returns a -1
(value less than zero).
Serial.read() Reads all the data available on serial buffer (or incoming serial data if put otherwise).
Returns the first byte of incoming serial data.
mySerial.available() checks for any data coming from GSM module through the SoftwareSerial
pins 9 and 10. Returns the number of bytes available to read from software serial port. Returns a -1 if
no data is available to read.

mySerial.read() Reads the incoming data through software serial port.


Serial.write() Prints data to serial monitor of arduino. So the function Serial.write(mySerial.read())
prints the data collected from software serial port to serial monitor of arduino.
Lets get the functions SendMessage() and RecieveMessage()
These are the functions in which we actually send commands to GSM module from Arduino. These
commands to communicate with GSM module are called AT Commands. There are different
commands to perform different tasks using the GSM module. You can read complete AT Commands
Library to understand all that is possible with GSM module.
SendMessage() is the function we created in our arduino sketch to send an SMS. To send an
SMS, we should set our GSM module to Text mode first. This is achieved by sending an AT
Command AT+CMGF=1 We send this command by writing this to SoftwareSerial port. To achieve
this we use the mySerial.println() function. mySerial.println writes data to software serial port (the Tx
pin of our Software Serial that is pin 10) and this will be captured by GSM module (through its Rx
pin). After setting the GSM module to Text mode, we should the the mobile number to which we shall
send the SMS. This is achieved with AT command AT+CMGS=\+91xxxxxxxxxx\\r where you
may replace all x with the mobile number.
In next step, we should send the actual content of SMS. The end of SMS content is identified with
CTRL+Z symbol. The ASCII value of this CTRL+Z is 26. So we send a char(26) to GSM module
using the line mySerial.println((char)26); Each and every AT command may be followed by 1 second
delay. We must give some time for GSM module to respond properly. Once these commands are
send to GSM module, you shall receive an SMS in the set mobile number.
RecieveMessage() is the function to receive an SMS (a live SMS). The AT command to receive a
live SMS is AT+CNMI=2,2,0,0,0 we just need to send this command to GSM module and apply a
1 second delay. Once you send this command, try sending an SMS to the SIM card number put
inside GSM module. You will see the SMS you had sent displayed on your Arduino serial monitor.
There are different AT commands for different tasks. If you want to read all SMSs stored in your SIM
card, send the following AT Command to gsm module AT+CMGL=\ALL\\r
Okay! Thats all and you are done. And you have learnt how to use arduino to send sms and receive
sms message with example code.

I shall summarize this tutorial on how to send/receive a text message using arduino and gsm module
with the following notes:AT Commands to Send SMS using Arduino and GSM Module
AT+CMGF=1 // Set the GSM module in text mode
AT+CMGS=\"+YYxxxxxxxxxx\"\r // Input the mobile number| YY is country code
the message with stopping character (char)26 // ASCII of ctrl+z

AT Commands to Receive SMS using Arduino and GSM Module


AT+CMGF=1 // Set the GSM Module in text mode
AT+CNMI=2,2,0,0,0 // AT Command to receive live sms

GSM Requirements

The quality of Voice in the GSM system must be better then that achieved by the 900MHz
analogue systems over all the operating conditions.

The system must offer encryption of user information

The system must operate in the entire frequency band 890-915MHz and 935-960MHz.

An international standardised signaling system must be used to allow the interconnection of


mobile switching center's and location registers.

Minimise modifications to the existing fixed public networks.

Design the system so handset costs are minimised

Handsets must be able to be used in all participating countries

Maximum flexibility for other services like ISDN

System should maximise the functions and services available to cater for the special nature of
mobile communications.

Overview of GMS Technology

During the period of Evolution of mobile communication technologies various systems were
introduced and deployed to achieve standardization in mobile industry but all the efforts were
failed. Multiple issues were sustained like incompatibility of systems, development of digital
radio frequency. That is when GSM (Global System For Mobile Communication) Technology
was introduced and problems like standardization, incompatibility etc were overcame. TDMA
solution was chosen in 1987, It is narrowband system and TDMA standards for Time Division
Multiple access.
GSM systems were in market for testing purposes in 1980s but first commercial lunch of GSM
technology was made in 1991 in Finland. GSM based mobile phones are operated on TDMA
Systems, in TDMA single radio frequency is offered to users with any interference. After all
these years, GSM is now the largest mobile communication technology worldwide, all
manufacturers of Mobile phones develop their products based on GSM, and all mobile
companies provide their subscribers GSM networks. GSM standards for Global System for
Mobile Communication, it is widely used mobile technology worldwide and it adopted by more
then 214 countries around the world.
Features of GSM Technology
There are many features associated with GSM technology due to which it is bar far the most
leading mobile communication technology in the world today. GSM technology facilitates with
high speed integrated data, voice data, fax, mail, voice male and mostly used SMS feature. GSM
also make sure that all the communication made between networks are secured and protected
from intruders and frauds.
One of the major advantages of GSM technology which changed the way we looked mobile
phones at the beginning. GSM actually brought the concept of being Mobile way beyond the
limits. It enabled us to communicate across the continents.

GSM supports multiple frequency levels like 900 MHz, 1800 MHz, 1900 MHz. 1900MHz
frequency is used in North America where as 1800MHz is used in other parts of the world.
Different frequency bands are used by different mobile phone operators. If you are using Mobile
phone which supports 1800MGz and operators are available on this band, phone can be used the
network, where as if phone is out of the range of the frequency band on mobile operator
frequency than you need to have phone that supports the frequency. To avoid such cases one
should always adopt to have mobile phones that support multiple frequency bands.
Different Frequency Bands
There are three different frequency bands on which mobile phones are usually operates and these
are Dual Band, Tri-Band and Quad Band.

Dual Band : Dual frequency band operates on 900MHz and 1800 MHz, that means mobile
phone that supports dual band can be operated any where in the world where 900 MHz and 1800
MHz frequencies are used. Dual Band GSM networks usually found in all continents Europe,
Asia, Africa, Australia and South America.
Tri-Band: As name is obvious three frequencies are supported in Tri Band, these frequencies are
900 MHz, 1800MHz and 1900 MHz. Tri band is also supported all around the world these days.
Quad-Band: Quad Band supports four frequencies which are 850 MHz, 900 MHz, 1800 MHz ,
1900 MHz. Quad band also enables GSM phones to road almost anywhere in the world. All
countries support GSM networks hence make communication possible.
There are over 700 GMS networks available in the world operating in their respective countries
and providing international roaming services courtesy GSM technology. There are over 2 billion
GSM subscribers in the world. Countries which are using GSM networks on larger scales are
Russia, china Pakistan, United States, India.
GSM phone deliver very good voice quality, support useful services and standards, it is very
likely that GSM will remain the only mobile communication network technology to be adopted
by each and every country of the world.

Quality
With digital, sound quality is sharp and clear. Background sounds and static are vastly reduced and
crossed-line conversations are also eliminated. In comparison with analogue there are also far fewer
dropouts, and overall the quality is more like that of a fixed telephone.
Security
Unlike analogue, everything you say and send within the digital network is safe and secure. Some
features are user authentication that prohibits unauthorised access, encryption key distribution that
guarantees the privacy of the call and caller identification restrictions that can prevent the delivery of the
calling users number to the receiver.
Convenience
With digital, better technology means better battery life. You get up to twice as much talk time from each
battery charge, compared with analogue. In addition the digital service allows more calls to be handled at
any one time, therefore reducing congestion in areas of dense population and high usage.
Roaming
With digital, you are able to use your mobile phone, and number in other countries around the world who
operate a GSM network. Click HERE to view the list of GSM operators around the world. Or you can just
take your SIM card and use another GSM phone. Your home carrier must have a roaming agreement in
place and must be notified before leaving so that you can be activated in that country. All you need to do
is switch on the phone at your destination and you will automatically log into the network. Dependent on
the country you can still use your old SIM, but some countries will require you to get a loan SIM from your
carrier before going there. This will give you a new number whilst in that country but you can easily set up
a diversion to the new number if need be.
GSM Phase 1 features

Call Forwarding

All Calls

No Answer

Engaged

Unreachable

Call Barring

Outgoing - Bar certain outgoing calls(e.g. ISD)

Incoming - Bar certain incoming calls (Useful if in another country)

Global roaming - Visit any other country with GSM and a roaming agreement and use your phone
and existing number* (see section on roaming)

GSM Phase 2 features

SMS - Short Message Service - Allows you to send text messages too and from phones

Multi Party Calling - Talk to five other parties as well as yourself at the same time

Call Holding - Place a call on Hold

Call Waiting - Notifies you of another call whilst on a call

Mobile Data Services - Allows handsets to communicate with computers

Mobile Fax Service - Allows handsets to send, retrieve and receive faxes

Calling Line Identity Service - This facility allows you to see the telephone number of the incoming
caller on our handset before answering

Advice of Charge - Allows you to keep track of call costs

Cell Broadcast - Allows you to subscribe to local news channels

Mobile Terminating Fax - Another number you are issued with that receives faxes that you can
then download to the nearest fax machine.

GSM Phase 2 + features

Available by 1998

Upgrade and improvements to existing services

Majority of the upgrade concerns data transmission, including bearer services and packet
switched data at 64 kbit/s and above

DECT access to GSM

PMR/Public Access Mobile Radio (PAMR)-like capabilities

GSM in the local loop

Virtual Private Networks

Packet Radio

SIM enhancements

Premium rate services (eg Stock prices sent to your phone)

GSM 96 features

In fact, there is no such thing as GSM 96. In MoU SERG there is a document called SE.03. In
SE.03 you find the date for implementation of services. The date is 'coded' E in case this is
essential at the start of operation of a GSM network.
Services of that kind are: TS11 (basic speech), TS12 (emergency calls/112), SMS MT, Call
forwarding/Call barring services and data/fax. Then there are E96 services, servrvices to be
implemented for roamers before end 1996. The only service in this section is ODB Phase 2.
(ODB=Operator Determined Barring).
E97 is SMS MO (Short Message/Mobile Originated).
The list for E98 is longer. One reason is to put presure on suppliers. Services included are
CAMEL (to support PNP as a start), SOR, USSD, HSCSD and GPRS.

The GSM Network comprises three parts, Mobile Station (MS) which is similar to a cordless phone with
extra features, the Base Transceiver Station (BTS) that controls the connection with the Mobile Station,
the Base Station Controller (BSC) that controls multiply Base Transceiver Station's and then the rest of
the network covered further below..
Mobile Station (MS)
A Digital Mobile Phone and a SIM card make up the Mobile Station. The SIM (Subscriber Identity Module)
is a card that fits into your handset and is one of two sizes - either full size (same size as a credit card) or
the smaller plug in version. The SIM microprocessor is based on a silicon chip which is designed to
tolerate temperatures between -25 Degrees Celsius and +70 Degrees Celsius, and will also withstand up
to 85% humidity. However silicon is fragile and, therefore, if the card is tampered with, physically or
electronically, the card will be rendered useless.
The SIM contains all of your identification details, such as your IMSI (International Mobile Subscriber
Identity. This is a numeric string, where the first 3 digits represent the country where the SIM is from, the
next represent the operator in that specific country. The other digits represent the subscribers identity in
his home-network), phone memories, billing information, SMS text messages, pin numbers and
international roaming information.
A IMEI (International Mobile Equipment Identity) card is the serial number of the GSM phone that is the
equivalent of the ESN number in a Analogue Phone, this is fixed in the phone and cannot be changed.
The SIM card contains a IMSI (International Mobile Subscriber Identity) number that identifies the user to
the network along with other user and security information.
Base Transceiver Station (BTS)
The Base Transceiver Station consists of a radio transceiver with antenna that covers a single cell. It
handles the communications with the MS via radio interface.

BTS are all connected together to allow you to move from one cell to another. The antenna can take on
various forms, in the UK lampposts are being used, but normally it has three directional cells.
Base Station Controller (BSC)
The Base Station Controller manages multiple BTS's. It controls the allocation and release of radio
channels and handovers between cells.
A series of BTS's are connected to each Base Station Controller, the BSC keeps a eye on each call and
decides when to pass the call off to another BTS and to which one.
The Rest of the Network
Several BSC's are controlled by the Mobile service Switching Center (MSC), the MSC works with four
databases (HLR, VLR, EIR and the AuC) and together they manage the communications between Mobile
Station user and the other network types. Each of the databases has a separate job, these are as follows
Mobile Switching Center (MSC)
The Mobile Switching Center is the interface between the base station system and the switching
subsystem of the mobile phone network. Furthermore, the MSC is also the interface between the cellular
network and the PSTN. The MSC generates all billing records and ensures that all usage is directed to
the appropriate account.
The MSC has a relatively complex task, as unlike a conventional telephone exchange, when GSM
subscribers make calls they could be anywhere within the network.
The MSC must ensure that calls are routed through to those subscribers, wherever they are and
wherever they move to throughout the duration of each cell. This situation becomes even more complex
when two mobile subscribers wish to contact each other from two distant locations.
In order to simplify the subscriber management function, a specific service area is allocated to each MSC.
The MSC has to control the switching of tariff to and from the subscribers within it's service area which
involves the coordination of all radio resources and the inter cell hand-off activities.
Home Location Register (HLR)
The HLR is the central data base for all the subscribers which contains details on the identity of each
subscriber, the services to which they have access and the locations where the subscriber was last
registered.
All subscriber administration procedures are communicated to the HLR where the data is stored until it is
required by another part of the Public Land Mobile Network (PLMN).
The two key references used to route calls to each subscriber are the International Mobile Subscriber
Identity (IMSI) and the Mobile Subscriber Integrated Services Digital Network (MSISDN) number.
The IMSI is the unique number allocated to the subscriber which is stored in the SIM Card and is used by
the network for internal communications. When the SIM Card is inserted into a Mobile Equipment it
becomes a Mobile Station.
The MSISDN is the subscriber's mobile number which is linked to the IMSI in the HLR. Incoming calls to a
subscriber are translated back to the IMSI at the HLR thus enabling them to be delivered to the Mobile
Station.

Once the Mobile Station's MSISDN has been used to identify the IMSI, the HLR verifies the subscription
records to ensure that the call can be delivered to the last known location of the Mobile Station.
Visitor's Location Register (VLR)
The VLR is a database that is linked to an MSC and temporarily stares information about each Mobile
Station within the area served by that MSC.
The information that is temporarily stored in the VLR is sufficient to allow any Mobile Station within that
MSC area to make and receive calls. This includes the Mobile Station's identity, the area in which it was
last registered and data pertaining to the subscriber and any supplementary services that have been
selected by the subscriber.
The MSC refers to the VLR each time that a Mobile Station attempts to make a call in order to verify that
the request can be fulfilled. This process is to establish that no call restrictions or call barring instructions
are in place.
Equipment Identity Register (EIR)
The EIR ensures that all Mobile Equipment's are valid and authorised to function on the PLMN. Three
categories exist on the EIR, a white list, a gray list and a black list.
The white list comprises the IMEI ranges of all the Mobile Equipment's that have been approved by any
one of the three European, GSM approval centers.
Any Mobile Equipment that appears on the gray list will be allowed to function but will trigger an alert to
the network operator. This facility allows the network operator to identify any subscriber that is using a lost
or stolen Mobile Equipment.
Mobiles that are lost or stolen can be blacklisted which will prevent them from functioning on the home
PLMN or on other PLMNs around the world.
Central Equipment Identity Register (CEIR)
A central EIR is managed by the MoU Permanent Secretariat in Dublin, Ireland. Every MoU member is
committed to linking their network's EIR to the CEIR by January 1995.
The advantage in having the CEIR concept is that it empowers each network operator to restrict or
prevent the operation of any given MS throughout all PLMNs that are linked up to the CEIR.
Authentication Center (AUC)
The authentication center is used to validate the SIM Card being used by the Mobile Station. Secret
information that is held in the AUC and which is also contained within the SIM Card is used to perform a
complex mathematical calculation. Authentication occurs if the results of these two calculations agree.

SMSC (SMS Center or Service Center), the SMSC handled all the SMS messages that are sent.
The messages are sent on a data channel so you can receive them whilst on a call.

GMSC (Gateway MSC), is a gateway switch where the call is directed when setting up a call to a
GSM user. The GMSC looks for the subscriber by interrogating the right HLR which then
interrogates the VLR and routes the incoming call towards the MSC where the subscriber can be
reached.

You might also like