Tuesday, February 16, 2016

3G Connectivity With Raspberry Pi using Huwaei E303 Dongle

  Hi Guys. In this post we will see how to provide internet connectivity to Raspberry Pi using 3G USB dongle. This comes handy in many cases.The internet connection will be provided by a Huawei E303 USB 3g dongle on the vodafone network Odisha.



Setup
                            Power Source -------->RPI--->(USB) 3g Dongle
         
  The USB port of the PI doesnot have enough power to provide to a 3G dongle so if you plug directly the dongle onto the Pi the Pi may behave unwantingly which can be avoided by using an externally powered USB hub. I Raspbian Wheezy on Raspberry Pi. Next is after connecting the dongle to the Pi is to check if that has been detected by Pi. To get a list of USB connected devices type :

   $ sudo lsusb



   The output of the above command will be something like this :
      
   Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
  Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
   Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
   Bus 001 Device 010: ID 12d1:1504Huawei Technologies Co., Ltd. E398 LTE/UMTS/GSM Modem/Networkcard

 I have higlighted the output that shows the detected USB dongle. Most of the USB dongle comes with partition hosting drivers. So their might be chance that the Pi detects the dongle as mass storage device. Don't worry about that just install usbmodeswitch.To install, in the terminal window type:

   $ sudo apt-get install usb-modeswitch

The usbmodeswitch just helps to change the mode of the dongle from mass storage to modem.


Download and setup  UMTSKeeper and Sakis3g

UMTSKeeper

 UMTSkeeper is used to automatically reconnect the 3g dongle using the Sakis3g script should the connection drop, which actually happens quite a few times. Download and unpack UMTSkeeper by issuing the following commands from the terminal window:

$ sudo mkdir umtskeeper
$ cd umtskeeper
$ sudo wget "http://zool33.uni-graz.at/petz/umtskeeper/src/umtskeeper.tar.gz"
$ sudo tar -xzvf umtskeeper.tar.gz
$ sudo chmod +x umtskeeper

 The first command created a folder called 'umtskeeper' in the current directory you are in. To confirm what this directory is, type 'pwd'. Make note of the output, as we will need the full path to automate UMTS keeper later. Now we will download Sakis3g into the same directory to keep things simple.

Sakis3g

 Sakis3g is a script used to make a 3g connection. You need to be able to provide a few details: your APN, the PIN for your sim card and your username and password if your provider requires them. This information can (hopefully) be found on your providers website or in the documentation that came with your simcard/dongle. If not, a search on google for 'your provider APN settings' should unearth them. The sakis-3g.org website has been down for some time. Fortunately somebody has uploaded a copy of the script to sourceforge. To download and unpack it, issue the following commands from the terminal window:

   $ sudo wget "http://downloads.sourceforge.net/project/vim-n4n0/sakis3g.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fvim-n4n0%2Ffiles%2Fts=1363537696use_mirror=tene~t" -O sakis3g.tar.gz
   $ sudo tar -xzvf sakis3g.tar.gz
   $ sudo chmod +x sakis3g

Before going further, you should attempt to make a 3g connection using the sakis3g script alone, proving everything you've done up till now works. Sakis3g has an interactive mode, which will prompt you for information regarding your 3g connection. In the terminal window, type:

    $ ./sakis3g --interactive


and follow the prompts on screen. If you have no APN user or password, enter '0'. Once a connection has been made, make sure you can browse the internet, or issue a ping from the terminal window:

   $ ping  www.google.com

Now test UMTSkeeper. The command at first may look a bit confusing (the details are for my connection):

$ ./umtskeeper --sakisoperators "USBINTERFACE='0' OTHER='USBMODEM' USBMODEM='12d1:1506' APN='CUSTOM_APN' CUSTOM_APN='www'  SIM_PIN='1234' APN_USER='' APN_PASS=''" --sakisswitches "--sudo  --console" --devicename 'Huawei' --log --silent --monthstart 8 --nat  'no'

Breaking it down a little, these are the areas that you will need to change:

USBMODEM: The Device ID we found using the lsusb command earlier

CUSTOM_APN, APN_USER, APN_PASS, SIM_PIN: Information about your sim card and your providers data network.

A full breakdown of the paramaters can be found on the UMTSKeeper site..

Once you are satisfied UMTSKeeper is working in harmony with Sakis3g, we can edit /etc/rc.local so that it starts when the operating system boots. In the terminal window, type:

 $ sudo nano /etc/rc.local

and add the following single line, edited to show your path to the umtsfolder you found with the 'pwd' command earlier:

 Path_to_umtskeeper_folder/umtskeeper --sakisoperators "USBINTERFACE='0' OTHER='USBMODEM' USBMODEM='12d1:1506'  APN='CUSTOM_APN' CUSTOM_APN='www' SIM_PIN='1234' APN_USER=''  APN_PASS=''" --sakisswitches "--sudo --console" --devicename  'Huawei' --log --silent --monthstart 8 --nat 'no' 

Exit, saving changes and reboot to enjoy uninterrupted 3G internet connection.

$ chromium -kiosk  //Install Gogle Chrome

No comments:

Post a Comment