Get Cellular (GSM) Internet on Your Raspberry Pi in 15 minutes

This is a topic that's been explored time and time again on tech blogs, since the first Raspberry Pi was released. So why am I doing a write-up now? Because I felt that what is missing is a straightforward walkthrough that includes all config files and scripts, so that the average enthusiast can get a device connected to the Internet without spending excessive time Googling and troubleshooting. 

This tutorial and associated scripts will help you get your Raspberry Pi online through a cell phone provider. It will enable your device to be continually connected to the internet via GSM data from the time it powers-on, so that you won't have to set it up again. You'll need a small bit of familiarity in already working with a Pi and with entering some Linux commands, but if you get stuck, definitely let us know! 

 

Pre-req's and Caveats

You'll need the same hardware and services as us. This includes an unlocked Huawei E303 USB peripheral and a Ting SIM card. You'll also need a Raspberry Pi with the stock Debian Wheezy (NOOBS default) image up-and-running.

To make it simple, I'm providing links to purchase the GSM card and Ting card below, as well as the configuration scripts and settings I used, which should save you lots of googling and trial-and-error. 

  • The Huawei E303 USB peripheral can be bought on Amazon. Here's the one I bought: http://www.amazon.com/gp/product/B00P5UJA0Q?psc=1&redirect=true&ref_=oh_aui_detailpage_o02_s00. Be sure to buy one that's unlocked! 
  • Go to www.ting.com and order a SIM card. They have very low rates, great support, and easy setup on most devices. You could re-use your Ting SIM card in other phones/devices, too. 
  • You'll see the Raspberry Pi B+ in the picture, as well as an Adafruit 3D Printed case and some peripherals. I'll assume you have a similar setup, but if not, an older Raspberry Pi Model B will work, and the newest Raspberry Pi 2 should work, too. 

I won't go into basic setup and install of the Debian Wheezy OS; there's plenty of blogs out there that do a good job - this post is just about getting GSM data working. So now let's get into the technical stuff...

 

Initialize the SIM Card and GSM Peripheral

The Ting SIM must first be activated through your account on Ting.com. To get the SIM connected to ting.com for the first time, just to be sure it's working properly, you could use their Support articles, like this one for iOS. If you do this in an tablet or smartphone, then skip the steps below and go on to the GSM Keep Alive Configurations section later on. Otherwise, to activate the SIM + Huawei USB peripheral in your Pi, take these actions: 

  1. Insert the Huawei USB peripheral with the Ting SIM inside it into the Pi and power-on. 
  2. Run "sudo apt-get install ppp usb-modeswitch wvdial" on the command line to add some pre-reqs/tools. 
  3. Now replace the contents of the /etc/wvdial.conf file on your Pi with the contents in our Ting_wvdial.conf file. Be sure to keep the wvdial.conf file with the same filename (we renamed ours on our site to differentiate between different conf files we have for various carriers and devices). 
  4. Do the same for /etc/usb_modeswitch.conf using our file Huawei_E303_usb_modeswitch.conf. Again, be sure to keep the same file name of usb_modeswitch.conf. 
  5. Restart the device with "sudo reboot"
  6. After power-on and login, type the following command to connect to the Ting/T-Mobile network: "sudo wvdial 3gconnect &". After it connects successfully, try running some ping and curl commands to test internet connectivity (make sure your WiFi and ethernet's unplugged at this point ;)
  7. Reboot again and proceed to the next steps for setting up scripts to allow for continual GSM connectivity.

 

GSM Keep Alive Configurations 

Assuming the Huawei + Ting combo has been initialized and connects a Raspberry Pi correctly, the following steps can now be taken to enable UMTSkeeper/Sakis3G scripts to the work of continually connecting your Pi to the internet. 

  1. If usb-modeswitch and ppp have not yet been installed, go ahead and do so with the following command: "sudo apt-get install ppp usb-modeswitch"
  2. Create a directory for the UMTSkeeper/Sakis3G script, e.g. cd; mkdir umtskeeper
  3. Download UMTSkeeper to your new directory, e.g. cd; cd umtskeeper; wget "http://mintakaconciencia.net/squares/umtskeeper/src/umtskeeper.tar.gz"
  4. Unpack/"Untar" the downloaded file archive in the umtskeeper directory, e.g. tar -xzvf umtskeeper.tar.gz
  5. Allow umtskeeper and sakis3g scripts to be executed in Linux, e.g. chmod +x sakis3g umtskeeper
  6. Now we'll need to add working configuration files for these utilities to the Raspberry Pi. If you didn't do so already in the Initialize the SIM Card and GSM Peripheral section above, replace the contents of the /etc/usb_modeswitch.conf file with ours: Huawei_E303_usb_modeswitch.conf. Be sure to keep the same filename of usb_modeswitch.conf on your system. 
  7. Now replace the contents of the /etc/rc.local file with the contents in our file: umtskeeper_rc.local. Again, be sure to keep the same filename of rc.local for your system. 
  8. Restart the device with "sudo reboot". 

Once restarted, it will take about a minute from the time of power-on to get internet connectivity. You'll know you have internet connectivity by looking at the Huawei dongle and observing the green LED light, which will be solid green (not blinking). If it's blinking, the device is not connected to the internet. You can check connectivity by running some pings and curl commands. 

And that should be it! Many thanks to Trevor and Bryan on the team for helping create this setup. 

I hope this is just a starting point for you to start tinkering with your very own Internet of Things platform. Definitely let us know how you do!