Pradeep CE

Indie maker, solopreneur, travel enthusiast, and aspiring writer :)

Internet on the Raspberry Pi 2 with a 3G Dongle

January 24, 2016

I’m working with a Raspberry Pi 2 for my final-year project in college. We needed internet connectivity on the Pi, and a friend (and team-member) of mine had a Tata Docomo Photon Max WiFi Data Card. So we decided to put these two together.

The data card (3G dongle / WiFi adapter) is actually a Huawei EC315. It can act as a USB modem as well as a WiFi access point. And as it turned out later, it was a near-perfect choice for the Raspberry Pi.

I’ll assume that you’re running the latest Raspbian / NOOBs distro on your Pi, and you have completed the initial setup process.

First off (if you haven’t done it already) update your package lists.

sudo apt-get update

Now plug in the EC315. You should be able to see it listed by lsusb. In the picture, its the one that says 12d1:1f01 Huawei Technologies Co., Ltd.

Output of lsusb

But you can’t use it to connect to the internet yet. You can see that running ifconfig won’t turn up the EC315.

The 3G dongle is still not recognized as a modem

This is because most data cards these days come with a small on-board memory that contains the necessary drivers to make them work on Windows machines. When you plug them into a Windows machine, this memory is mounted, the required software is installed, and the data card is then “switched” to a “modem” mode that lets Windows recognize it as a USB modem.

But on Linux systems, you need a program to “switch” your data card to “modem” mode. usb-modeswitch is a program that does just that.

Install usb-modeswitch

Install usb-modeswitch by typing

sudo apt-get install usb-modeswitch

Now unplug the EC315 from the Raspberry Pi, wait a second, and plug it back in.[1]

If you run lsusb now, you can see that the device ID of the data card has changed. This is because usb-modeswitch has now switched your data card to “modem” mode.

usb-modeswitch doing its job

You can also see that the EC315 turns up as an ethernet interface in ifconfig. This is why the EC315 is a near-perfect choice: it works right out of the box with usb-modeswitch, with no additional configuration whatsoever. You can now start surfing right away!

The EC315 is shown as eth1

An interesting (and convenient) thing to note is that even if you shutdown your Pi and start it up again now, the data card will still be recognized as a modem. This will make life easier if you want your Pi to run unattended.

If this doesn’t happen with your data card, then you might need to install a program like wvdial that will let you configure a dial-up connection. For more information about this, take a look at this post of Nico’s, that I started off on.


  1. Though just unplugging the data card and plugging it back in worked for me, you might need to restart your Pi if it doesn’t. Supposedly, sudo udevadm trigger emulates a hotplug; but it didn’t work for me.

This post used to be a part of my old blog, and was migrated here for legacy reasons.

The views and opinions expressed on this site are my own. They do not reflect the views or policies of any employer or client, past or present.

Pradeep CE | Copyright © 2022 | | v2.0