Difference between revisions of "GSM/GPRS/GNSS HAT"
Line 1: | Line 1: | ||
− | [[Category:Modules]][[Category:GPS/GSM| ]] | + | [[Category:Modules| ]][[Category:GPS/GSM| ]] |
{{Infobox item|colorscheme=blue | {{Infobox item|colorscheme=blue | ||
|name=[[GSM/GPRS/GNSS HAT]] | |name=[[GSM/GPRS/GNSS HAT]] |
Revision as of 02:19, 15 September 2017
| ||
Introduction
GSM/GPRS/GNSS HAT, Compatible with Raspberry Pi 2B/3B/Zeo/Zero W
More |
How to use
Hardware configuration
This module comes with power adapter, micro USB cable, GSM antenna, GPS antenna and Bluetooth antenna. Besides these you should prepare two more things:
- A SIM card, the card should be usable and GPRS access (for testing the GPRS)
- 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.
- 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 insert correctly.
GSM Debugging
General AT commands
Command | Description | Return |
---|---|---|
ATE | ATE1 Echo mode on ATE1 Echo mode off |
OK |
AT+COLP | AT+COLP=1 Enable +COLP notification AT_COLP=0 Disable +COLP notification |
OK |
AT+CLIP | AT+CLIP=1 Enable +CLIP notification AT+CLIP=0 Disable +CLIP notification |
OK |
ATD<phone_number>; | Call a phone number, for example: ATD10086; Must finished with Halfwidth semicolon |
OK |
ATA | Answer the phone | OK |
ATH | Hang up the phone | OK |
AT+CNMI | AT+CNMI=2,1 Enable new SMS message indicator | OK |
AT+CMGF | AT+CMGF=1 Set the format of messages to Text mode AT+CMGF=0 Set the format of messages to PDU mode |
OK |
AT+CSCS | Select TE character set AT+CSCS="GSM" GSM 7 bit default alphabet AT+CSCS="UCS2" 16-bit universal multiple-octet coded character set |
OK |
AT+CSMP | AT+CSMP=17,168,2,25 Set SMS text mode parameters | OK |
AT+CMGR | AT+CSMP=17,168,2,25 Set SMS text mode parameters | OK |
AT+CMGS | AT+CMGS="phone_number" Send SMS to the corresponding phone |
> |
0x1A | End mark. Check the option ”Send As Hex” then send it |
For more details of AT commands, please refer to:SIM800 Series_AT Command Manual_V1.09
Make calls
- Insert the SIM card, connect the GSM antenna and TLL serial wires correctly. Then power on the board;
- Check whether the indicators blink correctly (PWR’s and STA’s keep bright, NET’s flashes).
- Send “AT+CPOM?” and Enter to query the status of SIM card. Getting “+CPIN: READY” if the SIM card is OK
- Call number: for example, “ATD10086;” (10086 is the number of China Mobile Communications Corporation)
- Send “ATH” and Enter to hang up the call, as below:
Answer calls
- Enable CLIP notification: AT+CLIP=1 then Enter
- Answering: ATA and Enter; Hang up: ATH then Enter
Send English messages
- Plug the SIM card, connect the GSM antenna and TLL serial wire correctly. Then power on;
- Check whether the indicator blink correctly (PWR and STA keep bright, NET flashes).
- Set the local SMSC:AT+CSCA="+8613800755500" then Enter, get response “OK”. Note: The SMSC will be different on different area. In this part, it is Shenzhen China as examples.
- AT+CMGF=1: Set SMS to TEXT mode;
- AT+CMGS="xxxxxxxxxxx” then Enter, set the number of receiver, then you will get response: >, edit the content of message (needn’t Enter at the end). After editing, 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 send successfully, module will get the reply +CNGS: 174 as below figures.
Receive English messages
- Send a message “this is a receive test” to the GSM/GPRS/GSNN HAT
- While receiving messages, module will report it through UART: “SM”, 3, it means that there are 3 messages in SM, and the message we received just now is the third message.
- Reading messages:AT+CMGR=3 to read the third message (AT+CMGL="ALL" to read all messages)
- Deleting message:AT+CMGD=3, to delete a message as below
Send Chinese message
- AT+CSCS="UCS2", Set the characters set as UCS2
- AT+CSMP=17,128,2,25
- AT+CMGS="00310038003500360035003700300038003600340030", set the phone number of receiver with UCS2 set
- After getting the response >, edit the contents of message (has been converted) without Enter at the end. Then send 1A in HEX format as below
Receive Chinese message
- Send AT+CMGF=1 to set Text mode
- Send AT+CSCS="GSM" to set characters set as GSM
- If receiving messages, module will report it through UART. Reading message: AT+CMGR=3, Then convert the message to Chinese characters with the software as below.
GPS Debugging
General AT commands
Command | Description | Return |
---|---|---|
AT+CGNSPWR | AT+CGNSPWR=1 Turn on the power of GPS AT+CGNSPWR=0 Turn off the power of GPS |
OK |
AT+CGNSIPR | AT+CGNSIPR? Enquiry the baud rate of GPS AT+CGNSIPR=<Baudrate> Set the baud rate of GPS |
The current baud rate OK |
AT+CGNSTST | AT+CGNSTST=1 Send data received to UART AT+CGNSTST=0 Stop sending data received to UART |
OK |
AT+CGNSINF | GNSS navigation information parsed from NMEA sentences | Print the GPS information |
AT+CGPSSTATUS | Check GPS status |
For more details of AT commands, please refer to:SIM868 Series GNSS Application Note V1.00
GPS Configuration
- Connecting the GPS antenna, and place the receiver on open area outdoor
- Turn on power of GPS: AT+CGNSPWR=1
- Check the baud rate: AT+CGNSIPR?
- Start to sending data received to UART: AT+CGNSTST=1:
- 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 them in Receiver option or click icons which is on the panel directly):
- Choose Player>, then you can see the information of GPS:
GPRS Debugging
General AT commands
Command | Description | Return |
---|---|---|
AT+CGATT | AT+CGATT? Check the state of GPRS attachment | +CGATT:1 1 Attached |
AT+CSTT | AT+CSTT="CMNET" Set APN to CMNET | OK |
AT+CIICR | Bring up wireless connection with GPRS | OK |
AT+CIFSR | Get local IP address | OK |
AT+CIPSTART | AT+CIPSTART="Mode", "IP_Addr", "Port" Mode: connection type; IP_Add: Remote server IP address; Port: Remote server port |
CONNECT OK |
AT+CIPSEND | Send data | OK |
1A | (HEX format) Tell module to send data | SEND OK |
AT+CIPCLOSE | Close TCP or UDP connection | CLOSE OK |
AT+CIPSHUT | Deactivate GPRS PDP Context | SHUT OK |
For more details of AT commands, please refer to:SIM800 Series_AT Command Manual_V1.09
Local virtual severs settings
Virtual servers define the mapping between service ports of WAN and web servers of LAN. All requests from Internet to service ports of WAN will be redirected to the computer (web servers of LAN) specified by the server IP. (see your router’s guide manual)
- Log in Management Console of your router with browser (read your router’s guide manual for specific address)
- Set Port:5000 (The Port can’t be conflict to other’s. Here we set 5000)
- Set LAN IP address of your computer (you can run CMD on your computer, and execute command ipconfig to enquiry the address of IPv4), 192.168.1.14 as examples
Searching WAN IP
You can search “IP” on browser to get your WAN IP address, as below:
GPRS Setting
- AT+CSQ To enquiry the quality of signal. The first parameter of response is signal quality (Max is 31). The signal stronger, the value bigger.
- AT+CREG? Check Network registration. If the second parameter of response is 1 or 5, it means that Network has been registered successfully
- AT+CGATT? Check the state of GPRS attachment
- AT+CSTT="CMNET" Set the Network according to actual situation. Here we use CMNET
- AT+CIICR Bring up wireless connection with GPRS
- AT+CIFSR Get the local IP address
- AT+CIPSTART="TCP","113.81.232.4",5000 Established TCP/IP connection
Sending data
- AT+CIPSEND GSM/GPRS/GNSS module ready to send data to server
- After getting the response >, edit the contents of 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.
Receiving data
- Choose the IP address of module on peers input box
- Input the data which you want to send:hello,i am server,please receive my message
- Click Send button, you can see that module receive the data with COM assistant software
Deactivating Connection
Send AT+CIPCLOSE or AT+CIPSHUT to deactivate connection.
Bluetooth Debugging
General AT Commands
Command | Description | Return |
---|---|---|
AT+BTPOWER=1 | AT+BTPOWER=1 Turn on Bluetooth AT+BTPOWER=0 Turn off Bluetooth |
OK |
AT+BTHOST | AT+BTHOST? Enquiry the name and address of Bluetooth AT+BTHOS=<Name> Change the name of Bluetooth |
The name and MAC address of Bluetooth |
AT+BTSCAN | AT+BTSCAN=1,10 Search nearby Bluetooth devices | Information of Bluetooth device searched +BTSCAN:<Num> |
AT+BTPAIR | AT+BTPAIR=0,1 Pair with device 1 AT+BTPAIR=1,1 Confirm pairing |
OK |
AT+BTUNPAIR | AT+BTUNPAIR=0 Delete the pairing data stored | OK |
AT+BTACPT | AT+BTACPT=1 Confirm SPP connection | OK |
AT+BTSPPSEND | AT+SPPSEND Send data | nput data after getting > response |
Bluetooth Setting
- Connecting the Bluetooth antenna to the GSM/GPRS/GNSS HAT. Open the Bluetooth of your telephone, and make it visible to all nearby Bluetooth.
- AT+BTPOWER=1, Turn on Bluetooth
- AT+BTHOST? Enquiry the name and MAC address of module, you can also use AT+BTHOST=<Name> Command to change the Bluetooth name of GSM/GPRS/GNSS HAT
- AT+BTSCAN=1,10 To search available nearby devices. Search time is 10s. During searching, module will print the information of available device via UART. For example, +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, and “-47” is the RSSI value.
- AT+BTPAIR=0,2 , Pair with available device proactively, the second parameter here is the ID we got at step 4 . If get the response Error, just use AT+BTUNPAIR to delete the pairing data and pair again.
- After sending the pair command successfully, you can see that your telephone prompt the pair request. Then you need to click Pair to accept the request, and send AT+BTPAIR on PC to confirm the pair 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 fail to pair after a while. In this case, you need to send the pair command again. You can also use the telephone to originate the pairing request, then input AT+BTPAIR=1,1 to confirm it.
Bluetooth Connecting
To test Bluetooth connection and communication with GSM/GPRS/GNSS, you can use the Bluetooth APP. Scanning the QR code below to download the APP, then you can use it’s Serial function for test. (The APP is just used for simply test)
- Open the APP, click SCAN button on the upper right to scan the available devices. Then choose “SIM868” (“SIM868” is the 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 are connecting request. If you don’t reply it for a while, the APP will prompt that connecting failed. And the Assistant software will print +BTDISCONN to prompt you connecting failed.
- Connecting again, send command AT+BTACPT=1 to confirm and accept Bluetooth connection. You can see that +BRCONNECT is printed on the Assistant shows that succeed SPP connection. Then you can send data to the module with the APP.
- While receiving the data send from the telephone, the data will be print with ID of device, the length of string and the content on the Assistant software.
- Send AT+BTSPPSEND command to transmit data. After getting the response >, input the content without Enter at the end. Send 1A in HEX begin to transmit the data. Then you can see that the data is received by your phone.
Using with Raspberry Pi
UART configuration of Raspberry Pi
Because UART of Raspberry Pi is used for Linux console output by default, if we want to use the UART, we need to change the settings. Executing this command to enter the configuration page :
sudo raspi-config
Choose Advanced Options -> Serial -> no
, to disable Linux’s use of console UART
Open /boot/config.txt file, find the below statement and uncomment it to enable the UART. You can directly append it at the end of file as well.
enable_uart=1
Then reboot.
Minicom for UART debugging on Raspberry Pi
Inserting the module to Raspberry Pi and plug the jumper B,
Install minicom,minicom is a text-based modem control and terminal emulation program for Linux:
sudo apt-get install minicom
Execute command: minicom -D /dev/ttyS0
(ttyS0 is the UART of Raspberry Pi 3B)
Baud rate is 115200 by default. If you need to change the baud rate, for example 9600, you can add the parameter -b 9600.
The user UART device of Raspberry Pi 2B/Zero is ttyAMA0, and ttyS0 of Raspberry Pi 3B
Testing Bluetooth function as examples:
Examples
Python examples are provided for Raspberry Pi
- Executing sudo python call_phone.py to make a call, if you want to change the phone number on code, just need to modify the parameter W_buf_phone as below:
- Executing sudo python send_message.py to send a message.
- Changing the number of receiver: the penultimate parameter of W_buff array.
- Changing the content of message:The last parameter of W-buff array
- Executing sudo python gps.py to get the GPS information
Resources
Datasheets
SIM868 Related
- SIM800_Series_AT_Command_Manual_V1.09
- SIM868_GNSS_AGPS_Application
- SIM868_GNSS_Application_Note_V1.00
- SIM868_Reference_Design_V1.01(160310)
- SIM868_RF_Design_Application_Note_V1.00
- File:SIM868_Series_Hardware_Design_V1.06
Other Chips
FAQ
Support
If you require technical support, please go to the Support page and open a ticket.