4G data via USB dongle on Linux

Many 4G dongles actually contain two devices: a SD card or hub and a USB modem. usb_modeswitch can be used to decide which device the computer will see. On Ubuntu, NetworkManager manages the actual modem communications. The guide below was developed using Ubuntu Mate 20.04

Have a question? Want to contribute? Try the "Other Projects" section of the Raspberry Pi forum. Start your title with "WBC".

Instructions

Before plugging your USB dongle in, run

$ lsusb Bus 002 Device 003: ID xxxx:xxxx BigDisk Corp. Bus 002 Device 002: ID xxxx:xxxx Miscellaneous. Hub Bus 002 Device 001: ID xxxx:xxxx Something else Bus 001 Device 003: ID xxxx:xxxx More stuff

Now, plug your dongle in and find out the USB ID of the new device.

$ lsusb Bus 002 Device 003: ID xxxx:xxxx BigDisk Corp. Bus 002 Device 002: ID xxxx:xxxx Miscellaneous. Hub Bus 002 Device 001: ID xxxx:xxxx Something else Bus 001 Device 007: ID 1234:5678 Qualcomm, Inc. USB2.0 Hub Bus 001 Device 003: ID xxxx:xxxx More stuff
Next, run usb_modeswitch using the ID that you found using lsusb

$ usb_modeswitch -v 1234 -p 5678 -S Look for default devices ... Found devices in default mode (1) Access device 011 on bus 001 Get the current device configuration ... Current configuration number is 1 Use interface number 0 with class 8 Send Sierra control message communication with device stopped. May have switched modes anyway -> Run lsusb to note any changes. Bye!
Check to see if files have been created in /dev/

$ ls -la /dev/ttyUSB* crw-rw---- 1 root dialout 188, 0 Dec xx ti:me /dev/ttyUSB0 crw-rw---- 1 root dialout 188, 1 Dec xx ti:me /dev/ttyUSB1 crw-rw---- 1 root dialout 188, 2 Dec xx ti:me /dev/ttyUSB2
Now, use NetworkManager to create a mobile broadband connection

The phone number and APN information are typically the most important information to provide. If you have the SIM card working in an Android phone, you may be able to find the APN information under Settngs.