GSM VoIP Gateway with Chan_dongle

A highly affordable GSM VoIP gateway can be obtained using Huawei E155X or compatible USB modems and chan_dongle, providing both inbound and outbound calls on GSM/3G networks.

Hardware requirements

Chan_dongle is able to work with many different USB modems from Huawei, such as K3715, E169 / K3520, E155X, E175X, K3765 and others. Read the full compatibility list here.
Before connecting the modem to your RPi, be sure to use a power supply rated at least 1A, better 1.2A or more. If your power supply does not provide enough current to power both the RPi and the modem, you can get problems booting the RPi, or calls to/from the GSM network fail with error “dongle disconnected”.
Alternatively a powered USB hub can be used as well. If you want to use 2 modems, an additional WiFi connection or other devices that require considerable amount of current, a powered USB hub is absolutely required.
In case you are using one of the older 256MB models with F1 and F2 still in place, you might want to consider bridging over F1 and F2, read more details here. This is however not required on the newer 512MB models, or when using a powered USB hub.

Not all Huawei USB modems work out of the box, on some of them voice calling capability has to be enabled first, some need to be upgraded with the latest firmware. Details on this can be found on the original chan_dongle wiki.
Before inserting the SIM into your modem please deactivate the PIN on your card. This can be done with any phone. Insert the SIM into your phone, deactivate PIN and you’re done. You can also use the Mobile Partner software – which comes with the modem itself – on a Windows computer to do this.

Setup and configuration

Once your modem has PIN deactivated, latest firmware and voice enabled, run this command:


This installer script installs, and creates an initial configuration. The script is provided with upgrade #11 (and improved further with upgrade #12). Once the installer has finished, connect your modem to the RPi. If it was connected already before, unplug it now and plug it in again. Some older modems still require usb_modeswitch to enable data/audio mode, for those a complete reboot of the RPi is recommended at this point.

Then log into FreePBX, in Connectivity – Trunks click Add Custom Trunk. Provide a trunk name, set Outbound CallerID to the number of your SIM, and enter in the field Custom Dial String:


Add an outbound route to use this trunk, as well as an incoming route. On the incoming route set DID Number to your SIM number, precisely matching the number you entered when running the install-dongle script.

More details on how to setup inbound and outbound routes can be found in the forum.

Sending and receiving SMS

The install-dongle script provides a few basic options to send and receive SMS. Received messages can be forwarded by email. If no email address is specified, messages are stored in /var/log/asterisk/sms.txt instead.
Additionally, received messages can optionally be forwarded to a mobile phone number on top of sending them by email. This is done through the first dongle0, your mobile operator’s charges apply for sending SMS.
In order to send out custom messages, a password protected web page can be activated during the install-dongle run. This page is located at http://raspbx/sms or http://raspbx.local/sms (for Mac).
A web page for sending USSDs is optionally available. Install it with:

apt-get install ussd-webpage

The page can be found at http://raspbx/ussd or http://raspbx.local/ussd (for Mac).


If it doesn’t work at this point, at first check if the interfaces of your modem match the configuration:

ls -l /dev/tty*

2 devices, ttyUSB1 and ttyUSB2 should show up. If the numbers are different, something like ttyUSB0 and ttyUSB1, edit /etc/asterisk/dongle.conf and change the values below [dongle0] accordingly.
Many modems require the usb_modeswitch program to switch over from CD-drive mode (for installing Windows drivers) to modem mode. The /dev/ttyUSB devices will not appear before the switch-over was done. Make sure to have all the latest upgrades on recent Debian Jessie based images to fix some initial bugs with usb_modeswitch. If your modem is still not switching it might be necessary to add a custom rule for usb_modeswitch.

Some users have reported voice calling with a specific mobile operator was not working, while using a sim card from a different provider with the same modem and RPi worked perfectly fine.

Troubleshooting power problems
In case the modem devices ttyUSB1 and ttyUSB2 are disappearing as soon as a call is set up (or also at other times), and later they appear again, it is most likely the modem is not sufficiently powered and thus disconnects again and again. Try these options:

  • Remove any USB extension cord from the modem and connect it directly.
  • In case a powered USB hub is used, try a different one or even try without it. With some of those hubs the modems just don’t work properly, although the current rating of the hub’s power supply is high enough.
  • If the modem is directly connected to the RPi (without a hub), the power supply has to power them both. Try different power supplies, as some have problems to keep their output voltage stable under higher load.
  • As a last resort, you can also try to use a different modem.

For more information, read the complete documentation here:

