Asterisk on Raspberry Pi as GSM gateway

Yesterday I’ve installed chan_dongle for Asterisk PBX running at Raspberry Pi. What is chan_dongle? It is driver for Asterisk PBX, that allow to use some Huawei 3G USB dongles as a voice “board” to handle voice, SMS and USSD. Kind of your own self-made single-channel GSM gateway.

Raspberry PI with Huawei 3G dongle


  • Get compatible USB modem;

  • To check is modem have voice function and is not locked, use DC-Unlocker software;

  • Unlock modem if needed (it’s locked to operator and you have SIM card from other operator). Check unlock instructions and resources;

  • (optional step) if according to the DC-Unlocker, modem has no voice function, or you had issues with further configuration steps, try to upgrade firmware;

  • Download Raspberry-asterisk, flash it to the SD card (4GB at least; flash instructions on their website, below how I did that on mac OS):

# find your card (disk1 in my case)
mount /dev/disk1
diskutil unmountDisk /dev/disk1
sudo dd if=raspbian_wheezy_20120608.img of=/dev/rdisk1 bs=1m


Power on Raspberry Pi, find its ip address, ssh and:

  • Upgrade system
  • Install necessary software:
apt-get install usbutils unzip autoconf automake

# compile USB-modeswitch

cd /usr/src/


tar -jxvf usb-modeswitch-1.2.5.tar.bz2
tar -jxvf usb-modeswitch-data-20121109.tar.bz2

cd usb-modeswitch-1.2.5
make all
make install

cd ../usb-modeswitch-data-20121109
make install

cd ..
  • Now plug-in (if plugged, eject it first) an Huawei USB stick and check lsusb output:
lsusb | grep Huawei

It should print something like this:

Bus 001 Device 005: ID 12d1:140c Huawei Technologies Co., Ltd.
  • Now switch USB-stick to the modem mode. Values foe -v and -p flags I get from previous step and value for -M flag, I get from google search for my modem model and brand.
usb_modeswitch -v 0x12d1 -p 0x140c -H -s 5 -M 55534243000000000000000000000011060000000000000000000000000000
  • Download and install chan_dongle:


cd asterisk-chan-dongle-asterisk11/
automake -a
make all
make install
cp etc/dongle.conf /etc/asterisk/
cp /etc/extensions.conf /etc/asterisk/extensions-dongle.conf
  • Restart Asterisk PBX and check modem status:
asterisk -rx "core restart now"

# done, checking devices
asterisk -rx "dongle show devices"

You should see something like this:

# *CLI> dongle show devices
# ID           Group State      RSSI Mode Submode Provider Name  Model      Firmware          IMEI             IMSI             Number
# dongle0      0     Free       2    0    0       Yoigo          E1762   xxxx yyy  Unknown
# *CLI>

Done! Next step would be configuration of your new GSM gateway.

Still playing with device. Quality is good, better than I get with Portech GSM gateway, price per port also way better, and it also can send and receive SMS and USSD.

Good luck!

If you would like to try my system, download latest image here: Flashing instructions are same as for any Raspberry Pi image: gunzip .gz file, insert SD card, flash with Linux DD command… This resource for example, describes flashing procedure quite well.

Some useful links