Google Chat: zj734465502@gmail.com
+86-0755-88291180
sales01@spotpear.com
dragon_manager@163.com
services01@spotpear.com
manager01@spotpear.com
WhatsApp:13246739196
GSM/GPRS HAT for Raspberry Pi, Based on SIM800C
PIN | Description |
---|---|
5V | 5V power input |
GND | Ground |
RX1 | Serial port 1 Data receiver |
Tx1 | Serial port 2 Data transmission |
DTR | Sleep control pin. High: Sleep; Low: Wake-up (should set AT+CSCLK=1) |
RI | Interrupt wake-up pin. this pin defaults to high and keep low for 120ms when URCs are reported or SMS received. (should set "AT+CFGRI=1") |
RX2 | Serial port 2 Data receiver |
TX2 | Serial port 2 Data transmission |
PWR | Power control pin |
RESET | When power is on, you can reset module by pulling-down the reset pin. It is unavailable when power off |
Raspberry Pi 40PIN
PWR | Light: Module is powered on with 5V voltage input |
NET | light on for 64ms and off for 800ms: Not registered the network |
Connect to PC
In addition to the micro USB cable and GSM/Bluetooth antenna, users need to prepare the following before using the SIM800C module.
Networking testing
The following table lists some common AT commands that can be used to quickly and easily detect whether the SIM800C's AT serial communication and network connection are normal. Before following the steps of the network communication demonstration described in the table below, it is recommended to do a simple network test to confirm that the target network connection is normal and operable.
Commands | Description |
---|---|
AT | AT Test Command |
ATE | ATE1: Turns on echoing; ATE0: Turns off e'choing. |
AT+CSQ | Network signal quality query, returns a signal value |
AT+CGMR | Request firmware version |
AT+CREG? | Request network registration status |
AT+CGATT? | Check for GPRS attachment service status |
For details AT commands, please refer to SIM800C Series_AT_Command Manual ===TCP/IP Communication
SIM800 series TCPIP Structure
The TCP/IP application of the SIM800 serial module has two connection modes, which can be set by the command AT CIPMUX=<n>. When AT CIPMUX is set to 0 (AT+CIPMUX=0), it is in single link mode; when AT CIPMUX is set to 1 (AT+CIPMUX=1), it is in multi-link mode. The module is set as single link mode by default.
In single link mode, the SIM800 serial module can operate in both transparent and non-transparent modes. In both transmission modes, the module can be configured as a TCP/UDP client or as a TCP server.
In multi-link mode, the SIM800 serial module can only work in non-transparent mode.
In this mode, the module can work as an absolute TCP/UDP connection client, which can establish a total of 6 connections; it can also be configured as a TCP server, and can also be configured with 5 TCP/UDP clients. SIM800C TCP/IP defaults to a multi-client architecture that supports a total of five sockets, including TCP or UDP.
With the following demonstrations we will focus on the client communication of the SIM800C, in single-link non-transparent mode and transparent mode.
【Client communication in non-transparent mode】
Non-Transparent Mode TCP Clinet testing
AT Commands | Description |
---|---|
AT+CGATT? | Check GPRS attachment service status |
AT+CSTT="CMNET" | Set APN |
AT+CIICR | Establish a wireless connection |
AT+CIFSR | Retrieve the local IP address |
AT+CIPSTART="TCP","118.190.93.84",2317 | Establish a TCP client connection |
AT+CIPSTART="UDP","118.190.93.84",2317 | Establish a UDP client connection |
AT+CIPSEND=<string length> | Send a specified string length |
AT+CIPCLOSE | Close the connection |
AT+CIPSHUT | Close PDP context connection |
【Client communication in transparent transmission mode】
Transparent mode TCP Client testing
AT Commands | Description |
---|---|
AT+CGATT? | Check GPRS attachment service status |
AT+CIPMODE=1 | Set to transparent mode |
AT+CSTT="CMNET" | Set APN |
AT+CIICR | Establish a wireless connection |
AT+CIFSR | Retrieve the local IP address |
AT+CIPSTART="TCP","118.190.93.84",2317 | Establish a TCP client connection |
AT+CIPSTART="UDP","118.190.93.84",2317 | Establish a UDP client connection |
AT+CIPSEND=<string length> | Send a specified string length |
AT+CIPCLOSE | Close the connection |
AT+CIPSHUT | Close PDP context connection |
To switch between the transparent transmission mode and the command mode, any of following methods describe below are available.
This chapter introduces the HTTP communication function of SIM800C module, which is mainly divided into HTTP GET and HTTP POST. For more details information about the HTTP and FTP communication, please refer to SIM800C Series_IP_Application_Note
【HTTP GET】
HTTP GET testing
AT Commands | Description |
---|---|
AT+SAPBR=3,1,"Contype","GPRS" | Configure bearer profile 1 |
AT+SAPBR=3,1,"APN","CMNET" | Configure the bearer profile APN. |
AT+SAPBR=1,1 | Open a GPRS context |
AT+SAPBR=2,1 | Query a GPRS context |
AT+SAPBR=0,1 | Close the GPRS context. |
AT+HTTPINIT | Check the HTTP connection status |
AT+HTTPPARA="CID",1 | Set parameters for HTTP session |
AT+HTTPPARA="URL","www.sim.com" | Set parameters for HTTP session |
AT+HTTPACTION=0 | GET session start |
AT+HTTPREAD | Read the data of the HTTP server |
AT+HTTPTERM | End HTTP service |
【HTTP Post】
HTTP POST testing
AT Commands | Description |
---|---|
AT+SAPBR=3,1,"Contype","GPRS" | Configure bearer profile 1 |
AT+SAPBR=3,1,"APN","CMNET" | Configure the bearer profile APN. |
AT+SAPBR=1,1 | Open a GPRS context |
AT+SAPBR=2,1 | Query a GPRS context |
AT+SAPBR=0,1 | Close the GPRS context. |
AT+HTTPINIT | Check the HTTP connection status |
AT+HTTPPARA="CID",1 | Set parameters for HTTP session |
AT+HTTPPARA="URL","www.sim.com" | Set parameters for HTTP session |
AT+HTTPDATA=100,10000 | Upload 100 bytes data, waiting for 10000ms |
AT+HTTPACTION=0 | GET session start |
AT+HTTPREAD | Read the data of the HTTP server |
AT+HTTPTERM | End HTTP service |
The TCP/IP application of the SIM800 serial module has two connection modes, which can be set by the command AT+CIPMUX=<n>.
Sending email 1
Sending email 2
【Sending emails】
For sending emails some of the features this module offers are sending ordinary emails, set the email Carbon-copy; it can also email attachments, send it encoded as UTF-8 etc. We provide a simple operation demonstration of how to send an ordinary email.
Receiving email
AT Commands | Description | Return |
---|---|---|
AT+SAPBR=3,1,"Contype","GPRS" | Configure bearer profile 1 | OK |
AT+SAPBR=3,1,"APN","CMNET" | Configure the bearer profile APN. | OK |
AT+SAPBR=1,1 | Open a GPRS context | OK |
AT+SAPBR=2,1 | Query a GPRS context | OK |
AT+SAPBR=0,1 | Close the GPRS context. | OK |
AT+EMAILCID=1 | Configure email parameters | OK |
AT+EMAILTO=30 | Set time value of the server response | OK |
AT+SMTPSRV="smtp.ym.163.com",25 | Set SMTP server address and port | OK |
AT+SMTPAUTH=1,"kaloha@waveshare.net","123456" | Set username and password | OK |
AT+SMTPFROM="kaloha@waveshare.net","kaloha" | Set the sender address and name | OK |
AT+SMTPRCPT=0,0,"kallanlw@163.com","kallanlw" | Set a recipient | OK |
AT+SMTPRCPT=1,0,"john@sim.com","john" | Set the CC email and name | OK |
AT+SMTPSUB="Test" | Set the email subject | OK |
AT+SMTPBODY=19 | Set the message body | OK |
This is a new Email | Content of the email | OK |
AT+SMTPSEND | Send the email | OK |
AT+SAPBR=3,1,"Contype","GPRS" | Configure bearer profile 1 | OK |
AT+SAPBR=3,1,"APN","CMNET" | Configure the bearer profile APN. | OK |
AT+SAPBR=1,1 | Activate a GPRS context | OK |
AT+SAPBR=2,1 | Query GPRS context | OK |
AT+SAPBR=0,1 | Close the GPRS context. | OK |
AT+EMAILCID=1 | Configures email parameters | OK |
AT+EMAILTO=30 | Set time value of the server response | OK |
AT+SMTPSRV="smtp.ym.163.com",25 | Set SMTP server address and port | OK |
AT+SMTPAUTH=1,"kaloha@waveshare.net","123456" | Set username and password | OK |
AT+SMTPFROM="kaloha@waveshare.net","kaloha" | Set sender address and name | OK |
AT+SMTPRCPT=0,0,"kallanlw@163.com","kallanlw" | Set the email recipient address and name | OK |
AT+SMTPRCPT=1,0,"john@sim.com","john" | Set the email CC address and name | OK |
AT+SMTPSUB="Test" | Set the email subject | OK |
AT+SMTPBODY=19 | Set the message body | OK |
This is a new Email | Content of email | OK |
AT+SMTPSEND | Send email | OK |
【Receiving emails】
AT Commands | Description | Return |
---|---|---|
AT+SAPBR=3,1,"Contype","GPRS" | Configure bearer profile 1 | OK |
AT+SAPBR=3,1,"APN","CMNET" | Configure the bearer profile APN. | OK |
AT+SAPBR=1,1 | Activate a GPRS context | OK |
AT+SAPBR=2,1 | Query a GPRS context | OK |
AT+SAPBR=0,1 | Close the GPRS context. | OK |
AT+EMAILCID=1 | Configure email parameters | OK |
AT+EMAILTO=30 | Set time value of the server response | OK |
AT+POP3SRV="pop.ym.163.com","kaloha@waveshare.net","123456",110 | Set POP3 server address and account information | OK |
AT+POP3IN | Log in to the POP3 server | OK |
AT+POP3NUM | Get the total number of messages and its total size | OK |
AT+POP3LIST=1 | Get the size of first email | OK |
AT+POP3CMD=4,1 | Read the first message | OK |
AT+POP3READ=1460 | Read the message content | OK |
【SMS sending and receiving】
Sending SMS
The TCP/IP application of the SIM800 serial module has two connection modes, which can be set by the command AT+CIPMUX=<n>.
【Sending message】
(1A is the key value of "CTRL+Z", which is used to tell the module to perform the “send” operation. To cancel the operation, send 1B or "ESC")
【Receiveing message】
Receiving message
The SIM800 serial module supports Bluetooth 3.0 and other profiles such as SPP, OPP and HFP/HSP.
The commands in the table below mainly demonstrates the Bluetooth SPP serial communication functionality.
For more information about Bluetooth, please refer to SIM800C_Series_BT_Application_Note
Bluetooth debugging 1
AT Commands | Description | Return |
---|---|---|
AT+BTPOWER=1 | Turn on the Bluetooth power | OK |
AT+BTHOST? | Query Bluetooth name and address | OK |
AT+BTSCAN=1,10 | Search for nearby Bluetooth devices | OK |
AT+BTPAIR=1,1 | Digital confirmation mode response pairing | OK |
AT+BTACPT=1 | Accept client connection request | OK |
AT+BTSPPSEND | Send data | OK |
AT+BTPOWER=0 | Turn off the Bluetooth power | OK |
Test steps:
Bluetooth debugging 2
SIM800C GSM GPRS HAT has 40PIN header on board, compatible with any revision of Raspberry Pi.
Connecting to Raspberry Pi
Hardware connection
SIM800C GMS/GPRS HAT | Raspberry Pi |
---|---|
5V | 5V |
GND | GND |
RXD | TXD (BCM P14) |
TXD | RXD (BCM P15) |
PWR | P7 (BCM P4) |
【Pin initialization】
The default PWR pin of the module is to jump to the P4 pin of raspberry pi by placing a jumper cap. In order to ensure that SIM800C GSM/GPRS HAT can work properly after it is connected to raspberry pi, it is necessary to initialize the level output of raspberry pi board pin.
chmod 777 pi_gpio_init.sh
sudo nano /etc/rc.local
sh /home/pi/SIM800C/pi_gpio_init.sh
【Serial port setting】
The serial port of Raspberry Pi is set for shell login by default. Therefore, we need to disable shell login function and enable hardware serial
sudo raspi-config
enable_uart=1
Press the PWRKEY button and hold for about 1 second. Waiting for about 2 seconds. You should see that the NET light starts flashing. This means the module is powered on successfully.
Install minicom on your Raspberry
sudo apt-get install minicom
Then execute command minicom -D /dev/ttyS0 to run the minicom
Note that the defualt baud rate is 115200, serial port is ttyS0 (for Raspberry Pi 3B/3B+ is ttyS0, for Raspberry Pi Zero/2B it should be ttyAMA0)
About the PPP networing, you can refer to this page: SIM868 PPP Dail-up Networking