跳转到内容
主菜单
主菜单
移至侧栏
隐藏
导航
首页
最近更改
随机页面
MediaWiki帮助
Mcuzone Wiki
搜索
搜索
登录
个人工具
登录
查看“1004 RPi0 4G Cat1-GPS-ETH EN”的源代码
页面
讨论
大陆简体
阅读
查看源代码
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
查看源代码
查看历史
常规
链入页面
相关更改
特殊页面
页面信息
←
1004 RPi0 4G Cat1-GPS-ETH EN
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
== '''Keywords''' == Raspberry, Raspberry Pi Zero, Cat1 4G LTE, USB2.0-A, Ethernet, Expansion Board, USB HUB, GPS, GNSS == '''I. Introduction''' == The Raspberry Pi Zero series (including the Zero, Zero W/H, and Zero 2W) is a highly cost-effective embedded system platform, known for its small size, low power consumption, and acceptable performance, making it suitable for many lightweight application scenarios. Although the Zero series is compact, it reserves a large number of expansion interfaces. Especially on the backside of the board, gold-plated test points for USB and power are brought out. We can use these sets of USB and power test points to expand various types of peripherals. This expansion board is essentially a USB hub that connects to the Zero's USB port via pogo pins. It expands four USB ports via USB, with one USB port converted to a 100Mbps wired Ethernet port, one USB port connected to a 4G Cat1 module, and two USB 2.0-A host ports. 4G Cat1 is a high-cost-performance module aimed at medium-speed IoT applications around 10 Mbps. The 10 Mbps downlink and 5 Mbps uplink speeds can satisfy the majority of connectivity and transmission requirements. It supports 4G all-net communications, including Unicom, Telecom, and Mobile. The 4G module on this expansion board also supports GPS/GNSS.. == '''II. Hardware Resources''' == 2.1 Use gold-plated pogo pins to connect the Raspberry Pi Zero series, eliminating the need for external cables; 2.2 The two groups of gold-plated pogo pins are used separately for power supply and USB communication. 2.3The expansion board is equipped with a USB-C power supply interface, which can power the entire system. The Micro USB port on the Zero can also be used for power. 2.4 The onboard USB hub expands the Zero's USB into four ports: one port is used for connecting a 4G LTE Cat1 module, two are USB host interfaces, and one is a USB to 10/100Mbps Ethernet adapter. 2.5 4G LTE Cat1 module supports full 4G network coverage, with a downlink speed of up to 10Mbps and an uplink speed of up to 5Mbps. 2.6 The 4G LTE Cat1 module is a plug-and-play in most systems, driver-free and does not require manual dialing, usually recognized as the eth1 network card. 2.7 The 4G LTE Cat1 module uses a Nano-sized SIM card and offers the option of either an SMA antenna or a first-generation IPEX antenna. 2.8 The 4G LTE Cat1 module supports GPS/GNSS. 2.9 The expansion board supportsother Pi with USB contacts in the same position, such as the Orange Pi Zero 2W. 2.10 Onboard PWR/MODE/ACT LED. 2.11 Onboard reset button for 4G. Note 1: After connecting this expansion board, the Micro USB port on the Zero will no longer be usable. Note 2: In some systems, it is necessary to disable the OTG function and set the USB mode to Host mode. Note 3: The expansion board supports all versions of the Raspberry Pi Zero, including the Zero, Zero W, Zero WH, and Zero 2W. http://www.mcuzone.com/wiki/1004_Zero_4G_Cat1-GPS/1004_Zero_4G_Cat1-GPS_08.jpg == '''III. System flashing''' == 3.1 The hardware in this document is based on the Raspberry Pi Zero 2W. 1. The Raspberry Pi OS used in this document is: 2024-07-04-raspios-bookworm-arm64.img.xz(Raspberry Pi OS with desktop). (If you are using the Raspberry Pi Zero (1st generation) series boards, they only support 32-bit systems. Please be sure to download the correct version.) You can download the Raspberry Pi OS in: https://www.raspberrypi.com/software/operating-systems/#raspberry-pi-os-64-bit 2. Ubuntu system: Ubuntu Server 24.04 LTS. (The Raspberry Pi Zero 2W cannot use the Desktop version due to performance limitations.) The image is: ubuntu-24.04-preinstalled-server-arm64+raspi.img.xz You can download the Ubuntu system in: https://ubuntu.com/download/raspberry-pi 3.2 Use Imager or balenaEtcher to flash the OS image in TF card. [[0005 MPS2242 2280 2280P(Single SSD Expansion Board)#3.2 Boot from TF card|Click here to read the instructions for System flashing]] == '''IV. Demonstration of Using the Raspberry Pi OS''' == === 4.1 View hardware devices === ==== 4.1.1 View USB devices ==== Open the terminal in Raspberry Pi OS and enter the command<code>lsusb</code>, as shown in the image below: http://www.mcuzone.com/wiki/1004_Zero_4G_Cat1-GPS/1004_Zero_4G_Cat1-GPS_01.jpg The system has detected the USB hub and the 4G module: Device 002:External USB Hub; Device 003:4G module; Device 004:USB to 100Mbps Ethernet adapter; Device 005:USB2.0-A Interface; Device 006:USB2.0-A Interface. If the system stop at the Raspberry Pi logo and fails to boot: http://www.mcuzone.com/wiki/0007_Zero_4G_Cat1/0007_Zero_4G_Cat1_58.jpg or if after booting, the keyboard, mouse, and 4G module cannot be used, please carefully check whether the pogo pins are aligned with the gold-plated contacts. Additionally, on the PC, open the <code>config.txt</code> file located in the root directory of the TF card to check the USB initialization script. http://www.mcuzone.com/wiki/0007_Zero_4G_Cat1/0007_Zero_4G_Cat1_41.jpg You need to confirm that the three red-boxed areas in the following image are all configured completely. If not, please manually add the missing parts and save the file: <code># otg_mode=1</code> (It is recommended to comment out as follow) <code>dtoverlay=dwc2,dr_mode=host</code> (These two areas must be ensured to be included.) http://www.mcuzone.com/wiki/0007_Zero_4G_Cat1/0007_Zero_4G_Cat1_57.jpg ==== 4.1.2 View network devices ==== Open the terminal in Raspberry Pi OS and enter the command <code>ifconfig -a</code>, as shown in the image below: http://www.mcuzone.com/wiki/1004_Zero_4G_Cat1-GPS/1004_Zero_4G_Cat1-GPS_02.jpg 可以看到eth0为4G Cat1(上图中IP地址默认为192.168.5.8),eth1为为USB转以太网。 We can see that eth1 is a USB-to-Ethernet adapter, and eth0 is a 4G Cat1 connection (with the IP address in the image above is 192.168.5.142). '''''Note: The 4G Cat1 module of this expansion board initializes quickly and is connected to the first port of the USB Hub chip. SO, in the allocation of network names, the 4G Cat1 module is assigned as eth0, and the USB to Ethernet adapter is assigned as eth1.''''' === 4.2 Test network devices === ==== 4.2.1 ping tests ==== When testing, there is a priority order: if eth0 is connected, it will be used first. If there are specific requirements for internal and external networks, please adjust the metric values of each network and the DNS server settings. Use the -I parameter to specify which network interface to start the ping packet from, as shown below: <code>ping www.mcuzone.com -I eth0</code> <code>ping www.mcuzone.com -I eth1</code> http://www.mcuzone.com/wiki/1004_Zero_4G_Cat1-GPS/1004_Zero_4G_Cat1-GPS_03.jpg Priority can be checked by executing the <code>route</code> command; the network card with the smaller metric value will be preferred for communication http://www.mcuzone.com/wiki/1004_Zero_4G_Cat1-GPS/1004_Zero_4G_Cat1-GPS_04.jpg We can also force communication through another network by disabling a specific network card. For example, to disable eth0, you can execute the following command: <code>sudo ifconfig eth0 down</code> And enable eth0 by the following command: <code>sudo ifconfig eth0 up</code> ==== 4.2.2 设置网卡优先级与指定DNS服务器 ==== For knowledge regarding this part, you can refer to the following link: [[1001 Zero 4G Cat1-ETH(100M ETH 4G Cat1 USB2.0-A)#4.2.1 ping tests|Set network card priority]] [[1001 Zero 4G Cat1-ETH(100M ETH 4G Cat1 USB2.0-A)#4.2.4 Examples of how to use udhcpc|Use udhcpc to specify DNS servers]] [[1001 Zero 4G Cat1-ETH(百兆网络 4G Cat1 USB2.0-A 485版本可选)#4.2.3 利用udhcpc指定DNS服务器|udhcpc application scenario example]] It is recommended to specify the DNS server using the udhcpc software rather than editing the resolv.conf file, as this will be more stable. ==== 4.2.3 Test speed by iperf3 ==== You can download iperf3 (Windows version) in: <nowiki>http://www.mcuzone.com/down/Software.asp?ID=10000634</nowiki> Install iperf3 (Linux version) by using the following command: <code>sudo apt-get install iperf3</code> 100M Ethernet speed test results: It is about 75Mbps in client mode and it is about 94Mbps in server mode: http://www.mcuzone.com/wiki/1004_Zero_4G_Cat1-GPS/1004_Zero_4G_Cat1-GPS_05.jpg '''''注Note: The USB to 100M Ethernet adapter may not reach full speed due to the performance limitations of the Zero 2W, the USB hub, and the bandwidth usage of the 4G Cat1.''''' 4G CAT1 speed test results: http://www.mcuzone.com/wiki/0007_Zero_4G_Cat1/0007_Zero_4G_Cat1_46.jpg '''''Note: Network speed testing is affected by the network environment and testing methods. Speeds should be considered based on actual results, and this test is for reference only.''''' === 4.3 Demonstration of AT Command for 4G Cat1 Module on the Raspberry Pi OS === ==== 4.3.1 Method to open AT Command serial port ==== 在树莓派下要对4G进行AT命令操作,首先要打开AT命令串口,打开方法如下: Open the ttyUSB serial port: Input the following command: <code>lsusb</code> http://www.mcuzone.com/wiki/1004_Zero_4G_Cat1-GPS/1004_Zero_4G_Cat1-GPS_07.jpg Record the ID value of the 4G module: 1782 4e00 Use the following command to open the ttyUSB serial port, where the value after echo is the ID recorded above: <code>sudo modprobe option</code> <code>sudo sh -c 'echo 1782 4e00 > /sys/bus/usb-serial/drivers/option1/new_id'</code> http://www.mcuzone.com/wiki/0007_Zero_4G_Cat1/0007_Zero_4G_Cat1_12.jpg After execution is complete, the system should have three additional devices: ttyUSB0, ttyUSB1, and ttyUSB2. Then use a serial port tool to open the corresponding serial port. Install minicom: <code>sudo apt-get install minicom</code> http://www.mcuzone.com/wiki/0007_Zero_4G_Cat1/0007_Zero_4G_Cat1_13.jpg Open AT Command serial port by minicom: <code>sudo minicom -D /dev/ttyUSB0</code> Or: <code>sudo minicom -D /dev/ttyUSB1</code> http://www.mcuzone.com/wiki/0007_Zero_4G_Cat1/0007_Zero_4G_Cat1_14.jpg Then directly type the AT command and press Enter to see the result. If you need to view the echo, please type the command: <code>ate1.</code> Note: The model of the 4G module may change, but the process remains the same. You only need to use <code>lsusb</code> to check the actual USB ID and replace it with the actual value in subsequent commands. Additionally, some 4G Cat1 modules's chipset IDs have already been included in the kernel's supported list, so these Cat1 modules can be automatically recognized as ttyAMAx without the need to add a USB ID. ==== 4.3.2 Common AT commands ==== 1) Check if the SIM card is detected: <code>at+cpin?</code> Return ready to indicate the card has been recognized, if return error, you need to check the hardware. 2) Check antenna signal quality: <code>at+csq</code> eturn values between 26 and 31 indicate a good signal, with 31 representing a full signal strength; return values between 20 and 25 indicate a barely acceptable signal; return values below 20 indicate a poor signal or that the antenna might not be connected. 3) Check network registration status: <code>at+cops?</code> Normally, it should return the network supporter's code: 7, where 7 represents 4G. Note: The above command <code>at+csq</code> should not include a question mark, while the other two commands require a question mark. 4) View the SIM card's IMEI code: <code>at+cgsn</code> 5) Reset 4G module (Sometimes, if you reinsert the SIM card, hot swapping may not work; in such cases, you can use this reset command to reset the module.): <code>at+reset</code> 6) Disable radio frequency: <code>at+cfun=0</code> Enable radio frequency: <code>at+cfun=1</code> The two commands mentioned above can be used in pairs to allow the module to re-register with the network without restarting the 4G module. http://www.mcuzone.com/wiki/0007_Zero_4G_Cat1/0007_Zero_4G_Cat1_15.jpg ==== 4.3.3 Test GPS ==== When using GPS, a '''passive GPS antenna''' is used by default, and ensure that the GPS antenna is extended outdoors. Note: Some passive GPS antennas are sensitive to the parasitic capacitance of the TVS diodes used for protection. If satellite acquisition fails, you may need to remove the TVS diodes and try again (as shown in the figure). If you want to use an active antenna, you need to replace capacitor C43 with a 0Ω resistor. http://www.mcuzone.com/wiki/1004_Zero_4G_Cat1-GPS/1004_Zero_4G_Cat1-GPS_11.jpg Run minicom to open the ttyUSB1 serial port: <code>sudo minicom -D /dev/ttyUSB1</code> And run: <code>AT+CGNSPWR=1</code> //Open GPS <code>AT+CGNSAID=31,1,1,1</code> //Enable position assistance (the command returns OK immediately, and positioning should succeed within approximately 2-10 seconds based on signal strength). <code>AT+CGNSURC=1</code> //Set up automatic reporting of location information After running successfully, GPS information will be output on the serial port, and after a short wait, positioning will be achieved. http://www.mcuzone.com/wiki/1004_Zero_4G_Cat1-GPS/1004_Zero_4G_Cat1-GPS_10.jpg == '''五、Ubuntu Server下使用演示''' == === 5.1 编辑初始化脚本 === Ubuntu Server烧写完毕后,请在PC端打开TF卡系统分区根目录下的config.txt检查USB的初始化脚本,Ubuntu Server对USB初始化了两遍,前面一遍没有配置成host模式,需要确认下图中的两处红框的位置是否都配置成完全,如果没有,请手动添加完整: <code>dtoverlay=dwc2,dr_mode=host</code> http://www.mcuzone.com/wiki/0007_Zero_4G_Cat1/0007_Zero_4G_Cat1_32.jpg http://www.mcuzone.com/wiki/0007_Zero_4G_Cat1/0007_Zero_4G_Cat1_30.jpg === 5.2 配置用户名和密码 === 将TF卡插入Zero 2W,启动系统。第一次启动后会要求登录,用户名和密码均为ubuntu,登录成功后会要求修改密码。 http://www.mcuzone.com/wiki/0007_Zero_4G_Cat1/0007_Zero_4G_Cat1_31.jpg 修改完毕后就自动进入系统。 === 5.3 配置网络 === Ubuntu Server系统出于安全考虑,有非常多的限制,默认很多服务器和组件也都是关闭状态;网络接口被关闭的,所以系统启动后并无网络可用,需要进行开启设置后才能使用。 '''''注意,系统默认并没有集成ifconfig工具,只有ip命令可用。''''' 执行<code>ip addr</code>查看并记录下网卡名称: http://www.mcuzone.com/wiki/0007_Zero_4G_Cat1/0007_Zero_4G_Cat1_33.jpg 其中2号网卡(enx00e0996df1cd)为USB转百兆网卡,3号网卡(enxac4bb3b9ebe5)为4G模组。 然后运行下面的命令,打开网卡配置文件: <code>sudo nano /etc/netplan/50-cloud-init.yaml</code> 按照下图编辑网卡配置文件: http://www.mcuzone.com/wiki/0007_Zero_4G_Cat1/0007_Zero_4G_Cat1_34.jpg 保存退出,然后重启。 重启后即可联网,安装net-tools工具以便于使用: <code>sudo apt install net-tools</code> http://www.mcuzone.com/wiki/0007_Zero_4G_Cat1/0007_Zero_4G_Cat1_35.jpg === 5.4 网络及4G模组测试 === 执行命令<code>ifconfig -a</code>,查看网卡信息: http://www.mcuzone.com/wiki/0007_Zero_4G_Cat1/0007_Zero_4G_Cat1_36.jpg 可见第一块网卡为USB转百兆网卡,第二块网卡为4G模组。 通过使用-I参数,在ping包时加上网卡名称,可指定哪块网卡进行ping包。通过这两块网卡对腾讯的网站的ping包测试可知,第二块网卡即4G模组支持ipv6: http://www.mcuzone.com/wiki/0007_Zero_4G_Cat1/0007_Zero_4G_Cat1_37.jpg === 5.5 AT命令交互测试 === 安装minicom工具: <code>sudo apt-get install minicom</code> http://www.mcuzone.com/wiki/0007_Zero_4G_Cat1/0007_Zero_4G_Cat1_38.jpg 然后和树莓派OS一样,通过minicom打开AT命令串口: <code>sudo minicom -D /dev/ttyUSB0</code> 或 <code>sudo minicom -D /dev/ttyUSB1</code> http://www.mcuzone.com/wiki/0007_Zero_4G_Cat1/0007_Zero_4G_Cat1_39.jpg 即可使用常见AT命令进行交互: http://www.mcuzone.com/wiki/0007_Zero_4G_Cat1/0007_Zero_4G_Cat1_40.jpg === 5.6 GPS测试 === 使用GPS时,默认采用'''''无源GPS天线''''',,且确保GPS天线甩出户外。 注意:部分无源GPS天线对保护用的TVS管的寄生电容较为敏感,如果无法定位卫星需要将TVS拆除重试(如图)。如果要使用有源天线需要把电容C43更换为0R电阻。 http://www.mcuzone.com/wiki/1004_Zero_4G_Cat1-GPS/1004_Zero_4G_Cat1-GPS_11.jpg 运行minicom,打开ttyUSB1串口: <code>sudo minicom -D /dev/ttyUSB1</code> 并运行: <code>AT+CGNSPWR=1</code> //打开GPS <code>AT+CGNSAID=31,1,1,1</code> //使能位置辅助定位(指令立即返回OK,根据信号强度,大概2-10秒左右会定位成功) <code>AT+CGNSURC=1</code> //设置定位信息自动上报 运行成功后就可以看到该串口有GPS信息输出,稍等片刻即可定位: http://www.mcuzone.com/wiki/1004_Zero_4G_Cat1-GPS/1004_Zero_4G_Cat1-GPS_09.jpg == '''六、OpenWrt系统操作演示''' == === 6.1 概述 === 此扩展板搭配树莓派Zero 2W,在OpenWrt系统下可配置为一进一出的交换机模式,扩展板上的4G可作为WAN口(直接4G上网),网口配置为LAN口,用于连接PC。 === 6.2 准备工作 === 本文使用的OpenWrt系统为:openwrt-bcm27xx-bcm2709-rpi-2-squashfs-sysupgrade-linux-6.1.98-20240723.img.gz 烧写OpenWrt系统并上电启动后,我们通过树莓派自带网口连接网线至PC网口,待PC的网卡与树莓派的网口连接成功后,我们在Windows设置中找到网络和Internet,在以太网中打开连接的网络查看默认网关的IP地址,这个地址就是OpenWrt系统的后台配置页面地址,如图所示,本文测试的地址为192.168.198.1: http://www.mcuzone.com/wiki/0007_Zero_4G_Cat1/0007_Zero_4G_Cat1_18.jpg 然后打开网页浏览器输入192.168.198.1进入OpenWrt系统。默认用户名为root,默认密码为password。 http://www.mcuzone.com/wiki/0007_Zero_4G_Cat1/0007_Zero_4G_Cat1_19.jpg === 6.3 设置OpenWrt系统 === 进入OpenWrt系统后,如前所述,用网线把树莓派的网口和PC的网口直连,等PC的网卡获取了IP地址后,即可让PC直接通过4G模块上网(无需设置)。 === 6.4 测试4G模块网速 === 在PC端打开<nowiki/>https://www.speedtest.cn/<nowiki/>进行测速,此时流量走的是4G模块,测试结果如下: http://www.mcuzone.com/wiki/0007_Zero_4G_Cat1/0007_Zero_4G_Cat1_46.jpg '''''注意:4G网络测速受网络信号和测试方法影响,速度请以实际为准。''''' === 6.5 挂载U盘及文件操作 === 将U盘插入USB口,则在“系统 - 磁盘管理”中直接可以看到该U盘的信息及挂载情况: http://www.mcuzone.com/wiki/0007_Zero_4G_Cat1/0007_Zero_4G_Cat1_20.jpg 在“系统 - 挂载点”中可以看到各个挂载点的情况,也可以在此页面对其进行配置。 在“网络存储 - 文件助手”中,可以对系统中的文件进行操作。 http://www.mcuzone.com/wiki/0007_Zero_4G_Cat1/0007_Zero_4G_Cat1_21.jpg === 6.6 TTYD终端 === OpenWrt系统自带一个网页版的TTYD终端,可在“系统 - TTYD终端”中打开。默认用户名为root,默认密码为password,因为是使用root账号登录,登录后即有root权限。 http://www.mcuzone.com/wiki/0007_Zero_4G_Cat1/0007_Zero_4G_Cat1_22.jpg <!--=== 7.7 无线网卡的使用 === 此扩展板自带一个无线网卡,但本OpenWrt系统因为驱动原因默认不开启,所以暂时处于不可用状态,如果需要使用,则需手动开启。 默认状态下,“网络”里面没有无线网卡的相关设置: 44 7.7.1 安装驱动 驱动下载地址: http://www.mcuzone.com/wiki/1001_Zero_4G_Cat1/brcmfmac43430b0-sdio.raspberrypi,model-zero-2-w.zip 下载完毕后将其解压到U盘,本文所解压的目录为U盘下的op文件夹,将U盘插到扩展板上,我们可以在“网络存储 - 文件助手”中看到这些文件,挂载目录为/mnt/sda/op/: 45 打开TTYD终端并登录,执行下列命令: <code>cd /mnt/sda/op/</code> <code>cp *.* /lib/firmware/brcm/</code> 47 然后重启系统。 7.7.2 配置无线网卡--> {{联系我们_图标}}
本页使用的模板:
模板:Contact Us icon
(
查看源代码
)
返回
1004 RPi0 4G Cat1-GPS-ETH EN
。
开关有限宽度模式