AT commands are instructions that are used to control modems.
AT stands for ATTENTION.
These commands come from Hayes at commands that were used by the Hayes smart modems in 1980’s. Many modems today including dial-up, wireless, GSM/GPRS modems use these AT command set for communication.
There are 2 types of modem AT commands.
- Basic commands
- Extended commands
Basic commands are AT commands that do not start with “+”. Extended commands are AT commands that start with a “+”. All GSM/GPRS uses the extended commands for SMS/DATA services.
Task which can be done by using AT commands
Here are few list of tasks which can be done by using the AT commands.
- Get basic information about the subscriber
- Get the information about signal strength and battery strength
- Establish a data/voice connection
- Send and receive fax
- Send and receive SMS
- Read/Search phonebook entries
Note that not all modems will support all the AT commands.
In this tutorial, I’m going to show examples using my “Nokia 2700” mobile phone which has a inbuilt GSM/GPRS modem.
In-order to send AT commands to modems, we need an interface. Minicom is a tool which provides an interface for communicating with devices that are connected to serial ports. Minicom is a linux equivalent to the HyperTerminal utility in Microsoft Operating Systems.
Using minicom we can send AT commands to the modem to get information about its features.
# apt-get install minicom
Configuring minicom to interface with the modem
Before configuring minicom, we need to connect the modem to the linux system. In my case, I’ve connected my “Nokia 2700” via data cable to my linux PC. Once the device is connected, you will see output similar to the following using dmesg. In my case the modem got detected as /dev/ttyACM0.
[ 1071.120084] cdc_acm 1-1.3:1.1: ttyACM0: USB ACM device [ 1071.120916] usbcore: registered new interface driver cdc_acm [ 1071.120917] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
To configure minicom to access modem, do the following:
# minicom -s +-----[configuration]------+ | Filenames and paths | | File transfer protocols | | Serial port setup | | Modem and dialing | | Screen and keyboard | | Save setup as dfl | | Save setup as.. | | Exit | | Exit from Minicom | +--------------------------+
Choose the “Serial port setup” and press “Enter”. It will display a screen similar to the following.
+-----------------------------------------------------------------------+ | A - Serial Device : /dev/tty0 | | B - Lockfile Location : /var/lock | | C - Callin Program : | | D - Callout Program : | | E - Bps/Par/Bits : 115200 8N1 | | F - Hardware Flow Control : No | | G - Software Flow Control : No | | | | Change which setting? | +-----------------------------------------------------------------------+
Press ‘A’ to change the serial device from /dev/tty0 to /dev/ttyACM0.
Press ‘E’ to change the Baud rate at which the modem communicates. In my case, it is “460800”. You can also used wvdialconf to identify the baud rate supported by your modem.
Once you change these settings, press “Enter”.
Choose “Save setup as dfl” and choose “Exit”.
Now we have configured the minicom successfully and you will see a screen like the following.
Welcome to minicom 2.6.1 OPTIONS: I18n Compiled on Feb 11 2012, 18:12:55. Port /dev/ttyACM0 Press CTRL-A Z for help on special keys
To test whether we have configured minicom successfully to communicate with modem, type “AT” in the minicom. You should get a “OK” response as follows.
Welcome to minicom 2.6.1 OPTIONS: I18n Compiled on Feb 11 2012, 18:12:55. Port /dev/ttyACM0 Press CTRL-A Z for help on special keys AT OK
1. Answer an Incoming call – ATA
To answer an Incoming call via modem, issue the “ATA” command in the minicom.
RING ATA OK
When there is an incoming call, you can see a ‘RING’ message in the minicom. You can press “ATA” to answer the incoming call.
2. Dialing out and hanging up a voice call – ATD – ATH
You can also dial out a voice call from the modem using ATD command.
ATD 99769XXXXX; OK
Now the phone will dial out to the number 99769XXXXX.
To hangup the call, use ATH command.
3. Getting the Manufacture/IMEI/IMSI information
Extended AT commands are used to provide information about the manufacturer, International Mobile Equipment Identity, International Mobile Subscriber Identity etc…
AT+CGMI Nokia OK AT+CGSN xxxxxxxxxxxxxxx OK AT+CIMI xxxxxxxxxxxxxxx OK
4. Getting Signal quality and battery charge status
You can also get the signal quality and the battery charge status using AT extended commands.
AT+CSQ +CSQ: 29,99 OK AT+CBC +CBC: 1,96 OK
The output format +CSQ: 29,99 represents <Received signal strength indicator>,<Bit Error Rate>
The output format +CBC: 1,96 represents <current charging status>,<charged %>
5. Sending SMS using AT commands
You can also send SMS via AT commands.
AT+CMGF=1 OK AT+CMGS="99xxxxxxxx" > This is a test message > OK
The command AT+CMGF=1 sets the “Message format” to “text mode”. The command AT+CMGS, send the SMS to the specified number. < ctrl +z > is used to terminate the message input.
Comments on this entry are closed.
As always, learned something new from here. I didn’t know about minicom before.
Can I do this on my Samsung galaxy phone? I would love to use that as a modem to try out at commands.
not work in minicom
As a point of historical fact, AT does not stand for ATTENTION, but ATLANTA. Dennis Hayes of the Hayes Microcomputer Products, who created the Hayes modem, needed two characters that when detected by the smart modem would enable the modem automatically to determine both the baud rate and parity of the incoming serial data. As he had attended Georgia Tech in Atlanta, Georgia, USA, he saw that the letters ‘A’ and ‘T’ in “Atlanta” had the perfect bit patterns (‘A’ had an isolated ‘1’ bit after the start bit, and ‘A’ and ‘T’ always had opposite parity bits). I developed the firmware for a Hayes-compatible smartmodem, and saw firsthand how this worked. Also, a good friend of mine later went to work for Dennis Hayes and Dennis recounted this story to him in person. I suppose it hardly matters which story is true, except to modem designers and those interested in history of technology.
I’ve never been a fan of minicom. I’ve always preferred screen /dev/tty…
Nice write-up though.
can i run minicom on windows xp using cygwin?
Not work in my,should I do any config or something before?
How do you send SMS using php on ubuntu?
I need a help. Could anyone please explain me the step “Configuring minicom to interface with the modem” clearly. Since I would like to connect my Samsung Galaxy-Y (GT-S5360) to my linux (Ubuntu-12.4) and how to know the Baud rate for the same.
i want to program a system in raspberry pi that takes in analog values and pushes it to the internet and also send and receive messages from raspb pi to boot or reboot or get period log status. I want to know what is better? to use a gsm dongle or gsm/gprs modem? please help
getting error: +CMS ERROR: Invalid mandatory information
Can anybody help?
” is used to terminate the message input.”
ctrl-z doesn’t terminate, but suspend. you can continue with `fg` and `bg`.
to really close the connection and exit socat you use ctrl-d.