≡ Menu

5 Modem At Command Examples in Linux (How to Configure Minicom)

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.

Installing minicom

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.

Add your comment

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

Comments on this entry are closed.

  • Randy May 23, 2013, 1:51 am

    As always, learned something new from here. I didn’t know about minicom before.

  • Kal May 23, 2013, 10:29 am

    Can I do this on my Samsung galaxy phone? I would love to use that as a modem to try out at commands.

  • sushant May 30, 2013, 2:33 am

    not work in minicom

  • Kelly Carter May 31, 2013, 6:12 am

    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.

  • Mike Mackintosh June 21, 2013, 11:26 am

    I’ve never been a fan of minicom. I’ve always preferred screen /dev/tty…

    Nice write-up though.

  • tariq June 23, 2013, 3:34 pm

    can i run minicom on windows xp using cygwin?

  • Morris September 12, 2013, 9:22 pm

    Not work in my,should I do any config or something before?

  • varma April 24, 2014, 10:22 pm

    Working fine!!!
    How do you send SMS using php on ubuntu?

  • Ramya Kalaiselvan January 7, 2015, 5:14 am

    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.

  • sakit babu February 9, 2016, 10:55 am

    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

  • Venkat Thrinath February 22, 2016, 3:06 am

    Not working..
    getting error: +CMS ERROR: Invalid mandatory information
    Can anybody help?

  • sillyme December 16, 2016, 3:36 pm

    ” 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.