Connect 3G Dongle in Raspberry Pi4

Nidhin kumar
Dec 20, 2020 · 5 min read
Image for post
Image for post
Source: Nidhinkumar

Overview

In this post, we will see how to connect a 3G Dongle in Raspberry Pi4 which has Ubuntu 20.4 LTS OS installed

Objectives

  1. What is Raspberry Pi
  2. What is Sakis3G
  3. What is SSH
  4. Connect Raspberry Pi in headless mode
  5. Install usb-modeswitch and PPP
  6. Copy Sakis3G and make it single executable
  7. Connect the 3G Dongle using Sakis3G

Prerequisites

  1. Raspberry Pi4 — (Ubuntu 20.4 LTS OS installed)
  2. 3G Dongle (The Dongle which i am having is Huawei 3533 Modem)
  3. Network connection

1. What is Raspberry Pi

The Raspberry Pi is a low cost, credit-card sized computer which enables people of all ages to explore computing, and to learn how to program in languages like Python.

Raspberry Pi is capable of doing everything you’d expect a desktop computer to do like browsing internet and playing high-definition video and games.

2. What is Sakis3G

Sakis3G is a tweaked shell script which is used for establishing a 3G connection with any combination of modem or operator.

3. What is SSH

Secure Shell (SSH) is a method for communicating with another computer securely. ‘Secure’ means the data sent via SSH connection is encrypted.

Example of SSH mechanism is User A sends a brief case to User B. User A locks the brief case and sends it to User B. User B receives the brief case but it cannot be opened since it doesn’t have the key. so User B puts another lock and sends it back to User A and then User A unlocks with the key and sends it back to the User B.Now User B can unlock the briefcase with the key.

This means if a third party tries to intercept the information being transferred it would appear scrambled and unreadable.

4. Connect to Raspberry Pi in headless mode

Now we will connect the Raspberry Pi in headless mode (Using SSH).Make sure your system and Raspberry Pi connects to the same network.

Now open the terminal in your system and type for ubuntu and get the inet address from Ethernet like below

Image for post
Image for post
ifconfig

Once you copy the inet address type the command to see the list of devices connected to the network and copy the IP address of the RaspberryPi.

Once copied connect to the RaspberryPi using the SSH commnd

ssh ubuntu@192.168.43.125

where ubuntu is the name of the RaspberryPi device.Once connected you could see a screen like below

Image for post
Image for post
RaspberryPi -SSH connection

Now we have connected to RaspberryPi in headless mode.

5. Install the usb-modeswitch and PPP

Now we will install the usb-modeswitch and PPP in Raspberry Pi using the below command

sudo apt-get install usb-modeswitch
sudo apt-get install ppp
Image for post
Image for post
usb-modeswitch installation

Now we have installed the usb-modeswitch and PPP in RaspberryPi.

6. Copy Sakis3G and make it single executable

Now we will copy the Sakis3G file from local machine to RaspberryPi using Secure copy (SCP).Create a new directory named in RaspberryPi

Use the below command to copy the Sakis3G to RaspberryPi.Makesure you have opened a new terminal in your local machine which has the sakis3G file else provide the path of where the sakis3g file is located

scp sakis3g.tar.gz ubuntu@192.168.43.125:~/dongle/
Image for post
Image for post
Secure Copy

Once the file is copied to the dongle folder you can check it using the command where you can see the sakis3g file like below

Image for post
Image for post
Sakis3g file in RaspberryPi

Now we will unpack the Sakis3G file and make it executable file using the below command in RaspberryPi.(Make sure you have navigated to the dongle directory in RaspberryPi)

sudo tar -xzvf sakis3g.tar.gz  //unzip the file
sudo chmod +x sakis3g //making it executable

Once done we are ready to connect but before that check whether the dongle connected is in Modem mode or in Mass storage mode using the command

Image for post
Image for post
Mass storage mode

If you see in the above pic the dongle is in Mass storage mode which needs to be changed as Modem mode.

To make it in modem mode use the below command(Below command works for Huawei Modem)

sudo usb_modeswitch -v 12d1 -p 14fe -M '55534243123456780000000000000011062000000100000000000000000000'

Now if you run the command you could see the dongle changed to Modem mode like below

Image for post
Image for post
Modem/Networkcard

7. Connect the 3G Dongle using Sakis3G

Now we will connect the 3G dongle using the below command

./sakis3g --interactive

which will open the sakis3g interactive tool like below

Image for post
Image for post
USB Modem

Select HUAWEI Mobile which will move to the next screen lik below

Image for post
Image for post
Interface

Select the Interface #0 and enter which will move to the APN screen like below

Image for post
Image for post
APN screen

Select the APN and click enter

Image for post
Image for post
APN username and password

Now it will ask for the username and password.For BSNL there is no username and password.Instead we can pass empty space and click ok which will try to connect

Image for post
Image for post
Connection successful

Now we have connected in 3G Dongle successfully.To see which is the default connection we can check it in like below

Image for post
Image for post
Route table

The default connection in the route table is dongle (Iface is ppp0).If you want to connect the dongle automatically we can use the UMTS keepeer which we will cover in the next part.

Reference Links

https://askubuntu.com/questions/1145645/huawei-e3131-modem-shows-as-mass-storage

Congratulations!

You have learned how to connect a 3G dongle in RaspberryPi4

Happy Learning :)

CodingTown

Today a Reader, Tomorrow a Leader

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store