3G Internet on Raspberry Pi - Success!

This is a bit of a brain dump of how I got a 3G USB dongle working on the Raspberry Pi. Following on from getting the Raspberry Pi to send SMS.

That's The Power Of Love

The first thing to say is use a powered USB hub! I had lots of problems getting the modem working when it was plugged directly into the Pi. A 3G signal takes more power than the Pi's USB sockets can supply.

3G Raspberry Pi

In the above image, you can see that the Raspbery Pi is plugged into the mains - via a 1.8A plug.
The USB cable has two male ends. The black plug goes directly into the Pi for data. The red plug goes into the mains via a 1A plug (an Amazon Kindle adapter).

I used a USB Y Cable to supply power and data.

I also tried plugging both plugs into the Pi - that didn't work either. You need a separate powered hub.

Rather than use two plugs, I'm going to try to find a mains plug with two USB sockets. Each socket needs to supply at least 1A. Something like this looks like it should do the trick.

Or, you can use a cable like this.

Put one male USB plug into the PI and the other into a power supply. The dongle fits into the female USB socket.

P-p-p-p-pick Up A PPPD

In order to get our network connected, we need to install the ppp package.

sudo apt-get install ppp

If You Think I'm Sakis, And You Want My Body...

I tried using wvdial and numerous other ways to connect to 3G. None of them worked reliably. In the end, I turned to sakis - the All-In-One script for connecting 3G modem.

Sakis says it is:

"The easiest way to have your 3G/UMTS/GRPS connection up and running."

I can't argue with that!

Installation is very simple:

First, download the latest version. The Raspberry Pi runs on an ARM processor, so this is the version we download.

wget "http://www.sakis3g.org/versions/latest/armv4t/sakis3g.gz"

The script is compressed. Unzip it.

gunzip sakis3g.gz

Finally, we want to make the file executable so that we can run it.

chmod +x sakis3g

Running sakis is quite straightforward. It has a basic GUI which will work even if you're just using the command line.

sudo ./sakis3g --interactive

sakis3g interface

Sakis has a fairly comprehensive list of connection details - it should find yours automatically and present you with this screen.
sakis3g interface APN

If it doesn't know your connection settings (if you're on GiffGaff for example) you can manually enter them.

All being well, after a few seconds, you should see this screen.
sakis3g interface connected

You can now exit sakis. You will stay connected.

To check the details of your connection, run the following command:

sudo ./sakis3g connect info

You'll get back something like this:

K3565 connected to giffgaff (23410).
Connection Information
 
Interface: P-t-P (ppp0)
 
Connected since: 2012-07-13 07:36
Kilobytes received: 2
Kilobytes sent: 2

Network ID: 23410
Operator name: giffgaff
APN: giffgaff.com
 
Modem: K3565
Modem type: USB
Kernel driver: option
Device: /dev/ttyUSB0
 
IP Address: 10.136.6.52
Subnet Mask: 255.255.255.255
Peer IP Address: 10.64.64.64
Default route(s): 10.64.64.64

That's it! You can now access the Internet via your 3G modem.

Surfin' Safari

One last tip for you! There's no need to start your window manager to surf the web. There's a brilliant lo-fi web browser called Lynx.

You install it by typing:

sudo apt-get install lynx

You run it by typing:

lynx http://www.bbc.co.uk/news

(or whatever website you want to visit).
lynx on the Raspberry Pi

So, that should be everything you need to get the Raspberry Pi connected over a USB 3G dongle. Have fun!

