Difference between revisions of "Template:GMS GPRS GNSS HAT Manual"

From ingcool
Jump to: navigation, search
(硬件配置)
m (Text replacement - "47.107.148.244" to "{{SERVERNAME}}")
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
=Windows调试=
+
=Test it in Windows PC=
==硬件配置==
+
==Hardware connection==
用户在使用模块前除了本身配备的电源、micro USB 线、GSM 天线、GPS 天线和蓝牙天线外,还需要准备以下 2 样东西:<br />
+
This module comes with a power adapter, micro USB cable, GSM antenna, GPS
#一张 SIM 卡(中国移动或中国联通),未停机,并开通 GPRS 功能(否则无法进行 GPRS 功能测试)
+
antenna and Bluetooth antenna. Besides these you should prepare two more things:<br />
#一副带麦克风的耳机(用于测试通话功能)
+
#A SIM card, the card should be usable and GPRS access (for testing the GPRS)
*SIM 卡安装到 SIM 卡槽,接上耳机<br />
+
#An earphone with a microphone on it (For testing Call function)
*安装 CP2102 驱动,将跳帽插于跳线 B 上,把 micro USB 线一端接 PC 机的 USB 接口,另一端接 GSM/GPRS/GNSS HAT USB TO UART 接口,PWR 灯变常亮状态;<br />
+
*Insert the SIM card to the card slot, plug the earphone and connect the GSM antenna<br />
*在设备管理器里面可以看到 CP2102 对应的 COM 口。例如下图所示是 COM7,用户以自己 PC识别到的 COM 口为准。<br />
+
*Install CP2102 driver, plug the jumper B, and connect the USB to UART interface of GSM/GPRS/GNSS HAT to PC with a micro USB cable. Then the PWR indicator will keep bright.<br />
 +
*Open Device Manager to get the corresponding COM port number of CP2102. For example, it is COM7 as below. Users need to choose the correct port according to the Manager. <br />
 
[[file:GSM-GNSS-GPRS_COM.png|center|500px]]
 
[[file:GSM-GNSS-GPRS_COM.png|center|500px]]
*长按模块的 PWRKEY 按键约 1 秒,可以看到 NET 灯亮起,并开始闪烁,如下图所示。<br />
+
*Press the PWRKEY button and hold for 1s, the NET indicator will blink as below.<br />
正常可以看到 NET 灯先快闪(1 秒闪 1 次),表示还没有注册到网络。当注册到网络后,NET灯开始慢闪(3 秒闪 1 次)。注册网络过程需要几秒到几十秒不等,这取决于所在地 GSM 网络的状态。<br />
+
: Generally, the NET indicator will fast flash firstly (1 time per second), which means that the module has not logged in the Network. After logging in, the indicator become to flash slowly (1 time every three seconds). Up to the local GSM network, this process that logging in will last several seconds to dozens of seconds.<br />
如果长时间无法注册成功,请检查 GSM 天线、SIM 卡是否连接正常,SIM 卡是否已停机。<br />
+
If you take too much time to log in and failed, please check that whether the GSM antenna is connected correctly, and whether the SIM card is usable and inserted correctly.<br />
使用电脑USB调试,需要将此处的跳冒接至A<br />
+
Set the jumper to A<br />
:
+
:[[file:GSM-GPRS-GNSS HAT-1.png|500px]]
[[file:GSM-GPRS-GNSS HAT-1.png|500px]]
 
  
==GSM调试==
+
==Test GSM==
 
<font color="#FF0000">
 
<font color="#FF0000">
AT 指令请查阅:SIM800 Series_AT Command Manual_V1.10<br />
+
For more details of AT commands, please refer to: SIM800 Series_AT Command Manual_V1.10<br />
 
</font>
 
</font>
===拨打电话===
+
===Take calls===
#正确安装 SIM 手机卡、 GSM 天线、连接好 TTL 串口,接通电源;
+
#Insert the SIM card, connect the GSM antenna and TLL serial wires correctly. Then power on the board;
#观察指示灯是否正常, PWR 指示灯常亮, STA 灯常亮, NET 灯闪烁;
+
#Check whether the indicators blink correctly (PWR and STA keep bright, NET flashes every three seconds).
#查询 SIM 卡的状态,发送“AT+CPIN?+回车”,返回+CPIN: READY 正常;
+
# Send “AT+CPIN?” and Enter to query the status of the SIM card. Getting “+CPIN: READY” if the SIM card is ready
#拨打号码:“ATD10086;”,这里以 10086 为例;
+
#Call number: for example, “ATD10086;” (10086 is the number of China Mobile Communications Corporation)
#挂断电话:“ATH+回车”,如下图所示;
+
#Send “ATH” and Enter to hang up the call, as below:
[[file:GSM-GNSS-GPRS_Callphone.png|center|900px]]
+
[[file:GSM-GNSS-GPRS_Callphone.png|center|500px]]
  
