树莓派使用4G模块(华为ME909s

编程入门 行业动态 更新时间:2024-10-06 20:28:38

树莓派使用4G模块(<a href=https://www.elefans.com/category/jswz/34/1769368.html style=华为ME909s"/>

树莓派使用4G模块(华为ME909s

大部分树莓派用户使用raspbian系统和ubuntu mate系统,所以我只在这两个系统上尝试使用4G模块,模块使用Mini PCI-E转USB开发板,接入到树莓派上,配置网络方法具体如下:

本篇介绍raspbian系统,ubuntu mate系统将在下一篇介绍

4G模块能直接被系统识别,无需安装驱动,可以通过lsusb和ifconfig命令查看状况:

pi@pi-desktop:~$ lsusb
Bus 001 Device 007: ID 12d1:15c1 Huawei Technologies Co., Ltd. 
Bus 001 Device 006: ID 0a05:7211 Unknown Manufacturer hub
Bus 001 Device 005: ID 413c:2107 Dell Computer Corp. 
Bus 001 Device 004: ID 413c:301a Dell Computer Corp. 
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub


pi@pi-desktop:~$ ifconfig
enxb827ebdc8c6f Link encap:Ethernet  HWaddr b8:27:eb:dc:8c:6f  
          inet addr:192.168.1.101  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::ca29:cc82:f9d1:dd9/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:44427 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1460 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2462495 (2.4 MB)  TX bytes:134180 (134.1 KB)


lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:475 errors:0 dropped:0 overruns:0 frame:0
          TX packets:475 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:33987 (33.9 KB)  TX bytes:33987 (33.9 KB)


usb0      Link encap:Ethernet  HWaddr 02:1e:10:1f:00:00  
          inet addr:10.27.145.51  Bcast:10.27.145.55  Mask:255.255.255.248
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:63 errors:0 dropped:0 overruns:0 frame:0
          TX packets:89 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:13037 (13.0 KB)  TX bytes:12466 (12.4 KB)


wlan0     Link encap:Ethernet  HWaddr b8:27:eb:89:d9:3a  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:242 errors:0 dropped:242 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 

          RX bytes:85717 (85.7 KB)  TX bytes:0 (0.0 B)


在raspbian系统下使用wvdial来拨号连接4G网络

安装wvdial:

sudo apt-get install wvdial

配置连接信息:

sudo vi /etc/wvdial.conf
如下配置:
[Dialer hw1]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0
Init3 = AT+CGDCONT=1,"IP","3gnet"
Modem Type = Analog Modem
Baud = 9600  # 波特率常见的是9600  115200  460800
New PPPD = yes
Modem = /dev/ttyUSB0
ISDN = 0
Phone = *99#
Password = guest
Username = guest

Auto DNS = on

拨号上网:

sudo wvdial hw1

需要等待一会儿

此时可以通过ifconfig看到多出了个ppp0的网卡设备,并且已经获得IP地址

但是还是无法ping通外网,查看路由表信息如下:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0            0.0.0.0         0.0.0.0                   U      0         0        0 eth0
10.64.64.64     0.0.0.0         255.255.255.255    UH    0         0        0 ppp0

192.168.1.0     0.0.0.0         255.255.255.0        U      202      0        0 eth0

可以看出访问未知目标时,使用的是eth0的网卡,此处我们将其修改为使用ppp0来访问未知目标:
删除eth0的第一条路由信息:
sudo route del –net 0.0.0.0 eth0
新增一条ppp0的路由信息:
sudo route add –net 0.0.0.0 ppp0


修改后路由信息为:
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0            0.0.0.0         0.0.0.0                 U      0       0         0 ppp0
10.64.64.64     0.0.0.0         255.255.255.255  UH    0       0         0 ppp0

192.168.1.0     0.0.0.0         255.255.255.0      U      202    0         0 eth0


可以尝试ping内网和外网:
pi@raspberrypi:~ $ ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.522 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.470 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.402 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=0.449 ms

pi@raspberrypi:~ $ ping www.baidu
PING www.a.shifen (61.135.169.125) 56(84) bytes of data.
64 bytes from 61.135.169.125: icmp_seq=1 ttl=54 time=23.3 ms
64 bytes from 61.135.169.125: icmp_seq=2 ttl=54 time=27.0 ms
64 bytes from 61.135.169.125: icmp_seq=3 ttl=54 time=13.5 ms

64 bytes from 61.135.169.125: icmp_seq=4 ttl=54 time=23.1 ms


更多推荐

树莓派使用4G模块(华为ME909s

本文发布于:2024-03-12 19:52:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1732286.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:华为   模块   树莓派   ME909s

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!