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, it’s the one that says 12d1:1f01 Huawei Technologies Co., Ltd.
But you can’t use it to connect to the internet yet. You can see that running ifconfig won’t turn up the EC315.
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 by typing
sudo apt-get install usb-modeswitch
Now unplug the EC315 from the Raspberry Pi, wait a second, and plug it back in.
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.
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!
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.
Footnotes:  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.