Archive for the ‘raspberry pi’ Category

Raspberry GSM Gateway

Tuesday, March 19th, 2013

The idea of building my own GSM gateway came to me after travelling several times to my favourite hideaway abroad, Cambodia, over the last 6 years.

My german cellular provider for some reason doesn’t have a roaming agreement with the cambodian telcos and so my wellknown phonenumber back home was never reachable during my absences. Even if the providers would have had a roaming agreement, still an unreasonable roaming charge of about 2€ / min. for the call diversion would apply which is impracticable to me, considering the vast amount of extensive business phonecalls I expect every day.

Means, every time at Frankfurt airport when leaving for Asia I had to record an out-of-office message on the mailbox, referring callers back to the fixnet office number at least which I was able to redirect via a VoIP Provider to my cambodian cellular number. Termination of VoIP calls to the cambodian cellular networks is around 0,05€ / min. so this appeared to be a humble still viable workaround.

The voice quality of such a commercial VoIP connection though was beyond any acceptable level, huge delay, dropouts and unreliable call setup. It appeared that the VoIP call had to find it’s way to cambodia through a couple of wholesellers which caused the bad sound quality. Tried several VoIP providers, not much difference between them though, making 0,05€ / min a less good deal, all in all.

The solution for all my requirements seemed to manifest in building my own roaming network which would involve the use of two GSM gateways, one taking my german SIM in Berlin as a receiver, and one gateway in Phnom Penh as a call termination towards my cambodian GSM provider, holding a Cellcard SIM. Cellcard as many other cellular providers in emerging countries offer special rates on intra- net calls of 0,02 USD / min and below.

So far for the rough strategy. Sourcing for suitable SIP based GSM gateways, i was confronted with prices per GSM port between 200 – 400 €. For this to pay off, I would have to make a whole lot of phonecalls, I thought. So – why not try first building my own GSM gateway before spending such an amount on a black box ??

Googling a bit beamed me to a project page named chan_datacard, respectively chan_dongle which in essence is an Asterisk channel driver that drives Huawei 3G sticks. Those – beside being UMTS / HSDPA modems – are voice- SMS and USSD- capable as well. Actually a fully fledged mobilephone, just without display and keypad, mic and speaker. So all i would need there would be a host platform that runs an Asterisk and drives a Huawei dongle, one device in each country..


The company i work for builds some of the largest Asterisk based systems on the planet, so we all were just excited to have a look into the very opposite extreme – the currently smallest possible Asterisk box. There were some few opensource projects that theoretically could serve as a basis for building such a gateway out of a DSL router, but the cpu power of those routers did not convince me much. Else, documentation lacked alot.

Then, eventually i stumbled across the Raspberry PI and the Raspberry Asterisk project, RasPBX. Here the setup we came up with:


This is my installation in Phnom Penh, Cambodia, the german counterpart looks much alike. In the center you find the Raspberry PI, the Huawei dongle below is served via a powered USB hub, since at GSM activity the dongle would draw too much current from the skinny builtin USB host of the RPi if being directly connected to it..

OS Installation worked without a hitch, the dongle could be succesfully connected to the RPi within one day. This is what had to be assembled:

RPi – 50€
Huawei E173 HSDPA Surfstick – 25€
USB Modeswitch

A total BOM of 75€ (!) for a full featured GSM gateway…


Now when a caller in Europe calls my german GSM number, first my domestic Snom phone (right upper corner) rings, then after 5 seconds, my cambodian mobile phone gets called. As a sideffect, my cambodian friends from now on can call and SMS my german phone back at local rates of a few cents..

The connection quality over the 10.000 km spanning 64 kbps Asterisk SIP trunk between both gateways actually is so amazing that none of the callers even noticed that i was out of the country at the time !


Next we are going to install the identical RPi based GSM gateways at both our offices in Switzerland and Russia, VoIP- interconnected via our central (Asterisk based) PBX system in Germany, abstracting every employee’s mobilephone across the globe to a virtual extension within the company. Among many more obvious features we now are able to conduct conferences across the borders, at local call rates.