SIM7600CE联网测试分为两部分:html
一、TCP/IP链接node
二、PPP拨号上网python
实验环境:ubuntu-meta 16.04linux
硬件:树莓派3B,SIM7600CEubuntu
上网卡:移动的NB-IOT物联网卡ide
微雪官方教程:http://www.waveshare.net/wiki/SIM7600CE_4G_HAT工具
把模块插入到树莓派,并USB接口连到树莓派USB口上,开机,以下图所示:post
SIM7600X 4G HAT板载树莓派GPIO接口,可直接插入各版本树莓派使用;下表为树莓派管脚与模块引脚链接状况(树莓派三代B 和 树莓派三代B+):测试
SIM7600X 4G HAT | Raspberry Pi |
---|---|
5V | 5V |
GND | GND |
RXD | TXD (对应BCM的14) |
TXD | RXD (对应BCM的15) |
PWR | P22 (对应BCM的P6) |
FLIGHTMODE | P7 (对应BCM的P4),当拉高时进入飞行模式 |
使用SIM7600CE模块以前,须要对树莓派初始化设置this
cd /home/pi/SmartIoTControlSystem/SIM7600X/c
chmod 777 sim7600_4G_hat_init
sudo nano /etc/rc.local
sh /home/pi/SmartIoTControlSystem/SIM7600X/c/sim7600_4G_hat_init
因为树莓派串口默认用于终端调试,如需使用串口,则须要修改树莓派设置。执行以下命令进入树莓派配置:
sudo raspi-config
选择Interfacing Options ->Serial ->no -> yes,关闭串口调试功能。
打开/boot/config.txt文件,找到以下配置语句使能串口,若是没有,可添加在文件最后面:
sudo nano /boot/config.txt
重启生效。
一、将模块插入树莓派中
二、安装minicom,minicom是linux平台串口调试工具:
sudo apt-get install minicom
三、执行minicom -D /dev/ttyS0(ttyS0为树莓派3B/3B+的串口)。
默认波特率为115200
树莓派2B/zero,用户串口设备号为ttyAMA0,树莓派3B/3B+串口设备号为ttyS0。
四、以AT同步测试为例,发送相关指令,以下图所示:
sudo minicom -D /dev/ttyS0
到此,SIM7600的初始化完成!
1. TCP/IP链接测试
C语言版:
一、将模块插入树莓派中;
二、下载示例程序,把整个SIM7600X文件夹复制到/home/pi/SmartIoTControlSystem 路径下;
三、进入到bcm2835目录,编译安装BCM2835库:
cd /home/pi/SmartIoTControlSystem/SIM7600X/c/bcm2835
chmod +x configure && ./configure && sudo make && sudo make install
说明:若是编译出现问题,请参考FAQ的说明操做。
四、分别进到对应实例目录下,编译和运行程序,相关指令说明以下(以TCP程序为例):
sudo make clean //清除原来的执行文件 sudo make //从新编译 sudo ./TCP //运行程序
上述命令组合使用:
sudo make clean && sudo make && sudo ./TCP
微雪官网给的python例子须要python3环境,而如今的环境为python2,再也不测试。
2. ppp拨号软件安装与配置
安装ppp
sudo apt-get install ppp
新建一个script脚本
sudo su
cd /etc/ppp/peers cp provider gprs
修改gprs配置文件
nano gprs
修改内容以下:
# example configuration for a dialup connection authenticated with PAP or CHAP # # This is the default configuration used by pon(1) and poff(1). # See the manual page pppd(8) for information on all the options. # MUST CHANGE: replace myusername@realm with the PPP login name given to # your by your provider. # There should be a matching entry with the password in /etc/ppp/pap-secrets # and/or /etc/ppp/chap-secrets. user "myusername@realm" # MUST CHANGE: replace ******** with the phone number of your provider. # The /etc/chatscripts/pap chat script may be modified to change the # modem initialization string. connect "/usr/sbin/chat -v -f /etc/chatscripts/gprs" # Serial device to which the modem is connected. /dev/ttyUSB2 #因为咱们使用SIM7600CE的4G模块,而且该模块的驱动已经默认添加到raspbian的内核的,ttyUSB2为ppp的拨号端口 # Speed of the serial line. 115200 nocrtscts #增长 debug #增长 nodetach #增长 ipcp-accept-local #增长 ipcp-accept-remote #增长 # Assumes that your IP address is allocated dynamically by the ISP. noipdefault # Try to get the name server addresses from the ISP. usepeerdns # Use this connection as the default route. defaultroute # Makes pppd "dial again" when the connection is lost. persist
# Do not ask the remote to authenticate.
noauth
查看SIM7600CE的串口
ls /dev/ttyUSB*
使用minicom串口调试工具简单测试(若是未安装使用 sudo apt-get install minicom 进行安装)
链接 /dev/ttyUSB2 串口调试
minicom -D /dev/ttyUSB2
调试过程以下:
AT OK AT+CSQ +CSQ: 21,99 OK AT+CPIN? +CPIN: READY OK AT+COPS? +COPS: 1,0,"CHINA MOBILE CMCC",7 OK AT+CREG? +CREG: 0,1 OK AT+CPSI? +CPSI: LTE,Online,460-00,0x69B1,132648988,136,EUTRAN-BAND40,38950,5,5,-65,-988,8 OK AT+CEREG? +CEREG: 0,1 OK
调试完成退出。
查看网卡信息
ifconfig
开始拨号
pppd call gprs
拨号成功!
再次查看网卡信息:
能够看到多出ppp0网卡,即成功拨号,并得到一个临时IP。
使用 指定网卡进行ping操做 测试ppp0网卡是否能够连通外网
eth0网卡测试:
ping -I 192.168.1.179 www.baidu.com
成功!
ppp0网卡测试:
ping -I 100.104.6.86 www.baidu.com
没法ping通!
由于初次,拨号上网后,DNS没法解析,上不了网,能够加上指令:
route add -net 0.0.0.0 ppp0
成功!