4G/5G HAT Raspberry Pi OpenWrt Tutorial

From Waveshare Wiki
Jump to: navigation, search

Introduction

This tutorial will introduce how to use Raspberry Pi 4B with the SIM8202G-M2 HAT module to achieve mobile network Wi-Fi sharing. If an additional UPS is added as a power source, you can get a portable wireless router that can share 4G or 5G mobile networks anytime and anywhere.

Operating Principle

  • Soft routers refer to routing solution implementations using desktops, servers, or other devices with software, mainly relying on software settings to achieve router functions; OpenWrt is a very popular member of soft routers, it is a highly modular and highly automated embedded Linux system with powerful network components and extensibility, often used in industrial control devices, routers, etc.; After flashing OpenWrt soft router system on a Raspberry Pi, the Raspberry Pi itself is equivalent to a wireless WiFi router.
  • Remote NDIS (RNDIS) is a bus-independent class specification for Ethernet (802.3) network devices on dynamic plug-and-play (PnP) buses such as USB, 1394, Bluetooth, and InfiniBand. Remote NDIS defines a bus-independent message protocol between the host computer and remote NDIS devices through abstract control and data channels. Implementing RNDIS based on USB is actually TCP/IP over USB, which means running TCP/IP on a USB device to make the USB device appear as a network card. The advantage of using this protocol is its high versatility. In Windows systems, it can directly recognize and use external network modules by loading the built-in RNDIS driver. Similarly, in OpenWrt soft routing systems, the interface can be set to DHCP client mode and directly connect to the network through the module.

Preparation

Software Preparation

  • Raspberry Pi, 4g/5g communication expansion module (taking RM8202G as an example) and its accessory kit, TF card, two 5V3A DC power adapters, and a SIM card that supports and enables 5G/4G services

Flash Soft Router Image

Install Expansion Board

  • Align the communication module diagonally and insert it into the M2 interface on the base board, then press down and secure the rear with screws
  • Use IPEX adapter cable to connect the antenna interface on the communication module to the antenna interface on the base board, and screw in four paddle antennas separately
  • Use the USB-A male to USB-A male cable or adapter in the accessory package to connect the Raspberry Pi to the expansion module with the communication module installed (try to connect to the USB3.0 port of the Raspberry Pi)

安装效果图

Configure RNDIS/ECM Dial-up Mode

Load the ttyUSB* device symbol by adding the VID and PID of the module, open the corresponding AT port through minicom and send the AT command to configure the RNDIS network card mode, and then wait for the module to restart. Different series of modules have different commands, as follows:

  • SIM76XX
echo 1e0e 9011 > /sys/bus/usb-serial/drivers/generic/new_id
minicom -D /dev/ttyUSB2
AT+CUSBPIDSWITCH=9011,1,1
  • SIM82XX
echo 1e0e 9011  > /sys/bus/usb-serial/drivers/generic/new_id
minicom -D /dev/ttyUSB2
at+cusbcfg=usbid,1e0e,9011
  • RM5XXX/EM06XX
echo 2c7c 0800 > /sys/bus/usb-serial/drivers/generic/new_id
minicom -D /dev/ttyUSB2
AT+QCFG="usbnet",1
AT+QNETDEVCTL=2,3,1
AT+CFUN=1,1
  • FM6XX
echo 2cb7 0a05 > /sys/bus/usb-serial/drivers/generic/new_id
minicom -D /dev/ttyUSB0
ATE1
AT+CPIN?
AT+CGDCONT?
AT+GTAUTOCONNECT=1
AT+GTUSBMODE=39
AT+GTRNDIS=1,1
AT+GTRNDIS?
AT+CFUN=1,1

Configure Usage

Connect and Configure Raspberry Pi OpenWrt System WIFI

  • After flashing the OpenWrt system, insert the TF card into the Raspberry Pi motherboard. The default network port IP is: 192.168.1.1, and the default 5G WIFI router is enabled
  • You can search for the WIFI through your phone WIFI, find the default name "OpenWrt" WIFI hotspot, and then connect
  • Open your browser and enter: 192.168.1.1, default username: root, default password: password, and then you can enter the router management interface
  • Insert the SIM card into the card slot of the communication module, turn the switch to the position of external power (EXT PWR), and turn on the module after connecting the additional power supply
  • Add new interface, click Network —> Interface —> Add new interface

OpenWrt SIM8202G 1.png

  • Create new interface: Name of the new interface - SIM8202G; protocol of new interface - DHCP client; include the following interfaces - Ethernet adapter: "usb0", and then submit:

OpenWrt SIM8202G 2.png

  • Configure interface: Firewall settings - wan; Save & Apply
Change the firewall within the interface, but not within the firewall

OpenWrt SIM8202G 3.png

  • Wireless configuration: Network->Wireless->Edit->Interface Configuration->General Setup->Network, check SIM8202G, Save and Apply

OpenWrt SIM8202G 4.pngOpenWrt SIM8202G 5.png

Networking Speed Test

RM50XQ Networking speed test
  • Connect your mobile phone or other device to the Openwrtr hotspot, install a speed test tool, such as speed test software such as Internet Speed Manager, and you can choose to download www.speedtest.cn/pc/download to test the speed

About Measurement Speed

Due to many inconsistencies between actual and laboratory conditions, the 5G speed cannot be ideally maintained at 100MBPS. The following points:

  • Base station distance, the closer you are to the 5G base station, the better the signal and the faster the speed;
  • Base station load, the fewer people use, the faster the speed will be, and the commute will be slower during peak hours;
  • Number of base stations: Due to the spectrum relationship, the same amount of 4G coverage requires double the number of 5G base stations
  • Operator: You need to confirm whether your 5G card is speed-limited, you can periodically ask the operator to reset your network
  • Indoors are worse than outdoors: building penetration loss and indoor diffraction loss

PS: The current number of base stations still does not have good coverage, and the speed measurement in different locations is not the same.


Resources

Extended Application (networking required)

  • Install minicom
opkg update
opkg install minicom
  • Install lsusb
opkg install usbutils
  • Install rndis driver
opkg update
opkg install kmod-usb2 kmod-usb3 kmod-usb-net
opkg install kmod-usb-net kmod-usb-net-rndis kmod-usb-net-cdc-ether usbutils


Softwares

Images