Mobitel 3G with Huawei E220 on Debian

Finally I decided to shift my mobile Internet connectivity from GPRS to HSDPA by getting a Mobitel 3G broadband connection.

The package includes a Huawei E220 HSDPA USB modem (Wikipedia article), SIM card and connection, connection fee and first month's bill waived, a Rs 5k deposit which shall be refunded after an year.

Huawai E220 is known to work out of the box on Linux after 2.6.20. However, some of the most recent kernels seems to have a conflict with the USB mass storage driver. It means, the disk drive in the modem with Windows drivers get detected, but not the modem. I am presently running Linux, which also exhibits this behavior.

Bud suggested a quick workaround: to start the computer while the USB dongle is plugged in. This worked, and the modem was autodetected as /dev/ttyUSB0.

The sales person at Excel World Mobitel outlet told me that the APN has to be statically set to "mobitel3g" and the number is "*99***1#". It was easy to find the AT commands to do this. I created the following /etc/wvdial.conf file and running "wvdial" afterwards took me to the Internet. Username and password was just to stop wvdial complaining.

[Dialer Defaults]
Modem = /dev/ttyUSB0
Baud = 1843200
Modem Type = Analog Modem
Init2 = ATZ
Init3 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init4 = AT+CGDCONT=1,"IP","mobitel3g"
Dial Command = ATDT
Phone = *99***1#
Username = foo
Password = bar
Stupid Mode = yes

Going with the "get it working, then make it better" philosophy, then I looked at the conflict with the USB disk. There are couple of suggestions to the kernel usb-storage driver discussed on the above thread - which didn't work for me unfortunately, but just running this huaweiAktBbo utility did the trick. So I copied the binary to a standard location.

# apt-get install build-essential libusb-dev   # just to be sure
# cc -o huaweiAktBbo -lusb huaweiAktBbo.c
# cp huaweiAktBbo /usr/local/sbin/

Then I created a small script to initiate the connection:


if ln -s $lock $lock
    [ -c /dev/ttyUSB0 ] || /usr/local/sbin/huaweiAktBbo
    sleep 3
    if [ -c /dev/ttyUSB0 ]
        cp -f /etc/wvdial.conf.mobitel /etc/wvdial
    rm -f $lock

exit 0

Lock can also be created in /var/run, and notice that I have not done a "set -e", because if wvdial stops with an error, we still need to remove the lock. The lock is there to avoid multiple invocations of the script.

Then I created a simple udev rule to automatically connect whenever the E220 is plugged in. You can use "lsusb", among others, to find the vendor ID and product ID. I created a new /etc/udev/rules.d/010_local.rules file with the following line.

ACTION=="add", BUS=="usb", SYSFS{idVendor}=="12d1", \
    SYSFS{idProduct}=="1003", RUN+="/usr/local/sbin/mobitel.sh"

That's it! Now I am on the Internet automatically whenever the device is connected to the computer!

The only remaining "problem" was hal which was still trying to automount the USB disk. As suggested in ArchLinux wiki, creating a file /usr/share/hal/fdi/preprobe/20thirdparty/10-huawei-e220.fdi with the following fixes this:

<?xml version="1.0" encoding="UTF-8"?>
<deviceinfo version="0.2">
   <match key="usb.vendor_id" int="0x12d1">
     <match key="usb.product_id" int="0x1003">
       <merge key="info.ignore" type="bool">true</merge>

The connection is fast and way cheaper than GPRS when it comes to volume. HSDPA costs one rupee per MB, while GPRS costs 20!

Update: I noticed that udev runs the script multiple times, so as a quick fix I have added a test for /dev/ttyUSB0 in a couple of places in the script to make matters better.


Amitha Amarasinghe said...

What about fixed cost? I heard the device is too expensively priced compared to what it cost for Mobitel. Is that true?

Ivak said...

But now Mobitel give it as monthly 0% interest installment package.

srimal said...

based on the same line of reasoning

any possiblity of buy the modem from elsewhere at a lower price

and using the mobitel hspa sim?

geekaholic said...

Now thats what I call "Plug and Play" :)

Unknown said...

I call that "plug-configure-n-play" :P

Anuradha Ratnaweera said...

What is sometimes is called "configure" is the real "play" part. So it has to be called "plug-play-and-use"... ;-p

srimal said...

There is a small modem statistic tool for the huawei E220 at :


They also have the installation and udev scripts as a package:


srimal said...

Statiscs monitor:


bkjaya said...

Huawei E220 is working with latest updates of mandriva 2009

bkjaya said...

Huawei E220 is working well with latest updates of mandriva 2009

Unknown said...

E220 is very easy to use. You can order online to your nearest singer, abans or mobitel outlet (I got email saying this). Check out http://www.mobitel.lk/phones/about.html They have a cool phone shop.

Mine I'v used for over an year now. Works well!

Ravi said...

wvdial conf works fine for Dialog too. Though you should change the apn to www.dialogsl.com

I don't seem to have this conflict on ubuntu, my modem gets detected as
/dev/ttyUSB_utps_modem every time i plug it in. :)

Unknown said...

machang mobitel gets it stuff from Abans, i asked customer care agent when i went to buy device. Mobitel must be keeping margin and selling?

better to buy from abans or cheaper somewhere else.

Anonymous said...

got this on line today
new smart 5 offered by Mobitel!!??
are they running a teaser campaign? SMART 5 reintroduced?