===接听电话===
+
===Answer calls===
#设置来电显示:“AT+CLIP=1+回车”
+
#Enable CLIP notification: AT+CLIP=1 then Enter
#接通:“ATA+回车”,挂断:“ATH+回车”
+
#Hang up: ATH then Enter
 
[[file:GSM-GNSS-GPRS_answercall.png|center|500px]]
 
[[file:GSM-GNSS-GPRS_answercall.png|center|500px]]
  
===发送英文短信===
+
===Send SMS===
#正确安装 SIM 手机卡、GSM 天线、连接好 TTL 串口,接通电源;
+
#Set the local SMSC:AT+CSCA="+8613800755500" then Enter, get response “OK”. Note: The SMSC will be different in different areas. Here, it is ShenzhenChina as examples;
#观察指示灯是否正常, PWR 指示灯常亮, STA 灯常亮, NET 灯闪烁;
+
#AT+CMGF=1: Set SMS to TEXT mode;
#设置当地短信中心:AT+CSCA="+8613800755500"+回车,返回 OK。注:短信中心每个地方可能不一样,具体可百度查询或拨打移动联通客服,此短信中心为深圳;
+
#AT+CMGS="xxxxxxxxxxx” then Enter, set the number of receivers, then you will get a response: >, edit the content of the message (needn’t Enter at the end). After editing,  GSM/GPRS/GNSS HAT User Manual send 1A in HEX format to send the message (0x1A is key value of “CTRL+Z”, it will tell the module to send). If the message is sent successfully, the module will get the reply +CNGS: 174 as below figures
#AT+CMGF=1:设置短信模式为 TEXT
+
[[file:GSM-GNSS-GPRS_sendMessage.png|center|500px]]
#AT+CMGS="xxxxxxxxxxx"<回车> ,设置接收方手机号 ,然后会返回:>,发送需要发送的内容,结尾不需要回车,编辑完短信后以十六进制的格式发送 1A 发信息发送(0x1A 是“CTRL+Z”
 
#的键值,用于告诉模块执行发送操作,也可以发送 0x1B 即“ESC”取消操作),发送成功后模块返回+CNGS:174 确认发送成功。
 
[[file:GSM-GNSS-GPRS_sendMessage.png|center|900px]]
 
  
===接受英文短信===
+
===Receiver SMS==
#正确安装 SIM 手机卡、GSM 天线、连接好 TTL 串口,接通电源;
+
#Send a message “this is a receive test” to the GSM/GPRS/GSNN HAT from your phone
#手机上发送一条:“this is a receive test”到试验模块上
+
#. While receiving messages, the module will report it to UART: “SM”, 3, it means that there are 3 messages in SM, and the message we receive just now is the third message.
#接受到信息时,串口会制动上报信息,“SM”, 3,代表存在 SM 里面有 3 条信息了,刚刚发的信息就是第 3
+
#Reading messages:AT+CMGR=3 to read the third message (AT+CMGL="ALL" to read all messages)
#读取信息:AT+CMGR=3 读取第 3 条信息(AT+CMGL="ALL" 为读取所有信息)
+
#Deleting message:AT+CMGD=3, to delete the message as below
#删除信息:AT+CMGD=3,如下图所示
+
[[file:GSM-GNSS-GPRS_revMessage.png|center|500px]]
[[file:GSM-GNSS-GPRS_revMessage.png|center|900px]]
 
  
===发送中文短信===
+
==Test GPS==
#AT+CSCS="UCS2", 设置信息文本为 UCS2 编码集
 
#AT+CSMP=17,128,2,25
 
#AT+CMGS="00310038003500360035003700300038003600340030",设置接收方手机号的 UCS2集;
 
#等待返回>,此时发送进过转换的信息,结尾不需要回车,编辑完短信后以十六进制的格式发送 1A 发信息发送,如下图所示。
 
[[file:GSM-GNSS-GPRS_sendCNMessage.png|center|900px]]
 
 
 
===接受中文短信===
 
#发送 AT+CMGF=1 设置文本显示
 
#发送 AT+CSCS="GSM"设置 GSM 编码集
 
#接受到信息时,串口会制动上报信息,读取信息:AT+CMGR=3 ,在软件中把信息转成中文,如下图所示。
 
[[file:GSM-GNSS-GPRS_revCNMessage.png|center|900px]]
 
 
 
==GPS调试==
 
 
<font color="#FF0000">
 
<font color="#FF0000">
AT 指令请查阅:SIM868 Series GNSS Application Note V1.00<br />
+
For more details of AT commands, please refer to:SIM868 Series GNSS Application Note V1.00<br />
 
</font>
 
