In this workshop we shall see how to control a GSM board with ARDUINO
Hardware required :
ARDUINO UNO board GSM 300 or 900 board
12v DC adapter for GSM board Connecting wires
The connection is simple.We shall use the Hardware Serial port of ARDUINO (pin 0 & pin 1).
Pin 0 (RX) of Arduino is connected to RX pin of GSM
Pin 1 (TX) of Arduino is connected to TX pin of GSM
General Rule is always TX to Rx & Rx to Tx.But the GSM board I’m using has a MAX232 level converter IC & the Tx ,Rx printed on board is that of MAX232’s T1 IN & R1 OUT.
Do not get confused .Always ensure that
Rx of Arduino (pin 0) goes to pin 11 (T1 IN) of Max232
Tx of Arduino (pin 1) goes to pin 12 (R1 OUT) of Max 232.
As we use TTL level logic we need not bother about the presence of 232 IC.
Do not power the GSM from Arduino.Use a separate adapter of minimum 1Amp rating.
Make GND pins of both GSM & Arduino common.
To start with place a valid SIM to the holder on the GSM board.Connect the power adapter to GSM.
Now dial a call from another phone to the SIM number & ensure that you get a Ring back tone .
This is the initial test to confirm that your GSM is ready to accept commands from Arduino.
Making a Call from GSM
First we shall see how to Dial a number.
We make use of AT commands to control a GSM.
Here are the Steps you do for making a call
1.Wake up GSM by giving AT command .
2.Dial a number using command ATDphone_no; ATD followed by phone number & a Semicolon.
3.Now the call is made.To hang the call feed ATH command.
The above steps are converted to code as below:
—————————————————————-
//Code for Dialling a number
char phone_no[]=”9443303461”;
void setup()
{
Serial.begin(9600); //Open Serial Connection at baudrate 9600
delay(2000);
Serial.println(“AT”); // Wake up GSM
Serial.print(“ATD”); //Dial the phone number using ATD command
Serial.print(phone_no);
Serial.println(“;”); // Semicolon is a must at the end
delay(10000);
Serial.println(“ATH”); // After a delay of 5 secs Hang the call
}
void loop()
{
// empty loop.If you enter the above code here,the call will be made FOR EVER repeatedly.
//Take Caution while coding under loop.At some condition you’ve to terminate the Call
}
——————————————————————–
Please note that you’ve to disconnect GSM from Arduino while Uploading the code to Arduino .
While issuing ATH command use Serial.println & not Serial.print.This println is to send Carriage
Return after the ATH command.Note the reasonable amount of Delay (10secs) used after issuing the ATD command.
This delay is mandatory for GSM to respond.
Sending SMS from GSM
Now we shall see the procedure to send SMS through GSM.
1.Wake up GSM by sending AT command
2.The GSM should be put on Text mode by feeding command AT+CMGF=1
3.Now give command AT+CMGS=”Mobile_number”
4.Verify whether the Modem responds with a > character
5.After getting > symbol ,feed your Message to SMS.
6.Press CTRL+Z to send the SMS.
The above steps are coded for Arduino to handle automatically
————————————————————————–
//Code to send SMS from Arduino
int timesTosend=1;
int count=0;
char phone_no[]=”9443303461″; //phone number
void setup()
{
Serial.begin(9600); //Open Serial connection at baud 9600
delay(2000);
Serial.println(“AT+CMGF=1”); //set GSM to text mode
delay(200);
}
void loop()
{
while(count<timesTosend){
delay(1500);
Serial.print(“AT+CMGS=\””);
Serial.print(phone_no);
Serial.println(“\””);
while (Serial.read()!=’>’);
{
Serial.print(“Test Message from Arduino GSM….HELLO..!!!”); //SMS body
delay(500);
Serial.write(0x1A); // sends ctrl+z end of message
Serial.write(0x0D); // Carriage Return in Hex
Serial.write(0x0A); // Line feed in Hex
//The 0D0A pair of characters is the signal for the end of a line and beginning of another.
delay(5000);
}
count++;
}
}
———————————————————————————
Feed the above code in Arduino IDE & upload it.Do not forget to Disconnect GSM from Arduino
while uploading the code.
If you copy & paste the above code,you may get compile error.Type in the code wherever error is indicated.
Note the usage of Hex codes 0x1A for sending ctrl+z
0x0D for Carriage Return & 0x0A for LineFeed.
Watch this Video on making a Call &Sending SMS using Arduino & GSM :
The GSM & ARDUINO boards are available at :
really helpful and explain with full details
Very helpful.. how do we send mms thro this?
SIM300 or SIM900 models do not support MMS.It is supported by SIM306 for which we’ve placed order & still waiting.
Hi, can i use a TMAS GSM/GPRS modem instead?
i tried using TMAS, but it doesnt seem to be working..
AT commands for TMAS GSM are different from that of SIMCOM.Refer to data sheet of SIEMENS TMAS GSM
here http://www.rfsolutions.co.uk/knowledgebase/download_attachment.php?kb_att=19
Hi sir,I have used your code to send an sms to my mobile from “GPS/GPRS/GSM Module V3.0 (SKU:TEL0051)”+ Arduino uno I can see the message on the serial moniter but I couldn’t get any message to my mobile (also tried for sending different mobiles)can I know the reason for it.
Thanks
i am building this project where i need to use two xbee modules one if recieve data from sensor and will transmit a signal to the other xbee at a remote end and then the signal will be transmitted to a far more remote area via gsm network so on the receiving side i need to stack arduino uno + gsm sheild + xbee shield so i want to know how to stack all three i know how to stack xbee+ethernet+arduino but i think this will not work for gsm. I am totally new to all these so please help me!!!
Use hardware serial to XBEE .ie., pins 1,2 of Arduino to connect to Xbee .Software serial can be used for GSM.You can assign some other pins like 3,4 to connect GSM by including Software Serial library.
Thanks for the awesome tutorial, I wanted to check the SIM balance but when i send ATD*123# (for Airtel) I get no response on Serial connection. Can you help please?
send ATD command ending with semicolon.Ypu’ll get response.
Thank you sir, but the modem keeps on repeating the same line over and over and then gives ERROR, what is the problem?
CODE:
char phone_no[]=”*123#″;
char incomingByte=0;
void setup()
{
Serial.begin(9600);
delay(2000);
mySerial.print(“AT”);
delay(1000);
Serial.print(“ATD”);
Serial.print(phone_no);
Serial.println(“;”);
delay(1000);
}
void loop()
{
while (Serial.available() > 0)
{
incomingByte = Serial.read();
if(incomingByte!=’\n’){
Serial.print(incomingByte);
}
if(incomingByte==’\n’)
{
Serial.print(incomingByte);
} }
}
Sir the tutorial is very helpful and good can you please show how to receive sms and display it on serial monitor.
check out here
https://alselectro.wordpress.com/2013/09/19/gsmhandling-received-sms/
hi sir.nice sharing.i just wnt to ask.what is the value of external power supply to run the gsm shield?all type of gsm shield sama power?tqvm
All GSM shields have onboard regulator IC.You can safely provide an external power source of 9 or 12 volt DC.The ampere rating must be at least 100ma (1A).
tq 4 u reply..have u try gsm shield model icomsat?
WHERE I CAN BUY THE GSM?
Amazing tutorial sir! Thank u 🙂 Just wanna mention one thing, in recieve sms code, there should be no semicolon after the while loop, other wise while condition is checked just once.
Can I power the GSM SIM900A board with a 9V battery?
No.It requires more current.An external adapter of 12v/1amp is idle.
I powered it with 9V battery and the power led turned on. The network led however keeps blinking. When I made call to the number, it says user is switched off. Does it mean that the module is getting unsuffucuent power OR is something wrong with the module, OR both?
Once you power the module, the LED blinks fast and after few seconds it starts blinking slowly.This indicates the presence of Network.With 9v battery the power will switch on, you may even make one or two calls.But the GSM requires 1A current for efficient functioning.If the LED doesn’t show up network , try placing the SIM properly.
hi sir nice tutorial……..sir can i do this in matlab?? I want to interface the gsm module and arduino with matlab…please help….it will be very useful for my project….
You can create a Serial object in Matlab & interface with Arduino hardware serial.You can follow this link for understanding Serial object creation :
http://zeeshanali-telecomtrends.blogspot.in/2011/01/serial-port-communication-and-accessing.html
Very nice tutorial sir……Thank you
Hello sir,
I connected the gsm module with arduino and it works fine for calling. but I cannot send messages using the above code????I don’t understand what is wrong.
can I use gsm sim300 without MAX232 IC?