Modems reported working/not working

On top of the compatibility list on the original chan_dongle wiki, users of RasPBX have reported several modems to work fine with the RPi:

  • E153
  • E1550
  • E1552
  • E156G
  • E160
  • EG162
  • E166
  • E169
  • E171
  • E173 (some types of E173 seem to not work, only E173 with Qualcomm chipsets do work)
  • E1750
  • E180
  • E303
  • K3520 (not to confuse with K3520-z)
  • K3715
  • K3765a

The following modems had issues and could not me made working so far. Please let us know if they work for you nonetheless:

  • E150
  • E1752
  • E303C
  • E352
  • K3520-z

236 thoughts on “GSM VoIP Gateway with Chan_dongle

  1. Pingback: Malinowe Pi

  2. I have a Huawei E303F model with call support and a tatadocomo sim. I configured everything as described in the site as well as in the sourceforge forum. My device does not seem to be recognized….
    raspbx*CLI> dongle show device state dongle0
    ————– Status ————-
    Device : dongle0
    State : Not connected Start scheduled
    Audio : /dev/ttyUSB1
    Data : /dev/ttyUSB2
    Voice : No
    SMS : No
    Manufacturer :
    Model :
    Firmware :
    IMEI :
    IMSI :
    GSM Registration Status : Unknown
    RSSI : 0, dongle cmd dongle0 AT^U2DIAG=0

    Please help me on how to resolve the issue ?????

  3. Hi, I can’t install chan dongle…

    root@raspbx:~# install-dongle
    Installing GSM VoIP gateway with chan_dongle.
    Please read the documentation at

    Please enter the phone number of your SIM card
    (defaults to +1234567890 if left blank):
    Send incoming SMS to email address
    (leave empty to disable SMS forwarding):
    Forward incoming SMS to mobile phone number (via dongle0)
    (leave empty to disable):
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package asterisk11-chandongle
    Error installing chan_dongle and usb-modeswitch

  4. I make USSD callings from Asterisk CLI but the response is not correctly decoded, for example it cannot show € “, (comma)” or letters like ä, ü, ö.
    Here is the how response looks:

    raspbx*CLI> dongle ussd dongle0 *101#
    [dongle0] USSD queued for send with id 0x76573d38
    [2015-10-02 15:19:03] NOTICE[14060]: at_response.c:267 at_response_ok: [dongle0] Successfully sent USSD 0x76573d38
    [2015-10-02 15:19:05] WARNING[14266][C-0000002d]: app_verbose.c:101 verbose_exec: ‘Incoming USSD: Ihr Guthaben betr{gt: 3′ is not a verboser number
    01 e. Jetzt auch Ihr Guthaben aufladen: einfach *103*Aufladenummer# und die H|rertaste eingeben.

    In here for example it should show 3,01€. instead of 3’ is not a verboser number 01 e.

    Related Config:
    exten => sms,1,Verbose(Incoming SMS from ${CALLERID(num)} ${BASE64_DECODE(${SMS_BASE64})})
    exten => sms,n,System(echo ‘${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)} – ${DONGLENAME} – ${CALLERID(num)}: ${BASE64_DECODE(${SMS_BASE64})}’ >> /$
    exten => sms,n,Hangup()

    exten => ussd,1,Verbose(Incoming USSD: ${BASE64_DECODE(${USSD_BASE64})})
    exten => ussd,n,System(echo ‘${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)} – ${DONGLENAME}: ${BASE64_DECODE(${USSD_BASE64})}’ >> /var/log/asterisk/$
    exten => ussd,n,Hangup()

    • Unfortunately neither SMS nor USSD works with German umlauts or other special characters. This is a bug in the message decoding functions of chan_dongle.

  5. Just in case someone else has problems dialing numbers (from a sip endpoint) that start with a +XX (eg +49) instead of your local number (because the GSM endpoint doesn’t like them):

    Edit /etc/asterisk/extensions_custom.conf and add the following to the end of the file:

    ;convert +49 numbers to start with 0
    exten => _+49X.,1,Macro(user-callerid,LIMIT,EXTERNAL,)
    exten => _+49X.,n,Set(MOHCLASS=${IF($[“${MOHCLASS}”=””]?default:${MOHCLASS})})
    exten => _+49X.,n,Set(_NODEST=)
    ;exten => _+49X.,n,Noop,testblaaaa
    exten => _+49X.,n,Gosub(sub-record-check,s,1(out,0${EXTEN:3},))
    ;exten => _+49X.,n,Noop,0${EXTEN:3}
    exten => _+49X.,n,Macro(dialout-trunk,2,0${EXTEN:3},,off)
    exten => _+49X.,n,Macro(outisbusy,)

    Basically this is copied from extensions_additional.conf and all ${EXTEN} replaced by 0${EXTEN:3} or whatever your local standard might be.

  6. I’m trying to install an E3131 dongle but getting error: Unable to locate package asterisk11-chandongle. What could be the issue?

  7. Getting error: Unable to locate package asterisk11-chandongle while trying to install Huawei e3131. What could be the issue? Dongle model?

  8. Pingback: Blog of spblinux » Blog Archive » VOIP and mobile data connections

  9. Hi,

    I’m facing following issue while loading chan_dongle. Please suggest how to proceed further.

    Connected to Asterisk 11.15.0 currently running on raspbx (pid = 1368)
    raspbx*CLI> module load
    Unable to load module
    Command ‘module load’ failed.
    [2015-07-29 01:51:20] WARNING[4821]: loader.c:502 load_dynamic_module: Error loading module ‘’: /usr/lib/asterisk/modules/ undefined symbol: __ast_module_ref
    [2015-07-29 01:51:20] WARNING[4821]: loader.c:918 load_resource: Module ‘’ could not be loaded.

    Linux distro from –
    Raspberry pi 2. Ran install-dongle.

    Looking forward for help.


  10. WARNING[4697]: loader.c:502 load_dynamic_module: Error loading module ‘’: /usr/lib/asterisk/modules/ undefined symbol: __ast_module_ref
    WARNING[4697]: loader.c:918 load_resource: Module ‘’ could not be loaded.

  11. Hi I have finally managed to get GSM gateway working on raspbx. I had a Vodafone K3565 dongle (not K3565Z, that won’t work, has to be Huawei one), and found it’s a rebranded E160. Flashed E160 firmware onto it. The dongle was then suitable. And… It didn’t work. Until finally in desperation I ran raspbx-upgrade. Voilà! Working!

    • Hi Chris,
      Please can you help. I have spent hours on internet trying to get my K3565 rebranded to E160. I have not been successful. I would really appreciate it if you could post the steps and links you did to rebrand the K3565. Thank you in advance – appreciate it.

  12. Got a Huawei E160 “working” on RasPBX however I get one way audio. Reading a little there seems to be a fix to this using Huawei_voice (Kernel module). Is this available for RasPBX?

      • By running raspbx-update?

        I did that.

        huawei_voice compiles against 2.6 kernels but not against 3.18 and raspbx kernel is 3.18.6.

  13. I have several E1752 with 11.609.18.00.00 firmware and they work like a charm under Asterisk

  14. my experience with E156b “Colombia Version”

    Voice = OK* (maybe require Dc Unlocker to enable voice)
    SMS = OK
    DATA = not sure, in my case is not neccesary

    Best regards

  15. I have install asterisk and chan dongle.
    but I don’t no how to set it up as a gsm gateway.
    whenever I call my phone number.
    all I got is “I am sorry, that is not a valid extension……. ”

    ## sip.conf


    ## extension
    exten => 100,1,Dial(SIP/myphone)
    exten => 101,1,Dial(SIP/laptop)

    exten => s,1,Dial(SIP/myphone)
    exten => h,n,Hangup()

  16. Hello, i have raspberry pi 2, i installed the latest raspbx-09-02-2015, because other don’t support rb pi2, the configured everything and installed dongle.

    But.. there is error:

    chan_dongle.c:218 opentty: unable to open /dev/ttyUSB2: No such file or directory

    I tried to make chmod 0666 to /dev/ttyUSB*

    tried to add /etc/udev/rules.d/92-dongle.rules

    But same problem..

    There is no problem with b+ model..

    • When i run:

      root@raspbx:~# usb_modeswitch -v 0x12d1 -p 0x1446 -V 0x12d1 -P 0x140c -m 0x01 -M “55534243123456780000000000000011060000000000000000000000000000”

      It works but after reboot i must run that command

      • Do you really need such a long command or does it also work with:

        usb_modeswitch -v 12d1 -p 1446 -c 12d1\:1446

        When you plug in the modem after the Pi is booted up do you still need the command or will it then switch over automatically?

  17. I install chan dongle with a huawei k3715 dongle on a raspberry pi 2.
    Also i have a land line passthrough a sipura spa 3102 on same raspberry pi 2.
    The land line with sipoura work perfect but with chan dongle not
    Innitially i have problem with voice when speak the other hear me but i dont
    hear the other . some times i hear the other to but for short time lost again.
    After all updates and upgrades of freepbx and all updates and upgrades of raspbx the problem fixed and now the gsm gateway work perfect.
    Now i use the gsm line as disa to have access on landline.
    It works i hear the other end perfect but the other hear me very low.
    does anyone know how can i increase the volume?
    (sorry for my bad english)

  18. Raspberry Pi Asterisk + 3G (Voice + Data + SMS + internet)

    i am receive voice call
    i am sending SMS
    now i want to access 3G internet can it possible e303f Raspberry Pi
    please help advice

  19. i want to Redirect/Forward calls receiving on SIM on USB Dongal to soft Switch IP.
    is there any sulotion to forward calls comming on dongle’s mobile partner to redirect/forward to softswitch?


  20. I am looking for a solution to be able to connect a landline RJ11 to the Rasp and a GSM Sim, and all incomming calls from landline to be redirected thru the GSM Sim. Is this posible with a raspberry pi ?

  21. Hi guys,
    I am going though problems with huawei E169,
    the dongle is detected successfully on Raspbx, SMS is being routed to any other mobile number with no issues, but the voice calling is not working. for some reasons. when I call the number it goes to voice mail straight away.

    I connected to modem to a window machine in order to use DC unlocker to check if voice is enabled, and it was indeed activated.

    on the RPI I created custom trunk, created sip account, and create route.

    but ll this is not taking me anyway. any help is hightly appreciated.

  22. OK, I amaged to run Voice and Data over the 3G-HUAWEI with Raspberry Pi A+ (not B). I have to admit i am impressed.
    I am preparing the steps, but all what I acn tell, if you are newbie, the road is not rosey, bu not impossible.
    Also, I had to to remove all the freePBX componenets after the config is done to get decent performance … you cant ask a lot from this little berry … keep tuned

  23. Dear experts,

    Kindly , I need your support regarding strange issue I face with my HUAWEI 3G USB modem Model E173, which support voice calls. When I use your software , mobile partner and make phone calls to another mobile phone , I hear voice clearly into my laptop speakers. But when the mobile phone user on the other side pushes any mobile Phone keypad , I can “NOT” hear DTMF tone into my laptop speakers.
    I went to another place (40 kilometer away) , and run Mobile Partner again , now when I call the same mobile Phone , I can hear the DTMF tone when the Mobile phone user clicks any of the keypad. Is this related to device configuration. Which AT command and settings I use to make the device able to receive DTMF tone.

    Thanks so much for your support.

    • One more issue, I do not use Chan_dongle , I use my own code to communicate with the modem. To test , I use Huawei mobile partner.

  24. Hi
    Sorry for a noobish question. I lead a presales team and we have a vonage account to make calls. We can only do it from office. With this setup can we dial into the vonage gateway from outside??

    • Perhaps a VoIP gateway box like the spa3102. I use one, and can call my Pbx from mobile and then dial out on my Landline.

  25. Just wanted to know, is HUAWEI is best choice, however do D-Link 3g GSM Modem or TP-Link 3g GSM Modem support as well?

  26. Just wanted to report a success with Huawei E1553 USB Stik.
    I bought in China for E1552 Unlocked ( Actually on the outside plastic is written HUAWEI Model:E1552 , but inside is: E1553 according to DC-unlocker and asterisk )
    I was going to return it but decide to try it out before I do so.
    Still needs to be thoroughly tested but Asterisk can assess it and I can send SMS and respond to voice calls.

    raspbx*CLI> dongle show device state dongle0
    ————– Status ————-
    Device : dongle0
    State : Free
    Audio : /dev/ttyUSB1
    Data : /dev/ttyUSB2
    Voice : Yes
    SMS : Yes
    Manufacturer : huawei
    Model : E1553
    Firmware : 11.608.13.00.150
    IMEI : 354112037499956
    IMSI : 460008834867447
    GSM Registration Status : Registered, home network
    RSSI : 31, >= -51 dBm
    Mode : GSM/GPRS
    Submode : EDGE
    Provider Name : CMCC
    Location area code : 8859
    Cell ID : 880D
    Subscriber Number : Unknown
    SMS Service Center : +8613800871500
    Use UCS-2 encoding : Yes
    USSD use 7 bit encoding : No
    USSD use UCS-2 decoding : Yes
    Tasks in queue : 0
    Commands in queue : 0
    Call Waiting : Disabled
    Current device state : start
    Desired device state : start
    When change state : now
    Calls/Channels : 0
    Active : 0
    Held : 0
    Dialing : 0
    Alerting : 0
    Incoming : 0
    Waiting : 0
    Releasing : 0
    Initializing : 0

  27. I got Huawei E303. When the modem is unlocked. When I connect the dongle to Raspbx it does not create any ttyUSB devices. Not sure what is wrong. But it does create something like this:

    [ 13.391467] usb 1-1.4: new high-speed USB device number 5 using dwc_otg
    [ 13.522426] usb 1-1.4: New USB device found, idVendor=12d1, idProduct=14db
    [ 13.541224] usb 1-1.4: New USB device strings: Mfr=2, Product=1, SerialNumber=0
    [ 13.550073] usb 1-1.4: Product: HUAWEI HiLink
    [ 13.571204] usb 1-1.4: Manufacturer: HUAWEI
    [ 13.624114] Adding 204796k swap on /var/swap. Priority:-1 extents:4 across:270336k SSFS
    [ 13.681022] cdc_ether 1-1.4:1.0 eth1: register ‘cdc_ether’ at usb-bcm2708_usb-1.4, CDC Ethernet Device, 58:2c:80:13:92:63
    [ 13.713483] usbcore: registered new interface driver cdc_ether

    • sudo usb_modeswitch –default-vendor 0x12d1 –default-product 0x14fe –message-content 55534243123456780000000000000011062000000100000000000000000000

  28. hi
    i have got one e173 and one e1550 dongle but none of them are being displayed in /dev/ttyUSB*

    i have tried modeswitch but it did not worked
    please help

  29. hello all

    Actually i am interested in this field, but know the gsm gateways perfectly,

    if i have to design my own solution for termination,

    from where i have to start to learn it
    mean linux server or asterisks server please tell me in first what i have to understand than others
    desiscribe in Bullets of in numbring form

    AS like flow chart, please i want to understand the complete scenario of voip termination

    wating for your guide line

    • What model E173L do you have? I’ve got a E173Ls-5 and my outgoing calling is working but my unit doesn’t receive incoming calls.

  30. Hi,

    I’ve got a stupid question. :S
    When you’re taking about the SIM number here:
    “On the incoming route set DID Number to your SIM number, precisely matching the number you entered when running the install-dongle script.”
    Then you are talking about the mobile phone number, right?

    Best regards

    • Alright, my dongle had voice disabled, despite DC Unlocker showed enabled most of the time. – Faced that issue with a E1550 by 3 AT.

  31. I bought a Huawei 169 and it didn’t have a SIM in it. What would be a good provider to do pre-paid to connect to SIP provider? I really only want to do for testing and would be used as a back if my internet went down. Its for home use only so only a couple users would be using the system. I really only wan to pay a 1 time fee, and renew as needed so no re-occurring.

  32. Can somebody help me, i have installed chan_dongle, everything works perfect (in/out) but now i want a disa with pin, but i cannot get a pin in, everytime pin incorrect. Seems it doesn’t recognize my pressing.
    if i get on the same disa via landline (SPA3000) it works perfect, gets the pin and continues. But over GSM Stick with different mobile phones it doesnt work. No inputs works… How to get this done?

    • You could experiment with the dtmf= option in /etc/asterisk/dongle.conf. Maybe a different setting than the default works for you.

  33. Hi all,

    Just wondering how I would go about adding a second dongle to my Pi? I am not sure how to install the second one??

    Any help would be appreciated.


    • First of all you need to have a powered USB hub for both dongles. Unfortunately not all of these hubs are working well enough, maybe you need to try a few. Then install the first dongle according to the description. For the second dongle, edit /etc/asterisk/dongle.conf, copy everything below [dongle0] and name these settings [dongle1]. Then insert the correct ttyUSB devices for audio and data in section [dongle1]. You might need to set the subscriber number in your dongles, please refer to the original documentation at how to do this.

  34. Got the E156G running fine.
    No AT commands will enable voice, I had to use dc-unlocker, which worked Perfectly, instantly!
    Works on 3 (Three) network in UK, not tried others. SMS also works without needing unlock, not tried USSD yet.

  35. Pingback: Personal phone server, or Can you hear me now? « ClickedyClick

    • Can you tell me where you bought the E169. I see there are some variants which don’t support voice. Thanks.

  36. I am interested in using GSM gateway and huawei e173 to terminate calls to mobile phones. I need 24 channels running 100 percent operation including all the router, powerbar, battery backup, laptop and cellphone.