5G/4G Raspberry 4B openWrt Sample Tutorial
Overview
This tutorial will introduce how to use Raspberry Pi 4B equipped with SIM8202G-M2 HAT module to realize the function of sharing the mobile network with wifi. If you add a UPS as a power source, you can get a portable and portable wireless router. 4G or 5G mobile network anytime, anywhere shared.
Working Principle
- Soft routing refers to a routing solution formed by using a desktop computer or a server and other equipment with software. It mainly relies on software settings to achieve the function of a router; OpenWrt is a very popular member of the soft routing system. It is a The highly modular and highly automated embedded Linux system has powerful network components and scalability, and is often used in industrial control equipment, routers and other equipment; after the Raspberry Pi is programmed with the OpenWrt soft routing system, the Raspberry Pi itself is It is equivalent to a wireless WIFI router.
- Remote NDIS (RNDIS) is a bus-independent class specification for Ethernet (802.3) network devices over dynamic Plug and Play (PnP) buses such as USB, 1394, Bluetooth, and InfiniBand. Remote NDIS defines a bus-independent message protocol between a host computer and a remote NDIS device through abstract control and data channels. The implementation of RNDIS based on USB is actually TCP/IP over USB, which is to run TCP/IP on the USB device, making the USB device look like a network card. The advantage of using this protocol is that it has high versatility. In Windows system, it can directly identify and use the external network module by loading the built-in RNDIS driver. Similarly, in the OpenWrt soft routing system, the interface can also be set to DHCP client mode. Connect to the network directly through the module.
Preparations
Hardware Preparation
- Raspberry Pi, 4g/5g communication expansion module (here takes RM8202G as an example) and its accessories package, SD card, two 5V3A DC power adapters, SIM card that supports and has opened 5G/4G service.
Program Soft Routing Mirror
- Download the compiled OpenWrt image file and unzip it;
- Use the burning software to burn the image file in the prepared sd card.
Install the Expansion Board
- Insert the communication module into the M2 interface of the base plate at an oblique direction, and fix the tail with screws after pressing down;
- Connect the antenna port on the communication module to the antenna port on the base plate using an IPEX adapter cable, and screw in the four paddle antennas respectively.
- Use the accessory package USB-A male to A male cable or adapter to connect the Raspberry Pi to the expansion module with the communication module installed (try to connect the Raspberry Pi USB3.0 interface).
Configure the RNDIS Dial-up Mode
Load the ttyUSB* device sign by adding the VID and PID of the module, open the corresponding AT port through minicom and send AT commands to configure the RNDIS NIC mode, and then wait for the module to restart, the commands for different series of modules are different, as follows:
- SIM76XX
echo 1e0e 9011 > /sys/bus/usb-serial/drivers/generic/new_id sudo minicom -D /dev/ttyUSB2 AT+CUSBPIDSWITCH=9011,1,1
- SIM82XX
echo 1e0e 9011 > /sys/bus/usb-serial/drivers/generic/new_id sudo minicom -D /dev/ttyUSB2 at+cusbcfg=usbid,1e0e,9011
- RM5XXX/EM06XX
echo 2c7c 0800 > /sys/bus/usb-serial/drivers/generic/new_id sudo minicom -D /dev/ttyUSB2 AT+QCFG="usbnet",3 AT+QNETDEVCTL=2,3,1 AT+CFUN=1,1
- FM6XX
echo 2cb7 0a05 > /sys/bus/usb-serial/drivers/generic/new_id sudo minicom -D /dev/ttyUSB0 ATE1 AT+CPIN? AT+CGDCONT=1,"IP","Your_APN" AT+CGREG? AT+CGDCONT? AT+GTRNDIS=1,1
Configuration Usage
Connect and configure Raspberry Pi OpenWrt system WIFI
- After burning the OpenWrt system, insert the SD card into the Raspberry Pi motherboard, the default network port IP is: 192.168.1.1, and the default is 5G WIFI router.
- You can search through the mobile phone WIFI, find the WIFI open hotspot whose default name is "OpenWrt", and then connect
- Open the browser, enter: 192.168.1.1, the default username: root, the 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 the external power supply ((EXT PWR)), and the module will turn on after the external power supply is connected;
- Add new interface: Network -> Interfaces -> Add New Interface.
- Create new interface: name of new interface - SIM8202G; protocol of new interface - DHCP client; include the following interfaces - ethernet adapter: "usb0"; submit.
- Configuration interface: Firewall settings - wan; save & apply. Please modify the firewall settings in this interface!
- Wireless configuration: Network -> Wireless -> Modify -> Interface Configuration -> Basic Settings -> Check SIM8202G in Network; Save & Apply.
Network Speed Test
- Install speed testing software, such as Internet Speed Manager and other speed testing software, you can choose to download the speed test at www.speedtest.cn/pc/download.
About the speed testing
As there will be many inconsistencies between actual and laboratory conditions that will result in 5G speeds that are not ideally stable at 100MBPS, there are the following.
- Base station distance, the closer to the 5G base station the better the signal and the faster the speed.
- Base station load, the fewer people using it the faster it will be, and the slower it will be during peak commuting periods.
- Number of base stations: due to the spectrum, an equal amount of 4G coverage requires double the number of 5G base stations.
- Operator: you need to confirm your 5G card, and whether the speed is limited, you can regularly ask the operator to reset your network.
- Indoor is worse than outdoor: building penetration attenuation, and indoor bypass attenuation.
PS: The current number of base stations still does not have good coverage, and the speed measurement is not quite the same in different locations.