</font>
#插上 GPS 天线,并将接收器置于空旷的室外
+
#Connecting the GPS antenna, and place the receiver on open area to receive GPS signal
#打开 GPS 电源: AT+CGNSPWR=1
+
#Turn on power of GNSS: AT+CGNSPWR=1
#查询波特率:AT+CGNSIPR?
+
#Check the baud rate: AT+CGNSIPR?
#打开 GPS 数据流输出:AT+CGNSTST=1,得到定位信息,如下图所示
+
#Start to sending data received to UART: AT+CGNSTST=1:
 
[[file:GSM-GNSS-GPRS_GPS.png|center|900px]]
 
[[file:GSM-GNSS-GPRS_GPS.png|center|900px]]
*关闭串口助手,打开 u-center 软件设置端口(Port)和波特率(Baudrate)。端口号为串口读取的端口号。波特率设置为之前查询到的波特率。(端口和波特率可以在 Receiver 里面设置,也可以在面板图标上面直接设置),如下图所示:<br />
+
*Close the Com Assistant software SSCOM. Open u-center and set the Port and Baudrate. The Port is the port number recognized by PC. Set Baudrate as the value we got before (You can configure in Receiver option or click icons on the toolbar directly):<br />
 
[[file:GSM-GNSS-GPRS_GPS_u-center.png|center|900px]]<br />
 
[[file:GSM-GNSS-GPRS_GPS_u-center.png|center|900px]]<br />
*选择 Player>,即可看到 GPS 信息,如下图所示<br />
+
*Click Connect, then the GNSS information will be printed as below<br />
 
[[file:GSM-GNSS-GPRS_GPS_u-center2.png|center|900px]]<br />
 
[[file:GSM-GNSS-GPRS_GPS_u-center2.png|center|900px]]<br />
  
==GPRS 调试==
+
==Test GPRS==
 
<font color="#FF0000">
 
<font color="#FF0000">
AT 指令请查阅:SIM800 Series_AT Command Manual_V1.10<br />
+
For more details of AT commands, please refer to:SIM800 Series_AT Command Manual_V1.10<br />
 
</font>
 
</font>
===设置本地电脑虚拟服务器===
+
===Seyying local virtual server===
虚拟服务器定义了广域网服务端口和局域网网络服务器之间的映射关系,所有对该广域网服务端口的访问都会被重新定位给通过 IP 地址指定的局域网网络服务器。(请参阅您的路由器对应厂商的说明书)<br />
+
The virtual server defines the mapping between service ports of WAN and web servers of LAN. All requests from the Internet to service ports of WAN will be redirected to the computer (web servers of LAN) specified by the server IP. (Please refer to guide manual of your router)<br />
#使用浏览器登录到路由器管理界面(具体地址请参阅您的路由器说明书)
+
#Log in Management Console of your router with a browser (read your router’s guide manual for specific address)
#设置端口号:5000(与已有的端口号不冲突即可。本例设为 5000)
+
#. Set Port:5000 (The Port can’t conflict with others. Here we set it to 5000)
#设置电脑端内网 IP(局域网内电脑获取的 IP,可以在本机运行 CMD,进入命令行提示符,输入 ipconfig 查看 IPv4 地址,本例的电脑内网 IP 是 192.168.1.14),如下图所示
+
#Set LAN IP address for your computer (you can run CMD on your computer, and execute command ipconfig to inquiry the address of IPv4), 192.168.1.14 as examples
 
[[file:GSM-GNSS-GPRS_gnss_ip.png|center|900px]]<br />
 
[[file:GSM-GNSS-GPRS_gnss_ip.png|center|900px]]<br />
===获取外网 IP===
+
===Get WAN IP===
外网 IP 可以通过浏览器搜索 IP 获得,如下图所示<br />
+
You can search “IP” on a browser to get WAN IP address of your PC as below: (This method is only workable in China)<br />
 
[[file:GSM-GNSS-GPRS_gnss_ip2.png|center|900px]]<br />
 
[[file:GSM-GNSS-GPRS_gnss_ip2.png|center|900px]]<br />
===配置 GPRS===
+
===Set GPRS===
#AT+CSQ 查询网络信号质量,其中第一个参数为网络信号质量最大为 31,此数值越大说明网络信号越强
+
#AT+CSQ inquiry the quality of the signal. The first parameter of response is the signal quality (Max is 31). The signal is stronger, the value bigger.
#AT+CREG? 查询网络注册情况,其中第二个参数为 1 5 则说明已经注册成功
+
#AT+CREG? Check Network registration. If the second parameter of response is 1 or 5, it means that the Network has been registered successfully
#AT+CGATT? 查询模块是否附着 GPRS 网络
+
#AT+CGATT? AT+CGATT? Check the state of GPRS attachment
#AT+CSTT="CMNET",根据实际网络设置 APN,这里以移动为例
+
#AT+CSTT="CMNET" Set the Network according to the actual situation. Here we use CMNET
#AT+CIICR 激活移动场景
+
#AT+CIICR Bring up a wireless connection with GPRS
#AT+CIFSR 获得本地 IP 地址
+
#AT+CIFSR Get the local IP address
#AT+CIPSTART="TCP","113.81.232.4",5000 建立 TCP/IP 连接,如下图所示
+
#AT+CIPSTART="TCP","113.81.232.4",5000 Establish TCP/IP connection
===发送数据===
+
===Send data===
#AT+CIPSEND 模块向服务器
+
#AT+CIPSEND module is going to send data to the server
#等待返回>,此时输入要发送的数据,结尾不需要回车,编辑完短信后以十六进制的格式发送 1A 发信息发送
+
#After getting the response >, edit the contents of the message (has been converted) without Enter at the end. Then send 1A in HEX format as below
#发送完成,服务器会收到模块发送过来的数据,如下图所示
+
#If the data sent successfully, the server will receive the data
 
