After this tutorial, you will be able to send SMS with a common USB 3G modem.
I used Huawei E220 dongle (35$ from amazon). It is supported natively for any Linux Kernel 2.6.20 and the later.

Huawei_E220

Installation

The only thing you have to do is to enable option CONFIG_USB_SERIAL_GENERIC in your .config. This option will generate a module called usbserial.
At first after having plugged your E220 module into USB port, scan your usb bus, in order to find E220 VENDOR_ID and PRODUCT_ID

$lsub

…
Bus 004 Device 004: ID 12d1:1003
...

Your vendor ID is 0x12D1, product ID :0x1003

You can load module usbserial like this :

modprobe usbserial vendor=0x12d1 product=0x1003

Appears /dev/ttyUSB* devices

Software needed

To communicate with your Modem, you can use “echo” for sending and “cat” ,“grep” to interpret the answer from /dev/ttyUSB* entrie. One program are made for that. His name is ‘chat’. In debian system, chat utiliy is contained into ppp package.
$aptitude install ppp

Check the connection

Insert your SIM card into E220 sim card slot
E220 dongle support AT command. Extensive commands exist, only with some of them are useful for sending SMS
The First and easier command is “AT”. This command is very useful for checking the connection. The modem answer is “OK”. If no answer or “ERROR”, there’s something wrong.

$chat –v –t 2 “” “AT” “OK”

Send a SMS

First you need to put your device in text mode

/usr/sbin/chat -v -t 2 "" "AT+CMGF=1" "OK" < /dev/ttyUSB0 > /dev/ttyUSB0

The next step is to configure the phone number of your recipient . This is done by the following command:

m_phone_number="recipient_phone_number"
/usr/sbin/chat -v -t 2 "" "AT+CMGS=\"$m_phone_number\"" ">" < /dev/ttyUSB0 > /dev/ttyUSB0

At this setp, the modem is waiting for your message and the combined key (CTRL +Z) which indicate the end of your message. This can be emulate by ‘^Z’. Modem will answer after few seconds by command “+CMGS: 1”, if message sending without problem (low signal quality for example)

# SMS’s text
/usr/sbin/chat -v -t 2 "" "Your fisrt SMS" ">" < /dev/ttyUSB0> /dev/ttyUSB0
# To finalise the message send
/usr/sbin/chat -v -t 5 "" "^Z" "+CMGS: 1" < /dev/ttyUSB0> /dev/ttyUSB0

Resume

If you combined all these commands with dialog you can obtained a simple but efficient program for sending SMS like this :