In my previews post we have learned to link our mobile phone which serves as our GSM modem and used AT commands in the Hyper Terminal to send our SMS. This post will discuss the second function which is to receive SMS using AT commands. The GSM modem can be configured to receive SMS in different ways. It can be Immediate or through a Notification. I will be discussing to you these two modes shortly.
2. Receiving SMS
Immediate - The details of the SMS received from the GSM modem is immediately sent to the computer.
AT+CMGF=1
-formatSMS message as text
AT+CNMI=1,2,0,0,0
-sets the mode of the GSM modem to immediately respond when the SMS is received.
-this command should return something like:
Hello World!
-the mode we have set will continuously monitor the COM port for messages received from the GSM modem and immediately send it to the computer.
Notification - A notification is sent to the computer indicating that the GSM modem received an SMS message. The notification contains the memory location of the message which is accessed using an AT command to be displayed in the computer.
AT+CMGF=1
-formatSMS message as text
AT+CNMI=1,1,0,0,0
-sets the mode of the GSM modem to notify the computer that an SMS is received.
-this command should return something like (SIM Memory):
+CMTI: "SM",3
-the notification means that a message is received and stored in location 3 in SIM memory.
-or something like (Memory Card):
+CMTI: "ME",64
-the notification means that a message is received and stored in location 64 in extended memory.
AT+CMGR=3 <Enter>
-the command to read the received SMS from the GSM modem.
-details of the SMS from memory location 3 is then sent to the computer.
-details of the SMS from memory location 3 is then sent to the computer.
-this command should return something like: |
+CMT : "+63xxxxxxxxxx" , , "06/26/11,23:20:00+40"
Hello World!
That shows you how to receive and read the SMS from your GSM modem. After we receive the message its just right to delete the message from our phone memory or memory card. We don't want our mobile phone to be flooded with SMS right?
AT+CPMS=
AT+CMGD=3 <Enter>
-this AT command delete the SMS received stored in location 3 of the GSM modem.
-this command should return "OK" if the message is deleted successfully or an error if the specified memory location is empty.
Great job! We've just learned using AT commands in sending and receiving SMS message from our computer. If you were not able to get it then post a comment and we will discuss your problem. The next post is about getting the codes doing the job for you. Using the AT command you have now the idea on how to integrate it to your application. You can now use a higher level of programming to execute the commands. Try it out for your self. It is free and would not cost you that much of purchasing an SMS gateway software. Watch out for the next post. I'll be using VB.NET window forms to create a sample SMS application.
Good article. I tried. The SMS is not notified at PC. It remains on Mobile phone itself. Does it because of I am using my Mobile as GSM modem? if so what is solution? I have Samsung SGH series mobile. I am doing student project. Kindly help with setting at santulanc@gmail.com
ReplyDeletegood article.i am doing final year project in my school, can u help me in replying message to my computer after i read the message send to me?
ReplyDeleteI learn from a good blog, your blog I have a great inspiration, thank you.
ReplyDeletehi, I'm writing a code to write and receive sms using Arduino Uno and a shield gsm v2 by seeedstudio.
ReplyDeleteI am able to send text messages and make calls
I am not able to receive them I am not able use the at commands, how can I read a message that I received and then print it?
I enclose the code that performs the sending of text messages and calls.
thank you! MAra
ReplyDelete((this is my code))
#include
#include
SoftwareSerial mySerial(7,8);
void setup()
{
mySerial.begin(19200); // the GPRS baud rate
Serial.begin(19200); // the GPRS baud rate
delay(500);
}
void loop()
{
if (Serial.available())
switch(Serial.read())
{
case 't':
SendTextMessage();
break;
case 'd':
DialVoiceCall();
break;
}
if (mySerial.available())
Serial.write(mySerial.read());
}
void SendTextMessage()
{
mySerial.print("AT+CMGF=1\r"); //Because we want to send the SMS in text mode
delay(100);
mySerial.println("AT + CMGS = \"+393467817695\"");//send sms message, be careful need to add a country code before the cellphone number
delay(100);
mySerial.println("How are you ?");//the content of the message
delay(100);
mySerial.println((char)26);//the ASCII code of the ctrl+z is 26
delay(100);
mySerial.println();
}
///DialVoiceCall
///this function is to dial a voice call
void DialVoiceCall()
{
mySerial.println("ATD + +393467817695;");//dial the number
delay(100);
mySerial.println();
}
void ShowSerialData()
{
while(mySerial.available()!=0)
Serial.write(mySerial.read());
}
wow now i know thank you more power
ReplyDeleteHeya i am for the first time here. I found this board and
ReplyDeleteI find It truly useful & it helped me out a lot. I am hoping to give one thing back and aid others such as you helped me.
Take a look at my blog - fatcow web Hosting
di maread yung messages sa nokia c3 ko.. cms error 302 lumalabas.. operation not allowed.. panu ba to?
ReplyDelete