[[file:GSM-GNSS-GPRS_gnss_sendmsg.png|center|900px]]<br />
 
[[file:GSM-GNSS-GPRS_gnss_sendmsg.png|center|900px]]<br />
===接收数据===
+
===Receive data===
#AT+CIPSEND 模块向服务器
+
#Choose the IP address of module on Peers input box
#在 peers 选择设备端 IP 地址
+
#Input the data which you want to send: hello, I am a server, please receive my message
#在服务器中输入要发送的数据如:hello,i am server,please receive my message
+
#Click Send button, you can see that module receive the data
#点击发送,在串口助手即可收到信息,如下图所示
 
 
[[file:GSM-GNSS-GPRS_gnss_revmsg.png|center|900px]]<br />
 
[[file:GSM-GNSS-GPRS_gnss_revmsg.png|center|900px]]<br />
===关闭连接===
+
===Deactivate connection===
#发送 AT+CIPCLOSE AT+CIPSHUT 关闭连接
+
#Send AT+CIPCLOSE or AT+CIPSHUT to deactivate the connection.
 
+
==Test Bluetooth==
==蓝牙调试==
 
 
<font color="#FF0000">
 
<font color="#FF0000">
更多 AT 指令请查阅:SIM800 系列_BT_应用文档_V1.04 <br />
+
For more information about AT command: Please refer to: SIM800 series_BT_application_V1.04 <br />
 
</font>
 
</font>
===配置蓝牙===
+
===Setting===
#将蓝牙天线连接到 GSM 模块的蓝牙天线接口上面。打开手机蓝牙,并且开放检测,使手机蓝牙能够被未配对的设备搜索到
+
#Connecting the Bluetooth antenna to the GSM/GPRS/GNSS HAT. Open the Bluetooth service of your phone and set it visible to all nearby Bluetooth.
#AT+BTPOWER=1,打开蓝牙电源
+
#AT+BTPOWER=1 Turn on Bluetooth
#AT+BTHOST?,查询模块名称和地址,可以通过 AT+BTHOST=<Name>指令来修改模块的蓝牙名称
+
#AT+BTHOST?,Enquiry the name and MAC address of the module, you can also use
#AT+BTSCAN=1,10 ,搜索蓝牙附件设备,收索时间 10S,搜索过程中,串口会打印搜索到的蓝牙设备的信息。例如+BTSCAN: 0,2,"H60-L01",50:a7:2b:bb:a4:50,-47。其中 0,2 是设备 ID,“H60-L01”是设备名称,50:a7:2b:bb:a4:50 是设备的 MAC 地址,-47 是设备的 RSSI
+
#AT+BTSCAN=1,10 ,To search available nearby devices. The search time is 10s. During searching, the module will print the information of the available devices to UART. Examples: +BTSCAN: 0,2,"H60-L01",50:a7:2b:bb:a4:50,-47, “0,2” is the ID of this device;“H60-L01” is name of device; “50:a7:2b:bb:a4:50” is MAC address of device;“-47” is the RSSI value.
#AT+BTPAIR=0,2 ,主动请求匹配设置,第二个参数为第四步获取的设备 ID,如果返回error,AT+BTUNPAIR=0 清除配对信息,重新配对即可
+
#AT+BTPAIR=0,2, Pair with an available device, the second parameter here is the ID we got at step 4. If you get the response Error, just use AT+BTUNPAIR to delete the pairing data and pair again.
#发送配对指令成功后,会看到手机弹出配对信息,手机端点击配对后,需要发送AT+BTPAIR=1,1 确认既可配对。如果没有发送 AT+BTPAIR 指令确认配对,在等待一段时间后,手机端会弹配对失败信息。需要重新发起配对指令。也可以由手机端发起配对,模块输入AT+BTPAIR=1,1 即可确认配对,如下图所示
+
#After sending the pair command successfully, you can see that your telephone prompt the pairing request. Then you need to click Pair to accept the request and send AT+BTPAIR on PC to confirm the pairing behavior. With these, module pair with the telephone successfully. If you don’t send the AT command to confirm pairing, the telephone will prompt information that fails to pair after a while. In this case, you need to send the pair command again. You can also use the telephone to send the pairing request, then input AT+BTPAIR=1,1 to confirm it.
 
[[file:GSM-GNSS-GPRS_bt_config.png|center|900px]]<br />
 
[[file:GSM-GNSS-GPRS_bt_config.png|center|900px]]<br />
===蓝牙连接===
+
===Connecting===
*使用蓝牙 APP 与模块进行蓝牙连接和通信,这里可扫描对应二维码下载我们提供的蓝牙 APP,使用其中的串口功能进行测试。(该蓝牙 APP 只做简单测试使用,不提供其他功能)
+
*To test Bluetooth of GSM/GPRS/GNSS, you should use the Bluetooth APP. Scanning the QR code below to download the APP, then you can use its Serial function to test. (The APP is just used for simply testing)
[[file:GSM-GNSS-GPRS_bt_app.png|center|900px]]<br />
 
#打开 APP,点击右上角的扫描搜索蓝牙设备,点击“SIM868”(模块的蓝牙名字,这里我将模块名字定义为 SIM868),然后点击串口控制连接。模块接收到连接信息后,会显示
 
+BTCONNECTING:信息表示模块正在等待连接,如果一段时间不做回应的话,手机端会提示连接失败,同时模块显示+BTDISCONN:提示连接失败。
 
#重新进行一次连接,发送 AT+BTACPT=1 确认连接。模块会显示+BTCONNECT 信息提示连接 SPP成功。同时手机端可以发送数据。
 
#模块接收到手机蓝牙发送过来的数据,会以设备 ID,字符长度,数据内容的形式打印到串口上面。
 
#发送 AT+BTSPPSEND 发送数据。等待>符号出现,输入数据内容,结尾不换行结束输入。十六进制格式发送 1A 将输入的数据发送出去。可以看到手机端成功接收到数据,如下图所示:
 
[[file:GSM-GNSS-GPRS_bt_connet.png|center|900px]]<br />
 
  
=树莓派使用=
+
#Open the APP, click the SCAN button on the upper right to scan the available devices. Then choose “SIM868” (“SIM868” is default Bluetooth name of GSM/GPRS/GNSS HAT) and click UART. Then you will get the information that +BTCONNECTING on the COM assistant, which means there is a connecting request. If you don’t reply to it for a while, the APP will prompt that connecting failed. And failed information “+BTDISCONN” will be printed on PC
{{RPI_open_uart}}
+
#Connecting again, send command AT+BTACPT=1 to confirm and accept Bluetooth connection. You can see that +BRCONNECT is printed on PC shows that succeed in SPP connecting. Then you can send data to the module with the APP.
 +
#While receiving the data send from the telephone, the data will be printed with ID of the device, the length of string, and the content on PC.
 +
#Send AT+BTSPPSEND command to transmit data. After getting the response >, input the content without Enter at the end. Send 1A in HEX to begin to transmit the data. Then you can see that the data are received by your phone
  
==安装库==
+
=Workin with Raspberry Pi=
*安装Python函数库
+
==Enable serial port==
 +
*Open a terminal and configure interface by the following commands
 +
<pre>
 +
sudo raspi-config
 +
</pre>
 +
*Choose Interfacing Options -> Serial->No->Yes
 +
*Restart Raspberry Pi
 +
<pre>
 +
sudo reboot
 +
</pre>
 +
==Install libtaties==
 +
*Install Python libraries
 
<pre>
 
<pre>
 
sudo apt-get update
 
sudo apt-get update
Line 144: Line 131:
 
</pre>
 
</pre>
  
==minicom调试==
+
==minicom test==
*安装minicom调试助手,并调试
+
*Install minicom tool and test
 
<pre>
 
<pre>
 
sudo apt-get install minicom
 
sudo apt-get install minicom
# 对于树莓派3B\3B+\4B得串口
+
# For Pi 3B\3B+\4B,
 
sudo minicom -D /dev/ttyS0 -b 9600
 
sudo minicom -D /dev/ttyS0 -b 9600
# 对于树莓派ZERO\2B
+
# For Pi ZERO\2B
 
sudo minicom -D /dev/ttyAMA0 -b 9600
 
sudo minicom -D /dev/ttyAMA0 -b 9600
# 对于树莓派3B的USB口,使用树莓派USB调试,需要将跳冒接至A
+
# If you want to test with the USB port of Pi, you can change the jumper to A:
 
sudo minicom -D /dev/ttyUSB0 -b 9600
 
sudo minicom -D /dev/ttyUSB0 -b 9600
 
</pre>
 
