In this tutorial we will learn how to interface GSM Modem and send SMS. GSM Modems are easy long range interface where we need to read sensor data or control electrical equipment. We will start with selection of GSM modem, AT commands and connection of GSM Module with Arduino. A GSM modem is a specialized type of modem or phone hardware on small PCB which accepts a SIM card, and operates over a subscription to a mobile operator, just like a mobile phone.
What you will learn?
- Which GSM Modem should I use?
- How to connect GSM Modem with Arduino?
- How to send SMS using GSM module using Arduino?
Selection of GSM Modem
GSM modem are selected based on price, interface required and size. You can find detailed explanation here. We will not go deep into selection process. We are using SIM900A GSM Modem for this tutorial.
Connection of GSM Modem with Arduino Uno
Connecting GSM modem with arduino is very simple just connect RX Line of Arduino to TX Line of GSM Modem and vice versa TX of arduino to Rx of GSM modem. Make sure use TTL RX, TX lines of GSM modem.
Give 12V 2Amp power supply to GSM modem, Use of less current power supply can cause reset problem in GSM modem, give sufficient current to GSM modem.
Arduino Code for Sending SMS using GSM Modem
// GSM Modem SMS Sending Tutorial // circuits4you.com void setup() { Serial.begin(9600); //Initialise serial to communicate with GSM Modem } void loop() { delay(10000); //Give enough time for GSM to register on Network SendSMS(); //Send one SMS while(1); //Wait forever } void SendSMS() { Serial.println("AT+CMGF=1"); //To send SMS in Text Mode delay(1000); Serial.println("AT+CMGS=\"+9198xxxxxxxx\"\r"); //Change to destination phone number delay(1000); Serial.println("Hello from GSM Modem!");//the content of the message delay(200); Serial.println((char)26); //the stopping character Ctrl+Z delay(1000); }
Code is kept very simple we are using we are using few AT commands to send the SMS. every AT command ends with Carrige return. Always use Serial.println.
- AT+CMGF=1 set the GSM modem in text mode.
- AT+CMGS=”+9198xxxxxxxx” Send SMS to this number
- Message text
- Message closing character Control+Z. (char(26))
Note: While Programming Remove GSM Modem serial lines. You can use software serial also.
Testing of Code
- Insert the sim card.
- Upload Code with removed RX,TX lines.
- After uploading power off and connect RX,TX Lines.
- Turn on Both Arduino and GSM Modem.
- Wait for few seconds and see the blinking of network LED slows down. It means it is registered on network.
- You will receive SMS after 15 Seconds. If it takes too long to register on network in crease the 10 Second delay to larger value.
- For queries comment below.
- To use GSM Modem with Other microcontroller use this tutorial this.
In this tutorial you learned how to interface GSM Modem and send SMS. Its very simple but need to take care of Power supply current requirements, and Serial interface voltage levels USART(TTL) or RS232.
I have uploaded the code but then i didn’t get any msg.
how can we send sms to multiple numbers.