AT commands

About AT commands

AT commands are used to command a modem, e.g. a GSM. It is widely used by most mobile phones. If you have a phone with a data cable, you can control your phone using these commands using a serial terminal, like Putty.

The baudrate that is required changes from phone model to model, often it is 9600 or 19200, with 1 stopbit and no flow control.

More information about the history of AT command can be found at Wikipedia.

Open communication

Communication with a mobile phone is started using the command AT. The mobile phone will answer with OK

Enter Pin code

The Pin code can be entered using the CPIN command. This command must only be used in case of a GSM board after powering up and if you haven’t disabled your pin code.

AT+CPIN=0000

Call a number

You can call a number using the ATD command. The number must end with a ; It is not necessary to add the country code (+31 for the netherlands).

If the received does not answer the call or cancels it, the message NO CARRIER will be given.

Send SMS

In order to send a SMS, you must first specify the number of the SMS  station of your mobile provider. If you have used your phone before, this step is not required. A list of the SMS stations for Dutch providers can be found here.

To check the current SMSC number, give the following command:

AT+CSCA?

To set the the correct SMS station, use the command:

AT+CSCA=”+31626000230″

An SMS can be send using 2 options: text mode and PDU mode. Not all phones support both modes. To check whether both modes are supported, give the following command:

AT+CMGF=0 (PDU mode)

AT+CMGF=1 (text mode)

If error is returned, the mode is not supported. Text mode is not supported by most Siemens mobile phones.

 Text mode

Text mode is the most easiest to send a SMS. First you have to specify the receiver:

AT+CMGS=+31618555857

Then the message can be typed. To send the message, press ctr-z in your serial terminal (or send hex 1A)

PDU mode

PDU mode is a little bit more complex. In PDU mode, you must send a message in octal, containing the SMS station, receiver, time stamp and the message.

A converter for PDU messages can be found here. An example of a PDU message is:

07911326060032F011000B911316097254F40000AA2BD9771D840EDBCBA0797D3C2ECFE7E63A9B9D0791CBE337B94C06D1D1E939A85D9ECFC3E77208

To send a message, you first compose it with the CMGW command. This command requires the lenght of the TPDU message as parameter.

AT+CMGF=0     //Set PDU mode
AT+CMGW=xx //Send message of xx octets
> <PDU message> <ctrl-z>

You receive an index number. This is the location where the SMS is stored (you can find the SMS in your draft messages). To send it, use the CMSS command:

AT+CMSS=<index>

Incoming call

In case of an incoming call, the RING message is returned. To be exact, the message is:

/r/n RING/r/n

To see the number of the caller, you have to enable this notification. This can be done using the CLIP command:

Incoming SMS

On default, no message is returned in case of an incoming text message. However, you read text messages from the memory and enable a “new message indication”. This process is described in detail here.

On the page about the Siemens M35i phone, I describe how to read a SMS from it’s storage.

 Time and date

[not tested yet, but does not work on M35]

AT$DATE?

AT$DATE=<YY,MM,DD>

year from 00 to 90

Time command: $TIME =<HH,MM,SS>

AT$TIME?

AT$TIME= 14,56,12

More information

Leave a Reply

Your email address will not be published.