How to Use a 4G USB Module with Raspberry Pi

How to make an affordable 4G card work with Raspberry Pi. This is a direct IP card.

Similar projects worth following
The use case is pretty simple: you want 3G/4G on your Raspberry Pi because you want to access it when there is no WiFi. You could use an AT&T starter kit 3G shield but it seems more complex. I also believe it is locked to AT&T. The $50 Sfera Labs Sierra AirCard 320U USB modem seems like a viable option because it's unlocked, making it quick and easy to set up. It should work anywhere in the world either roaming or using a local SIM. This is important for me, personally, because it's part of a demo rig.

The good news is that the pre-built kernel 4.4 of Raspbian automatically recognizes this card, so you don't have to build your own kernel.

This is a great article from Netgear. What you see here is a short and simple example largely based on that article and my experience with this particular setup.

SIM card (generic)
With a data plan. Retail purchased SIM cards will not work with the AT&T starter kit, it is simply not possible to activate them - we tried to do it.

  • 1 × Sfera Labs Sierra AirCard 320U
  • 1 × AT&T Starter Kit Connectors and Accessories / Board-to-Board and Card Edge Connectors
  • 1 × Raspberry Pi 2 Model B
  • 1 × SIM card (generic)

  • 1
    Step 1

    Here is what you need to know about this modem. Like most modems, it responds to AT commands. Thus, the first thing to do is make sure that the kernel sees the modem driver correctly.

    • # modinfo sierra you should see v.1.7.x or later
    • # modinfo sierra_net you should see v.1.xx or later
    • # ls /dev/ttyUSB* you should see: /dev/ttyUSB0 /dev/ttyUSB1 /dev/ttyUSB2 /dev/ttyUSB3
    • # ifconfig you should see a WWAN without ip address.
    • # minicom –s you should see 115200-8N1 : 115200 bps and 8 bits none parity, 1 stop bit.

    I got a real feeling of nostalgia and fondly remembered the BBS when doing this. I did not need to enable echo: its ATE1, so if you don't see what you are typing, just type 'ATE1 <enter>' and it should respond let you see what you are typing.

  • 2
    Step 2

    The next thing you need to do is know your APN and additional details. For the AT&T starter kit, you will use this:

    For regular retail SIMs: broadband.# minicom -s AT #

    Verify the thing is ON. This should return OK.

    at!gstatus? should return device status.

    Ok, now you are good to set your APN into the modem.

    at!scprof=3," ",1,0,0,0
  • 3
    Step 3

    At the end of this, the modem should be connected.

    Check the IP address that the modem has at!scpaddr=3 and it should display the real life address. Now, you face the next challenge: how to exit Minicom. Ctrl-A and X worked for me.

    ifconfig the interface should have the IP address. How to test it without losing the terminal? ping -I wwan0

    If it's pinging its on.

View all 4 instructions

Enjoy this project?



Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates