樹莓派初始化
物理配置

這里需要先正常插入一張能夠上網的4G卡在模塊內。
軟件環境
- 下載示例程序,解壓后,把其內部Raspberry文件夾下的c文件夾改名為SIM7600X,然后把SIM7600X整個文件夾復制到樹莓派/home/pi目錄下
- 進入/home/pi/SIM7600X目錄下,執行指令
chmod 777 sim7600_4G_hat_init
- 設置開機初始化腳本
sudo nano /etc/rc.local
- 在exit0之前增加代碼
sh /home/pi/SIM7600X/sim7600_4G_hat_init
樹莓派配置
- 配置串口
在shell輸入sudo raspi-config
sudo raspi-config
根據路徑Interfacing Options ->Serial ->no -> yes按照下圖進行設置

- 打開/boot/config.txt文件,找到如下配置語句使能串口,如果沒有,可添加在文件最后面:
enable_uart=1
至此重啟生效
串口調試
- 安裝調試工具minicom
sudo apt-get install minicom
- 執行minicom -D /dev/ttyS0(ttyS0為樹莓派3B/3B+/4B的串口)。
默認波特率為115200
樹莓派2B/zero,用戶串口設備號為ttyAMA0,樹莓派3B/3B+/4B串口設備號為ttyS0。 - 以AT同步測試為例,發送相關指令,如下圖所示:

示例程序
- 下載示例程序至/home/pi/里面
wget https://www.waveshare.com/w/upload/2/29/SIM7600X-4G-HAT-Demo.7z
sudo apt-get install p7zip-full
7z x SIM7600X-4G-HAT-Demo.7z -r -o/home/pi
sudo chmod 777 -R /home/pi/SIM7600X-4G-HAT-Demo
- 進入此程序的bcm2835目錄內,編譯安裝BCM2835庫
cd SIM7600X/c/bcm2835
chmod +x configure && ./configure && sudo make && sudo make install
- 分別進到對應實例目錄下,編譯和運行程序,相關指令說明如下
sudo make clean //清除原來的執行文件
sudo make //重新編譯
sudo ./TCP //運行程序(以TCP為例)
上述命令組合使用如下
sudo make clean && sudo make && sudo ./PhoneCall

ppp撥號軟件安裝與配置-視頻
安裝ppp
sudo apt-get install ppp
新建script腳本
sudo su
cd /etc/ppp/peers
cp provider gprs
修改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*
一般情況下串口都是/dev/ttyUSB2
使用minicom調試/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
開始上網
先撥號
pppd call gprs
因為初次撥號需要設置DNS,所以利用su權限輸入下列命令
route add -net 0.0.0.0 ppp0
最后打開瀏覽器拔掉網線關閉WiFi,就可以訪問互聯網了。
參考如下:
https://www.cnblogs.com/little-kwy/p/11296426.html
https://www.bilibili.com/video/av75543557?zw