86 comments

  1. juanRIOT

    Magnificent! Thank you for this tip.
    Ever since I ordered my Raspi, Ive been tossing and turning my brain on how I can connect to 3G with it.

  2. Jimbob

    Hi there,

    I've been reading a lot about Raspi, being a former A-Level computer science student (back in the early/mid 1990s). It's a great idea. But after hearing more on the Guardian tech weekly podcast I got wondering, would is be possible to also create programming simulators for iphone/ipad/android as another simple way to get kids back into the fun of programming? Using some simple gamification to create interest.

  3. SRullo

    Hi!
    I need some help to connect a vodafone usb modem with my raspberry.
    Are you installed an external library? I'm working with Wheezy and Sakis3g has some issues to connect it..
    Thanks!

  4. richard

    hi
    I am trying to setup my E220 modem.
    May i know which version OS are you using?
    I am using ArchLinux.
    Thanks
    Rgds
    Richard

  5. Andrew

    Is there a way to share this internet connection with other (Windows) PC's on my LAN?

  6. Ferdinando

    Hello,

    I've successfully installed sakis and get it worked perfectly. I've also installed no-ip client to get a dynamic IP and it works. I easily connect through lan via ssh and tightvnc but i cannot get access to ssh ot vnc via the 3G connection even if i use the direct IP read from ip addr
    I've tried also without the lan connection, no-ip resolve the dns as I see it changes after a while, but no connection at all.. any suggestion?

  7. sanjay

    right now i don't have Internet in my raspberry pi, is it possible to download sakis3g.gz & copy on a Pen-drive & install it on raspberry pi,

    Step by Step Instruction will be helpful as i'm totally new to linux.

    Thanks & regards,
    Sanjay

  8. Marko Novak

    Hi Terence!

    First of all, thank you for posting these instructions.
    They helped me setting up the GPRS connection from my raspberry pi tremendously! :)

    One question though...
    You mentioned at the beginning of your post that a powered USB hub has to be used.
    I plugged the Huawei Vodafone modem directly into the USB slot of the RPi (without the powered USB hub) and it works fine. It successfully connects to the internet and I'm able to do all the browsing and stuff.

    Since I'm using the latest revision of the RPi (rev 2, the one made in the U.K., bought in september 2012), have you perhaps heard if the USB powering problem has been fixed for that revision? Or is it possible that I'll will be experiencing the random dropping of my GPRS connection?

    • Terence Eden

      Hi Marko,

      It's possible that the new boards give more power. If you're on 2G (GPRS) that also uses less power, so that might be the reason.

      T

  9. Richard Brown

    Hi Terence

    Thanks for the article and heads up. Unfortunately we are getting an error message with our huawei hilink on O2. It basically says, "Failed to connect". Any ideas please?
    Thanks
    Rich

    • Terence Eden

      Is it plugged into a powered USB hub?
      Do you have credit on your SIM?
      Are you allowed to use dongles on your mobile tariff?

      Any more specific errors?

  10. Damage

    Terence, you really are a life-saver :) I was troubleshooting ZTE MF688 for a week because device was obviously restarting when I made wvdial connection. It's so simple, I just plugged 3G modem into powered USB hub and it worked. Thanks for the advice!

  11. Mequa

    Hi, could this work on Raspbian with Vodafone Mobile Broadband K3770, HSPA USB Stick (Huawei Technologies)? (It's a pay-as-you-go service which I have topped up.)

    I have the first revision Pi. I don't yet have a powered hub, trying the above steps with it plugged directly into the Pi, the device showed in the list, but gave "failed to connect" when selected. Is a powered hub all that's needed to fix this?

      • Damage

        Powered hub is definitely a preferred solution, Y cable is not - "except" if you plug the red USB connector into another device, to get some extra power. I my case I've tried to plug it in TV (0,5A) and it worked. I have also plugged RPi into TV (1A) and it still worked.

  12. Mequa

    Hi, could this work on Raspbian with Vodafone Mobile Broadband K3770, HSPA USB Stick (Huawei Technologies)? (It’s a pay-as-you-go service which I have topped up.)

    I have the first revision Pi. I don’t yet have a powered hub, trying the above steps with it plugged directly into the Pi, the device showed in the list, but gave “failed to connect” when selected. Is a powered hub all that’s needed to fix this?

  13. fcastril

    Hi, do you know how send SMS to mobile ?
    I have a project that need to send information to my mobile by SMS while a switch is pressed on.
    Thanks

  14. Henry

    Hi Terence,
    love the article, great desktop pic!
    I've been thinking about installing my raspberry pi in the car with 3g. What I would like to be able to do is read information about the strength of tower signals around me with the intent of locating the car. Have you any idea if I can read this information from a stick (don't have one yet, any suggestions would be welcome)?
    Also saw the other great piece about sending SMS's. All cool stuff!

    • Richard M

      Why not use GPS to locate the car? You can use a USB GPS receiver to locate the car and the 3G dongle to either send you information by smms, email or some other means over the internet

  15. Jan

    trying to access the sakis3g.org site now since two days but is seems to be down, is there another way to get that file somewhere?

  16. Jan

    yes it's back, sorry for the confusion. wish everyone would use code hosting like github for such projects.

  17. Amogh

    Hello. I am trying to connect a Pantech UML 290 to my rpi running wheezy I have tried everything but killing myself to get connected.
    Sakis 3g kept throwing a modem does not have gsm capabilities at me and when I tried - - no probe it gave me a pin error. I have also tried wvdial but it does not work on arm as it should. have also tried ppp chat script but it keeps throwing a connect script error at me
    Could you please help me?

      • Amogh

        Well the dongle works fine on my laptop with vza . It is on a powered hub. And in vza I have disabled pin.

        • Amogh

          Any ideas ananyone? I have already tried ppp which gives me connect script failed. I have a project due within a week .please help out folks

  18. Marius

    This was a great tutorial! But how can I connect automatically when I reboot my Raspberry pi? Im planning to run my Pie without a monitor...

    Best regards Marius

  19. Michael

    Hi im trying to connect my ZTE MF665C but every time i select in the option for which device it comes and says failed to connect, i have no idea whats wrong.

    i have it connected to a usb powered hub

  20. Peter

    Thanks for sharing this. I am interested in doing this with a prepaid SIM card that charges per txt and MB of data. As such, I want to eliminate unwanted background network access-- e.g. even when I am not using my Macbook, there are a lot of small internet accesses that I can snoop using netstat. Is this a problem with the Raspberry Pi? I want to leave the RPi on 24/7 and only plan on sending ~5 SMS messages per month at 10 cents each and am worried that the low level data usage will overwhelm the savings from $10 per 3 mo plan.

    Could you possibly run netstat to snoop your internet connection for a while and give me an idea of how much background activity there is?

    • Terence Eden

      With the default install, I think the only internet access should be from the update checker - which you can disable. If you only care about SMS, you don't need to use data at all.

  21. Nick

    Hey. First off, nice post. By far the clearest I've found on the subject. Not having much joy getting 3g going on my pi though. I get 'failed to connect' everytime. I'll list my process-
    Using Huawei E3231 on 3 (UK)
    Latest wheezy raspbian (fresh install and updated)
    Dongle works as expected under windows
    lsusb = ID12d1:1f01 (is that the issue?)
    Followed your instructions
    Get same error everytime

    I'm still pretty new to all this so I'm finding it hard to even search for a solution. I'm trying to get my head around usb_modeswitch.
    Unfortunately, I've not come across any reports of this device working with R-Pi. There must be a solution though(fingers crossed). Any ideas? Cheers

      • Nick

        Cheers mate, I'll give it a go. Don't know how I managed to miss that post. Running my pi's and peripherals form a converted PC psu so no problems with power. Nice one for the quick reply.

        • Nick

          Hi again. I tried the recommended post. Didn't get far though. Couldn't get the thing to perform a switch. It states you use the command- /usr/bin/sg_raw /dev/sr0 11 06 20 00 00 00 00 00 01 00 to switch with sg3_utils. I get- do_scsi_pt: Bad address.
          I don't know what the numbers represent in this command but I'm assuming it's that. I've posted a message on the other post(waiting for reply) but I thought I'd try my luck here as well. Cheers

  22. Pingback: でっかいさとるさん » Blog Archive » Raspberry Pi 3G接続 その3
  23. lepidas blades

    first of all i want to say that this project is really useful BUT i got no joy connecting my huawei e1750 over 3g. when i start sakis it asks what to do and i say connect to 3G but the response is Embedded Usb-ModeSwitch binary is not valid for your architect. You need to recompile for devices to switch properly: ./sakis3g recompile.

    I am possitive I downloaded the link you gave, also i use raspbian.

    if any advice thank you very much

  24. Nick B

    Worked for me, using a Huawei E169 on 3UK.

    I'm curious to know what speeds people are getting? I ran a quick speed test which showed 1MBps but that could be down to network congestion/weak signal.

    I'm using a later Pi and mine works without a powered hub. The second USB slot is used for the keyboard/mouse via a PS/2-USB adaptor.

  25. exstud

    Is it possible to send sms while keeping the 3G internet connection open or do I have to close it?

    • exstud

      It did work simultaneously... my 3g router (huawei) was listed as 3 lsusb devices, the lsusb2 accepts AT commands...

  26. Tony

    Will this automatically reconnecting when/if the connection is lost, or would I need to manually reconnect by running the sakis3g script again?

      • Lewis Wight

        Is there anyways to automate this? I find if I leave the connection open too long I have to reconnect, I would like it to maybe try and reconnect on its own if the connection is lost.

  27. Mark C.

    Hi Terence,

    What are your thoughts with tethering an android phone via usb and using it as a modem for the pi?? Will the same steps you described above apply??? I have a Motorola phone running gingerbread and I want to send trigger commands to the pi. I have a few specific questions and I'm not sure where to start. Any help would be greatly appreciated.

    Best Regards,
    Mark C.

  28. Pingback: A quick portable server: Raspberry Pi | Marlon.ws
  29. Zoltan M.

    Hi Terence,

    first of all, a great howto - thanks a lot!
    My project would be: to open my garage by a simple phone call, using a pi and a usb modem.
    Do you perhaps know what I need to doe here? Receiving calls and checking IDs is simply done by AT commands? How can I tell if a call is about to happen, I mean how to recognize if a ring the modem? Do I have to poll something constantly, or is there a trigger somewhere when the modem rings?

    Thanks a lot in advance!
    Regards, Zoltan

    • Terence Eden

      First of all, you will need to find a USB dongle which will accept voice calls - many won't. You'll also need a SIM which your network provider has enabled for voice.

      • Zoltan M.

        The SIM I do have, and also a few dongles - do you perhaps know how to check if they have the feature? Or could you perhaps recommend a few specific modells?

      • Zoltan M.

        So, checked my Huawei 1750 with DC-unlocker, it is voice enabled.
        Any Ideas where/how to start? :)

    • exstud

      for that project you could simply get a cheap $20 phone and use the speaker signal to control your garage

      • Zoltan M.

        Yeah, thought of that, but it won't be that elegant and customizable that I would prefer. And hey, where is the fun and the joy of discovery in that? ;)

  30. Pingback: Getting Vodafone 3G to work on Raspberry Pi in India using K3770-Z « Blog linuxz2

Leave a Reply