5 Modem At Command Examples in Linux (How to Configure Minicom) - Voice Call and SMS on ubuntu


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 ada

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.

Post a Comment