1.3. USB Dongle configuration tutorial (SIM pre registered) - soracom/handson GitHub Wiki

Introduction

Establish 3G connectivity from Raspberry Pi using USB Dongle (MS 2131) with SORACOM Air SIM.

Preparation

  • Raspberry Pi
  • USB Dongle (Huawei MS2131)
  • SORACOM Air SIM for Global *already inserted for Workshop

Step 1: Configure Raspberry Pi for USB Dongle

You will be installing “network-manager” software package into your Raspberry Pi over SSH. Please make sure you are logged on to Raspberry Pi in your Putty/Terminal app.

Tip: If you are not familiar with Linux Command Line. This is a good list of cmd to remember: Common Linux Command Line

Command

sudo apt-get update && sudo apt-get install network-manager

Results

...
Need to get 7,709 kB of archives.
After this operation, 20.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Type 'y' and enter

...
Setting up ppp (2.4.6-3.1) ...
Setting up iputils-arping (3:20121221-5) ...
Setcap worked! arping is not suid!
Processing triggers for libc-bin (2.19-18+deb8u7) ...
Processing triggers for dbus (1.8.22-0+deb8u1) ...
Processing triggers for systemd (215-17+deb8u7) ...
You are now setting up an APN(Access Point Name) for SORACOM Air SIM to connect to SORACOM mobile network.

Command

sudo nmcli con add type gsm ifname "*" con-name soracom apn soracom.io user sora password sora

Results

Connection 'soracom' (3cbecb73-2f6c-48f9-819a-3e233408d4a0) successfully added.
To make above configuration active, you need to reboot your Raspberry Pi

Command

sudo reboot
Your Raspberry Pi will be rebooted and your current SSH session will be disconnected. Please reconnect to your Raspberry Pi over SSH again by following the previous step 1.2. (id/pwd = pi/raspberry).

Plug in your Huawei USB Dongle. You should now see “ppp0” interface in your “ifconfig” output. This means your cellular connection is successfully established. USB dongle LED indicator should be lit solid blue.

Image

Command

ifconfig ppp0

Results

ppp0 Link encap:Point-to-Point Protocol
inet addr:10.237.184.147 P-t-P:10.64.64.64 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:7 errors:0 dropped:0 overruns:0 frame:0
TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:106 (106.0 B) TX bytes:171 (171.0 B)

If you only see wwan0, it means your cellular connectivity is not successfully established. Please repeat the prior steps. If you still fail to establish, please raise your hand for help.

Your Raspberry Pi will automatically dial up each time your 3G USB modem is plugged into this Raspberry Pi, or when the connection is interrupted for some reason (e.g. Out of Cellular Range, Carrier Timeouts, or unexpected modem/device resets)

By default, Cellular connection has lower routing priority than Wi-Fi or Ethernet. This will sometimes affect your SSH access to your device over Wi-Fi or Ethernet. To solve this, you can update the default network route by editing the IP routing table. You can save the command as a Network Manager script and have it run each time you connect a USB modem or you reboot your Raspberry Pi.

To do this, run the route -n command to see the current IP routing table:

Command

route -n

Results

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    303    0        0 wlan0
0.0.0.0         10.64.64.64     0.0.0.0         UG    1024   0        0 ppp0
10.64.64.64     0.0.0.0         255.255.255.255 UH    0      0        0 ppp0
169.254.0.0     0.0.0.0         255.255.0.0     U     304    0        0 wwan0
192.168.1.0     0.0.0.0         255.255.255.0   U     303    0        0 wlan0

By default, wlan0 interface is set to highest priority. This means the traffic will pass wlan0 (Wi-Fi) interface even when you try to send data to SORACOM network.

Next step, download and install Soracom ppp route metric script:

Command

sudo curl -o /etc/NetworkManager/dispatcher.d/90.set_ppp_route_metric https://soracom-files.s3.amazonaws.com/handson/90.set_ppp_route_metric

Then, change the binary to executable

Command

sudo chmod +x /etc/NetworkManager/dispatcher.d/90.set_ppp_route_metric

Last but not least, you register them as Network Manager script to run when the USB modem is plugged in or the device restarts.

Command

sudo /etc/NetworkManager/dispatcher.d/90.set_ppp_route_metric ppp0 up

After running the script, run route -n to see the routing table:

Command

route -n

Results

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.64.64.64     0.0.0.0         UG    0      0        0 ppp0
0.0.0.0         192.168.1.1     0.0.0.0         UG    303    0        0 wlan0
0.0.0.0         10.64.64.64     0.0.0.0         UG    1024   0        0 ppp0
10.64.64.64     0.0.0.0         255.255.255.255 UH    0      0        0 ppp0
169.254.0.0     0.0.0.0         255.255.0.0     U     304    0        0 wwan0
192.168.1.0     0.0.0.0         255.255.255.0   U     303    0        0 wlan0

Notice that ppp0 is now the highest priority in the routing table. So for all network traffic, the ppp0 interface will be used.

You are all set now.

Reference: How to insert SORACOM Air SIM to USB Dongle (MS 2131)

Slide the front cover to remove it from your dongle.

Huawei USB Dongle MS2131

Cut SIM Card into Standard SIM. (Please be careful not to cut into the smaller size)

SIM Card

Put your SIM card into the card slot (as shown in the image below).

Huawei USB Dongle MS2131

Huawei USB Dongle MS2131

Replace the front cover and slide it back into place.

⚠️ **GitHub.com Fallback** ⚠️