Saturday, July 4, 2009

Send SMS using AT Commands

If you are writing an application which sends SMS using AT commands then, you must read this post. Few days ago I started to develop an application which is completely AT command based. Here I am going to explain the things that I learnt from experience.

First and the foremost thing before you start developing an application based on AT command , know which mode (text/pdu) your mobile handset supports.

If handset supports TEXT mode then work is simple.

  1. First you need to set text mode by using AT+CMFG=1 Command.

  2. And then use AT+CMGS=”+CellPhoneNumber” <enter>.

  3. If command execute successfully then It will return “>” as a response.

  4. After getting success response simply write your message ex. “this is test SMS”. This will submit SMS to network and will return the Message ID.

  5. If you want to send long message i.e. greater than 160 character length message then, this is really very useful.


I will cover how to send long message in my succeeding posts.

If handset supports PDU mode then work will be little lengthy and need some more efforts.

  1. For PDU mode, you need to set pdu mode by using AT+CMFG=0 Command.

  2. And then write AT+CMGS=<length><CR> command for modem to response. Here you can’t send the length of actual message. You need to convert the text into 7-bit or 8-bit encoding scheme. I included some useful links and sample application at the bottom of the page to accomplish this task.

  3. If command execute successfully then It will return “>” as a response.

  4. After getting success response, send <PDU><ctr-z/esc > sequence. This will submit SMS to network and will return the Message ID.

  5. If you want to send long message i.e. greater than 160 character length message then, this is really very useful.


Reference :

  1. PDU message format : http://www.dreamfabric.com/sms/

  2. Complete information about all AT Commands : http://www.developershome.com/sms/operatingMode.asp

  3. Text to PDU converter : http://nerdlabs.org/tools/pdu.php


Sample Application :

  1. PDU Decoder : http://www.codeproject.com/KB/IP/PDUDecoder.aspx

  2. Sample Applications : http://www.scampers.org/steve/sms/samples.htm


Do share new things with me.

No comments: