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.

hackster_post_for_raspberry_pi_project

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.

Interface

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.

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

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 8.8.8.8

Read More:Β  How to Use an Off-the-Shelf 4G USB Module with Raspberry Pi

 


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top