</pre>
默认波特率为115200,如需设置波特率为9600加参数 -b 9600,-D代表端口,/dev/ ttySO 类似于windows中的COM1,如果不是树莓派3,那么是minicom -D /dev/ttyAMA0,再将模块连接树莓派。<br>
+
The default baud rate of minicom is 115200,If you want to change it to 9600, you can add parameter to the command: -b 9600. ttyS0 is the serial port of Pi 3B/3B+, ttyAMA0 of Pi 2B/Zero. If you use USB interface, the port may be ttyUSB*<br>
以蓝牙测试为例,发送相关指令,如下图所示:<br>
+
Here we test Bluetooth as example:<br>
 
[[file:GSM-GNSS-GPRS_rpi_minicom.png|center|900px]]<br>
 
[[file:GSM-GNSS-GPRS_rpi_minicom.png|center|900px]]<br>
退出:Ctrl+A 然后单独按X,YES 回车<br>
 
  
==测试例程==
+
==Demo codes==
*下载程序
+
*Download
 
<pre>
 
<pre>
 
sudo apt-get install p7zip
 
sudo apt-get install p7zip
wget  http://www.waveshare.net/w/upload/1/1f/GSM-GPRS-GNSS-HAT-Code.7z
+
wget  http://{{SERVERNAME}}/w/images/1/1f/GSM-GPRS-GNSS-HAT-Code.7z
 
7zr x GSM-GPRS-GNSS-HAT-Code.7z -r -o./GSM-GPRS-GNSS-HAT-Code
 
7zr x GSM-GPRS-GNSS-HAT-Code.7z -r -o./GSM-GPRS-GNSS-HAT-Code
 
sudo chmod 777 -R GSM-GPRS-GNSS-HAT-Code
 
sudo chmod 777 -R GSM-GPRS-GNSS-HAT-Code
Line 170: Line 156:
 
</pre>
 
</pre>
  
*python程序,提供打电话、获取GPS、发送信息三种例程
+
*We provide some python codes for testing
 
<pre>
 
<pre>
 
sudo python call_phone.py  
 
sudo python call_phone.py  
Line 176: Line 162:
 
sudo python gps.py
 
sudo python gps.py
 
</pre>
 
</pre>
 +
 +
=Resources=
 +
==Examples==
 +
