How to Use an Off-the-Shelf 4G USB Module with Raspberry Pi
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.
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 sierrayou should see v.1.7.x or later
# modinfo sierra_netyou should see v.1.xx or later
# ls /dev/ttyUSB*you should see:
/dev/ttyUSB0 /dev/ttyUSB1 /dev/ttyUSB2 /dev/ttyUSB3
# ifconfigyou should see a WWAN without ip address.
# minicom –syou 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.
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+cfun=1 at+cgdcont=3,"IP","CustomAPN" at!scdftprof=3 at!scprof=3," ",1,0,0,0
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 188.8.131.52