top of page
Search

Send Sms Using Gsm Modem



In this article we are going to learn, how to send and receive SMS using GSM modem which is controlled by Arduino. Let us see, what GSM modem is, how to interface it with Arduino, how to send SMS with the setup.




Send Sms Using Gsm Modem



It is the first digital protocol for mobile communication which is optimized for full duplex voice communication. In a nutshell full duplex communication means both the parties can send/receive data (or voice) simultaneously.


//-------------Program developed by R.Girish---------------// #include #define rxPin 9 // gsm TX------> arduino 9 #define txPin 8 //gsm RX--------> arduino 8 SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin); char text[150]; String message=""; int x; void setup() Serial.begin(9600); while (!Serial) mySerial.begin(9600); delay(1000); Serial.println("Write your message (with dot at end):"); void loop() x=0; while( Serial.available()>0 ) text[x] = Serial.read(); message += text[x]; x++; if (text[x-1]==46) Serial.println("Your message is sending......"); SendTextMessage(); ShowSerialData(); delay(1000); Serial.println("r"); Serial.println("Success"); message=""; x=0; void SendTextMessage() mySerial.print("AT+CMGF=1r"); delay(1000); mySerial.print("AT+CMGS="+91xxxxxxxxxx"r"); // Replace x with your 10 digit phone number delay(1000); mySerial.println(message); mySerial.print("r"); delay(1000); mySerial.println((char)26); mySerial.println(); void ShowSerialData() while(mySerial.available()!=0) Serial.write(mySerial.read()); //-------------Program developed by R.Girish---------------//


You can also automate the message which is sent by GSM modem by coding Arduino appropriately. You can receive automated message alerts on your phone such as: anti-theft alert, fire alarm alert, weather alert on your local area etc.


The circuit for receiving SMS using a GSM moden is very simple, you just need 3 male to female header pins. The TX of GSM modem is connected to pin #9 of arduino and RX of GSM modem is connected to pin #8 of arduino and the ground to ground connection is also given between GSM and arduino.


//-----------------Program developed by R.Girish-------------// #include SoftwareSerial gsm(9,8); void setup() gsm.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': Send(); break; case 'r': Recieve(); break; case 'S': Send(); break; case 'R': Recieve(); break; if (gsm.available()>0) Serial.write(gsm.read()); void Send() gsm.println("AT+CMGF=1"); delay(1000); gsm.println("AT+CMGS="+91xxxxxxxxxx"r"); // Replace x with mobile number delay(1000); gsm.println("Hello I am GSM modem!!!");// The SMS text you want to send delay(100); gsm.println((char)26); // ASCII code of CTRL+Z delay(1000); void Recieve() gsm.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS delay(1000); //-----------------Program developed by R.Girish-------------//


Insert the SIM card and power the GSM modem with external power supply and press the power button for 3 seconds (depending the model), wait for 10 to 20 seconds to establish mobile network, the network LED should blink once in every 3 seconds. If everything is stated above is done, we are ready to go for next step.


TheSMS specification has defined a way for a computer to send SMSmessages through a mobile phone or GSM/GPRS modem. A GSM/GPRS modemis a wireless modem that works with GSM/GPRS wireless networks. Awireless modem is similar to a dial-up modem. The main difference isthat a wireless modem transmits data through a wireless networkwhereas a dial-up modem transmits data through a copper telephoneline. More information about GSM/GPRS modems will be provided in thesection "Introduction to GSM /GPRS Wireless Modems". Most mobile phones can be used as awireless modem. However, some mobile phones have certain limitationscomparing to GSM/GPRS modems. This will be discussed in the section"Which is Better: Mobile Phoneor GSM / GPRS Modem" later.


Tosend SMS messages, first place a valid SIM card from a wirelesscarrier into a mobile phone or GSM/GPRS modem, which is thenconnected to a computer. There are several ways to connect a mobilephone or GSM/GPRS modem to a computer. For example, they can beconnected through a serial cable, a USB cable, a Bluetooth link or aninfrared link. The actual way to use depends on the capability of themobile phone or GSM/GPRS modem. For example, if a mobile phone doesnot support Bluetooth, it cannot connect to the computer through aBluetooth link.


Afterconnecting a mobile phone or GSM/GPRS modem to a computer, you cancontrol the mobile phone or GSM/GPRS modem by sending instructions toit. The instructions used for controlling the mobile phone orGSM/GPRS modem are called AT commands. (AT commands are also used tocontrol dial-up modems for wired telephone system.) Dial-up modems,mobile phones and GSM/GPRS modems support a common set of standard ATcommands. In addition to this common set of standard AT commands,mobile phones and GSM/GPRS modems support an extended set of ATcommands. One use of the extended AT commands is to control thesending and receiving of SMS messages.


Oneway to send AT commands to a mobile phone or GSM/GPRS modem is to usea terminal program. A terminal program's function is like this: Itsends the characters you typed to the mobile phone or GSM/GPRS modem.It then displays the response it receives from the mobile phone orGSM/GPRS modem on the screen. The terminal program on MicrosoftWindows is called HyperTerminal. More details about the use ofMicrosoft HyperTerminal can be found in the "Howto Use Microsoft HyperTerminal to Send AT Commands to a Mobile Phoneor GSM/GPRS Modem" section of this SMS tutorial.


Belowshows a simple example that demonstrates how to use AT commands andthe HyperTerminal program of Microsoft Windows to send an SMS textmessage. The lines in bold type are the command lines that should beentered in HyperTerminal. The other lines are responses returned fromthe GSM / GPRS modem or mobile phone.


Line1: "AT" is sent to theGSM / GPRS modem to test the connection. The GSM / GPRS modem sendsback the result code "OK" (line 2), which means theconnection between the HyperTerminal program and the GSM / GPRSmodem works fine.


Line3: The AT command +CMGF is used to instruct the GSM / GPRS modem tooperate in SMS text mode. The result code "OK" is returned(line 4), which indicates the command line "AT+CMGF=1" hasbeen executed successfully. If the result code "ERROR" isreturned, it is likely that the GSM / GPRS modem does not supportthe SMS text mode. To confirm, type "AT+CMGF=?" in theHyperTerminal program. If the response is "+CMGF: (0,1)"(0=PDU mode and 1=text mode), then SMS text mode is supported. Ifthe response is "+CMGF: (0)", then SMS text mode is notsupported.


Line5 and 6: The AT command +CMGW is used to write an SMS text messageto the message storage of the GSM / GPRS modem. "+85291234567"is the recipient mobile phone number. After typing the recipientmobile phone number, you should press the Enter button of thekeyboard. The GSM / GPRS modem will then return a prompt ">" and you can start typing the SMS text message "A simpledemo of SMS text messaging.". When finished, press Ctrl+z ofthe keyboard.


Tosend SMS messages from an application, you have to write the sourcecode for connecting to and sending AT commands to the mobile phone orGSM/GPRS modem, just like what a terminal program does. You can writethe source code in C, C++, Java, Visual Basic, Delphi or otherprogramming languages you like. However, writing your own code has afew disadvantages:


SendingSMS messages with a mobile phone or GSM/GPRS modem has a drawback --the SMS transmission speed is low. As your SMS messaging applicationbecomes more popular, it has to handle a larger amount of SMStraffic and finally the mobile phone or GSM/GPRS modem will not beable to take the load. To obtain a high SMS transmission speed, adirect connection to an SMSC or SMS gateway of a wireless carrier orSMS service provider is needed. However, AT commands are not usedfor communicating with an SMS center or SMS gateway. This means yourhave to make a big change to your SMS messaging application in orderto move from a wireless-modem-based solution to a SMSC-basedsolution.


Inmost cases, instead of writing your own code for interacting with themobile phone or GSM/GPRS modem via AT commands, a better solution isto use a high-level SMS messaging API (Application programminginterface) / SDK (Software development kit) / library. The API / SDK/ library encapsulates the low-level details. So, an SMS applicationdeveloper does not need to know AT commands and the composition ofSMS messages in the bit-level. Some SMS messaging APIs / SDKs /libraries support SMSC protocols in addition to AT commands. To movefrom a wireless-modem-based SMS solution to a SMSC-based SMSsolution, usually you just need to modify a configuration file /property file or make a few changes to your SMS messagingapplication's source code.


Anotherway to hide the low-level AT command layer is to place an SMS gatewaybetween the SMS messaging application and the mobile phone orGSM/GPRS modem. (This has been described in the section "Whatis an SMS Gateway?" earlier.) Simple protocols such as HTTP/ HTTPS can then be used for sending SMS messages in the application.If an SMSC protocol (e.g. SMPP, CIMD, etc) is used for communicatingwith the SMS gateway instead of HTTP / HTTPS, an SMS messaging API /SDK / library can be very helpful to you since it encapsulates theSMSC protocol's details. 2ff7e9595c


 
 
 

Recent Posts

See All
Temple Run 2 original apk baixar

Download do APK original de Temple Run 2: como obtê-lo gratuitamente Você ama jogos de corrida? Você quer experimentar a emoção de...

 
 
 

Comments


OUR STORE

Address: 500 Terry Francois Street San Francisco, CA 94158

Phone: 123-456-7890

Email:  info@mysite.com

OPENING HOURS

Mon - Fri: 7am - 10pm
​​Saturday: 8am - 10pm
​Sunday: 8am - 11pm

HELP

SUBSCRIBE

Thanks for submitting!

  • Facebook
  • Pinterest
  • Instagram

© 2023 by Prickles & Co. Proudly created with Wix.com

bottom of page