*[http://{{SERVERNAME}}/w/images/1/1f/GSM-GPRS-GNSS-HAT-Code.7z Demo codes]
 +
==Software==
 +
*[http://{{SERVERNAME}}/w/images/8/88/TCP232.7z TCP232 Software]
 +
*[http://{{SERVERNAME}}/w/images/c/c1/Chiness_Unicode.zip Fonts convertor]
 +
*[http://{{SERVERNAME}}/w/images/3/31/U-center_v8.12.7z U-center]
 +
*[http://{{SERVERNAME}}/w/images/d/d5/SSCOM.rar SSCOM Software]
 +
==Documents==
 +
*[http://{{SERVERNAME}}/w/images/2/20/GSM-GPRS-GNSS-HAT-Schematic_.pdf Schematic]
 +
*[http://{{SERVERNAME}}/w/images/6/6f/SIM868_Reference_Design_V1.01%28160310%29.pdf SIM868_Reference Design V1.01(160310).pdf]
 +
*[http://{{SERVERNAME}}/w/images/f/fe/SIM868_NMEA_Message_Specification_V1.00.pdf SIM868 NMEA Message Specification V1.00.pdf]
 +
*[http://{{SERVERNAME}}/w/images/2/20/SIM800_Series_AT_Command_Manual_V1.09.pdf SIM800 Series AT Command Manual V1.09.pdf]
 +
*[http://{{SERVERNAME}}/w/images/3/3d/SIM868_GNSS_Application_Note_V1.00.pdf SIM868 GNSS Application Note V1.00.pdf]
 +
*[http://{{SERVERNAME}}/w/images/b/b6/SIM868_GNSS_AGPS_Application.pdf SIM868 GNSS AGPS Application.pdf]

Latest revision as of 11:30, 11 July 2020

Test it in Windows PC

Hardware connection

This module comes with a power adapter, micro USB cable, GSM antenna, GPS antenna and Bluetooth antenna. Besides these you should prepare two more things:

  1. A SIM card, the card should be usable and GPRS access (for testing the GPRS)
  2. An earphone with a microphone on it (For testing Call function)
  • Insert the SIM card to the card slot, plug the earphone and connect the GSM antenna
  • Install CP2102 driver, plug the jumper B, and connect the USB to UART interface of GSM/GPRS/GNSS HAT to PC with a micro USB cable. Then the PWR indicator will keep bright.
  • Open Device Manager to get the corresponding COM port number of CP2102. For example, it is COM7 as below. Users need to choose the correct port according to the Manager.
GSM-GNSS-GPRS COM.png
  • Press the PWRKEY button and hold for 1s, the NET indicator will blink as below.
Generally, the NET indicator will fast flash firstly (1 time per second), which means that the module has not logged in the Network. After logging in, the indicator become to flash slowly (1 time every three seconds). Up to the local GSM network, this process that logging in will last several seconds to dozens of seconds.

If you take too much time to log in and failed, please check that whether the GSM antenna is connected correctly, and whether the SIM card is usable and inserted correctly.
Set the jumper to A

GSM-GPRS-GNSS HAT-1.png

Test GSM

For more details of AT commands, please refer to: SIM800 Series_AT Command Manual_V1.10

Take calls

  1. Insert the SIM card, connect the GSM antenna and TLL serial wires correctly. Then power on the board;
  2. Check whether the indicators blink correctly (PWR and STA keep bright, NET flashes every three seconds).
  3. Send “AT+CPIN?” and Enter to query the status of the SIM card. Getting “+CPIN: READY” if the SIM card is ready
  4. Call number: for example, “ATD10086;” (10086 is the number of China Mobile Communications Corporation)
  5. Send “ATH” and Enter to hang up the call, as below:
GSM-GNSS-GPRS Callphone.png

Answer calls

  1. Enable CLIP notification: AT+CLIP=1 then Enter
  2. Hang up: ATH then Enter
GSM-GNSS-GPRS answercall.png

Send SMS

  1. Set the local SMSC:AT+CSCA="+8613800755500" then Enter, get response “OK”. Note: The SMSC will be different in different areas. Here, it is ShenzhenChina as examples;
  2. AT+CMGF=1: Set SMS to TEXT mode;
  3. AT+CMGS="xxxxxxxxxxx” then Enter, set the number of receivers, then you will get a response: >, edit the content of the message (needn’t Enter at the end). After editing, GSM/GPRS/GNSS HAT User Manual send 1A in HEX format to send the message (0x1A is key value of “CTRL+Z”, it will tell the module to send). If the message is sent successfully, the module will get the reply +CNGS: 174 as below figures
GSM-GNSS-GPRS sendMessage.png

=Receiver SMS

  1. Send a message “this is a receive test” to the GSM/GPRS/GSNN HAT from your phone
  2. . While receiving messages, the module will report it to UART: “SM”, 3, it means that there are 3 messages in SM, and the message we receive just now is the third message.
  3. Reading messages:AT+CMGR=3 to read the third message (AT+CMGL="ALL" to read all messages)
  4. Deleting message:AT+CMGD=3, to delete the message as below
GSM-GNSS-GPRS revMessage.png

Test GPS

For more details of AT commands, please refer to:SIM868 Series GNSS Application Note V1.00

  1. Connecting the GPS antenna, and place the receiver on open area to receive GPS signal
  2. Turn on power of GNSS: AT+CGNSPWR=1
  3. Check the baud rate: AT+CGNSIPR?
  4. Start to sending data received to UART: AT+CGNSTST=1:
GSM-GNSS-GPRS GPS.png
  • Close the Com Assistant software SSCOM. Open u-center and set the Port and Baudrate. The Port is the port number recognized by PC. Set Baudrate as the value we got before (You can configure in Receiver option or click icons on the toolbar directly):
GSM-GNSS-GPRS GPS u-center.png


  • Click Connect, then the GNSS information will be printed as below
GSM-GNSS-GPRS GPS u-center2.png


Test GPRS

For more details of AT commands, please refer to:SIM800 Series_AT Command Manual_V1.10

Seyying local virtual server

The virtual server defines the mapping between service ports of WAN and web servers of LAN. All requests from the Internet to service ports of WAN will be redirected to the computer (web servers of LAN) specified by the server IP. (Please refer to guide manual of your router)

  1. Log in Management Console of your router with a browser (read your router’s guide manual for specific address)
  2. . Set Port:5000 (The Port can’t conflict with others. Here we set it to 5000)
  3. Set LAN IP address for your computer (you can run CMD on your computer, and execute command ipconfig to inquiry the address of IPv4), 192.168.1.14 as examples
GSM-GNSS-GPRS gnss ip.png


Get WAN IP

You can search “IP” on a browser to get WAN IP address of your PC as below: (This method is only workable in China)

GSM-GNSS-GPRS gnss ip2.png


Set GPRS

  1. AT+CSQ inquiry the quality of the signal. The first parameter of response is the signal quality (Max is 31). The signal is stronger, the value bigger.
  2. AT+CREG? Check Network registration. If the second parameter of response is 1 or 5, it means that the Network has been registered successfully
  3. AT+CGATT? AT+CGATT? Check the state of GPRS attachment
  4. AT+CSTT="CMNET" Set the Network according to the actual situation. Here we use CMNET
  5. AT+CIICR Bring up a wireless connection with GPRS
  6. AT+CIFSR Get the local IP address
  7. AT+CIPSTART="TCP","113.81.232.4",5000 Establish TCP/IP connection

Send data

  1. AT+CIPSEND module is going to send data to the server
  2. After getting the response >, edit the contents of the message (has been converted) without Enter at the end. Then send 1A in HEX format as below
  3. If the data sent successfully, the server will receive the data
GSM-GNSS-GPRS gnss sendmsg.png


Receive data

  1. Choose the IP address of module on Peers input box
  2. Input the data which you want to send: hello, I am a server, please receive my message
  3. Click Send button, you can see that module receive the data
GSM-GNSS-GPRS gnss revmsg.png


Deactivate connection

  1. Send AT+CIPCLOSE or AT+CIPSHUT to deactivate the connection.

Test Bluetooth

For more information about AT command: Please refer to: SIM800 series_BT_application_V1.04

Setting

  1. Connecting the Bluetooth antenna to the GSM/GPRS/GNSS HAT. Open the Bluetooth service of your phone and set it visible to all nearby Bluetooth.
  2. AT+BTPOWER=1 Turn on Bluetooth
  3. AT+BTHOST?,Enquiry the name and MAC address of the module, you can also use
  4. AT+BTSCAN=1,10 ,To search available nearby devices. The search time is 10s. During searching, the module will print the information of the available devices to UART. Examples: +BTSCAN: 0,2,"H60-L01",50:a7:2b:bb:a4:50,-47, “0,2” is the ID of this device;“H60-L01” is name of device; “50:a7:2b:bb:a4:50” is MAC address of device;“-47” is the RSSI value.
  5. AT+BTPAIR=0,2, Pair with an available device, the second parameter here is the ID we got at step 4. If you get the response Error, just use AT+BTUNPAIR to delete the pairing data and pair again.
  6. After sending the pair command successfully, you can see that your telephone prompt the pairing request. Then you need to click Pair to accept the request and send AT+BTPAIR on PC to confirm the pairing behavior. With these, module pair with the telephone successfully. If you don’t send the AT command to confirm pairing, the telephone will prompt information that fails to pair after a while. In this case, you need to send the pair command again. You can also use the telephone to send the pairing request, then input AT+BTPAIR=1,1 to confirm it.
GSM-GNSS-GPRS bt config.png


Connecting

  • To test Bluetooth of GSM/GPRS/GNSS, you should use the Bluetooth APP. Scanning the QR code below to download the APP, then you can use its Serial function to test. (The APP is just used for simply testing)
  1. Open the APP, click the SCAN button on the upper right to scan the available devices. Then choose “SIM868” (“SIM868” is default Bluetooth name of GSM/GPRS/GNSS HAT) and click UART. Then you will get the information that +BTCONNECTING on the COM assistant, which means there is a connecting request. If you don’t reply to it for a while, the APP will prompt that connecting failed. And failed information “+BTDISCONN” will be printed on PC
  2. Connecting again, send command AT+BTACPT=1 to confirm and accept Bluetooth connection. You can see that +BRCONNECT is printed on PC shows that succeed in SPP connecting. Then you can send data to the module with the APP.
  3. While receiving the data send from the telephone, the data will be printed with ID of the device, the length of string, and the content on PC.
  4. Send AT+BTSPPSEND command to transmit data. After getting the response >, input the content without Enter at the end. Send 1A in HEX to begin to transmit the data. Then you can see that the data are received by your phone

Workin with Raspberry Pi

Enable serial port

  • Open a terminal and configure interface by the following commands
sudo raspi-config
  • Choose Interfacing Options -> Serial->No->Yes
  • Restart Raspberry Pi
sudo reboot

Install libtaties

  • Install Python libraries
sudo apt-get update
sudo pip install RPi.GPIO
sudo apt-get install python-serial

minicom test

  • Install minicom tool and test
sudo apt-get install minicom
# For Pi 3B\3B+\4B,
sudo minicom -D /dev/ttyS0 -b 9600
# For Pi ZERO\2B
sudo minicom -D /dev/ttyAMA0 -b 9600
# If you want to test with the USB port of Pi, you can change the jumper to A:
sudo minicom -D /dev/ttyUSB0 -b 9600

The default baud rate of minicom is 115200,If you want to change it to 9600, you can add parameter to the command: -b 9600. ttyS0 is the serial port of Pi 3B/3B+, ttyAMA0 of Pi 2B/Zero. If you use USB interface, the port may be ttyUSB*
Here we test Bluetooth as example:

GSM-GNSS-GPRS rpi minicom.png


Demo codes

  • Download
sudo apt-get install p7zip
wget  http://{{SERVERNAME}}/w/images/1/1f/GSM-GPRS-GNSS-HAT-Code.7z
7zr x GSM-GPRS-GNSS-HAT-Code.7z -r -o./GSM-GPRS-GNSS-HAT-Code
sudo chmod 777 -R GSM-GPRS-GNSS-HAT-Code
cd GSM-GPRS-GNSS-HAT-Code/GSM-GPRS-GNSS-HAT-Code/Raspberry\ Pi/
  • We provide some python codes for testing
sudo python call_phone.py 
sudo python send_message.py 
sudo python gps.py

Resources

Examples

Software

Documents