-
Notifications
You must be signed in to change notification settings - Fork 28
1.3. USB Dongle configuration tutorial
Establish 3G connectivity from Raspberry Pi using USB Dongle (MS 2131) with SORACOM Air SIM.
- Raspberry Pi
- USB Dongle (Huawei MS2131)
- SORACOM Air SIM for Global (Ready/Active status)
Slide the front cover to remove it from your dongle.
Cut SIM Card into Standard SIM. (Please be careful not to cut into the smaller size)
Put your SIM card into the card slot (as shown in the image below).
Replace the front cover and slide it back into place.
Log into your Raspberry Pi and install network-manager package
Tip: If you are not familiar with Linux Command Line. This is a good list of cmd to remember: Common Linux Command Line
sudo apt-get install network-manager
...
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) ...
Once Network Manager has been installed, create the 3G Dongle connection
sudo nmcli con add type gsm ifname "*" con-name soracom apn soracom.io user sora password sora
Connection 'soracom' (3cbecb73-2f6c-48f9-819a-3e233408d4a0) successfully added.
Reboot the Pi
sudo reboot
The Pi will be rebooted and your current SSH terminal will be disconnected.
Please reconnect to the Pi using assigned IP address (id/pwd = pi/raspberry).
plug in your USB Dongle and you should get a ppp0 interface. (This is your Cellular connection)
When it is connected via 3G, the USB dongle shows solid blue light.
ifconfig ppp0
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)
Your Pi is now connected to the cellular network and will automatically connect each time a Dongle is plugged in or Linux restarted. It will also automatically reconnect in case the connection drops for any reason (for example, if a device moves temporarily out of range of a mobile network).
One thing to note is that by default, Cellular connection has lower priority than WiFi or Ethernet. This could potentially affect your ability to access your device remotely. To solve this we update the default route metric by creating a Network Manager script:
First, run the route -n
command to see current Kernel IP routing table:
route -n
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
wlan0 interface will be used because of the priority (the order).
Download and install Soracom ppp route metric script:
sudo curl -o /etc/NetworkManager/dispatcher.d/90.set_ppp_route_metric https://soracom-files.s3.amazonaws.com/handson/90.set_ppp_route_metric
Make sure it is executable
sudo chmod +x /etc/NetworkManager/dispatcher.d/90.set_ppp_route_metric
This new script will run every time you reconnect a Dongle or reboot your pi, with it, you’ll be able to connect to it via Ethernet or Wifi while at the same time use Cellular as your default connectivity. Run it manually or otherwise reboot to activate it
sudo /etc/NetworkManager/dispatcher.d/90.set_ppp_route_metric ppp0 up
After running the script, run route -n
to see the routing table:
route -n
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 new ppp0 routing is now higher priority (order) in the table. The ppp0 interface will be used for any destination IPs.
Please open another terminal to the Pi and run the following script to confirm the Pi is connected via ppp0 interface over SORACOM network:
curl ifconfig.io
xxx.xxx.xxx.xxx
look up this IP address:
host xxx.xxx.xxx.xxx
xxx.xxx.xxx.xxx.in-addr.arpa domain name pointer ec2-xxx-xxx-xxx-xxx.eu-central-1.compute.amazonaws.com.
If you see the IP is coming from amazonaws.com, you are connected via SORACOM.
Congratulations!!