Google Chat: zj734465502@gmail.com
+86-0755-88291180
sales01@spotpear.com
dragon_manager@163.com
services01@spotpear.com
manager01@spotpear.com
WhatsApp:13246739196
R800C GSM/GPRS HAT features GSM (Global System for Mobile Communications) and GPRS (General Packet Radio Service) functions for Raspberry Pi. It has the advantages of small size and low power consumption, and can easily realize functions such as making calls, sending text messages, and surfing the Internet wirelessly.
5V | Power input (5V) |
GND | Ground |
RX1 | Serial port 1 data receiving |
TX1 | Serial port 1 data transmitting |
DTR | Sleep control pin is pulled high to sleep, pulled low to wake up (must set "AT+CSCLK=1") |
RI | The interrupt wake-up pin defaults to a high level, and there will be a 120ms low-level pulse when receiving a short message or URC report (must set "AT+CFGRI=1") |
RX2 | Serial port 2 data receiving |
TX2 | Serial port 2 data transmitting |
PWR | Switch control pin |
RESET | The reset pin can be reset when the power-on state is pulled low, and the power-off state is invalid |
VCCIO | The working level can be set to 3.3V or 5V via the jumper cap |
PWR | On/off control pin, connected to P4 pin of Raspberry Pi by default |
PWR | Lights up when power is supplied to the 5V and GND of the module |
NET | 64ms on/800ms off - unregistered on the network 64ms on/3000ms off - registered on the network 64ms on/300ms off - data transmission off - power off or PSM sleep mode |
Before using the R800C module, in addition to the micro USB cable and the GSM/Bluetooth antenna, the user also needs to prepare the following items:
Hardware connection operation:
The following table lists some commonly used AT commands, which can quickly and easily detect whether the AT serial communication and network connection of R800C is normal. Before performing the network communication experiment demonstrated below, it is recommended to do a simple network test first to confirm that the network connection is normal before operating.
Related AT command details can be found in R800C Series_AT Command Manual.
Command | Description | Return value |
AT | AT test command | OK |
ATE | ATE1 set echo, ATE0 disable echo | OK |
AT+CSQ | Network signal quality query, return signal value | OK |
AT+CGMR | Query firmware version | OK |
AT+CREG? | Query network registration status | OK |
AT+CGATT? | Check GPRS attachment status | OK |
Test steps:
Test steps:
Test steps:
The TCP/IP application of R800 series modules has two connection modes, which can be set by the command AT+CIPMUX=<n>. When AT+CIPMUX=0, it is single-link mode; when AT+CIPMUX=1, it is the multi-link mode. The default setting is the single-link mode.
When in single link mode, R800 series modules can work in transparent transmission mode and non-transparent transmission mode. In these two transmission modes, the module can be configured as a TCP/UDP client or a TCP server.
When in multi-link mode, R800 series modules only work in non-transparent mode.
In this mode, the module can be used as an absolute TCP/UDP connection client, and it can establish a total of 6 connections; it can also be configured as a TCP server, and it can also be configured as a 5-way TCP/UDP client. R800C TCP/IP is a multi-channel client architecture by default, supporting 5 sockets in total, including TCP or UDP.
The following will focus on demonstrating the client communication of the R800C in single-link non-transparent mode and transparent mode.
For detailed instructions related to TCP/IP communication, please refer to: R800C Series_TCPIP_Application_Note.
Related commands:
AT Command | Command Description | Return Value |
AT+CGATT? | Check GPRS attachment status | OK |
AT+CSTT="CMNET" | Set APN | OK |
AT+CIICR | Establish a wireless link | OK |
AT+CIFSR | Get local IP address | OK |
AT+CIPSTART="TCP","118.190.93.84",2317 | Establish a TCP client connection | OK |
AT+CIPSTART="UDP","118.190.93.84",2317 | Establish UDP client connection | OK |
AT+CIPSEND=<Character length> | Send a string of specified length | OK |
AT+CIPCLOSE | Close link communication | OK |
AT+CIPSHUT | Close the PDP context connection | OK |
Related commands:
AT Command | Command Description | Return Value |
AT+CGATT? | Check GPRS attachment status | OK |
AT+CIPMODE=1 | Set to transparent transmission mode | OK |
AT+CSTT="CMNET" | Set APN | OK |
AT+CIICR | Establish wireless link | OK |
AT+CIFSR | Get local IP address | OK |
AT+CIPSTART="TCP","118.190.93.84",2317 | Establish a TCP client connection | OK |
AT+CIPSTART="UDP","118.190.93.84",2317 | Establish UDP client connection | OK |
AT+CIPSEND=<Character length> | Send a string of specified length | OK |
AT+CIPCLOSE | Close link communication | OK |
AT+CIPSHUT | Close the PDP context connection | OK |
You can freely switch between transparent transmission mode and command mode through the following methods.
(1) If the fourth parameter of AT+CIPCCFG is 1, it supports to exit the transparent transmission mode through the escape sequence. The default escape sequence is +++. To use this sequence correctly, you must ensure that there is a 1000ms idle before the sequence and a 1000ms idle after the sequence. It should also be noted that the interval between each + should not exceed 1000ms, otherwise it may be regarded as TCP/IP data.
(2) The DTR pin of the serial port can be used. To use this method, first set up AT&D1, ground the DTR pin for at least 1 second, and then pull it high. This method can switch from data mode to command mode. The reported string "OK" indicates that the module is currently in command mode.
(3) For the TCP client connection, if the remote server disconnects, the module will automatically switch to the command mode.
(4) For the TCP server connection, if the remote client disconnects, the module will automatically switch to the command mode.
(5) Restart the module.
This chapter mainly introduces the HTTP communication function of the R800C module, mainly divided into HTTP GET and HTTP POST.
For detailed usage instructions of HTTP and FTP communication functions, please refer to R800C Series_IP_Application_Note.
Related commands:
AT Command | Command Description | Return Value |
AT+SAPBR=3,1,"Contype","GPRS" | Configuring Bearer Scenario 1 | OK |
AT+SAPBR=3,1,"APN","CMNET" | Configure bearer scenario 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+HTTPINIT | Check the HTTP connection status | OK |
AT+HTTPPARA="CID",1 | Set HTTP session parameters | OK |
AT+HTTPPARA="URL","www.sim.com" | Set HTTP session parameters | OK |
AT+HTTPACTION=0 | GET session start | OK |
AT+HTTPREAD | Read data from the HTTP server | OK |
AT+HTTPTERM | End HTTP service | OK |
Related commands:
AT Command | Command Description | Return Value |
AT+SAPBR=3,1,"Contype","GPRS" | Configuring Bearer Scenario 1 | OK |
AT+SAPBR=3,1,"APN","CMNET" | Configure bearer scenario 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+HTTPINIT | Check HTTP connection status | OK |
AT+HTTPPARA="CID",1 | Set HTTP session parameters | OK |
AT+HTTPPARA="URL","www.sim.com" | Set HTTP session parameters | OK |
AT+HTTPDATA=100,10000 | Upload 100 bytes of data, wait for 10000 milliseconds | OK |
AT+HTTPACTION=1 | GET session start | OK |
AT+HTTPTERM | End HTTP service | OK |
The R800C GSM GPRS HAT has a Raspberry Pi GPIO interface onboard, which can be directly plugged into various versions of the Raspberry Pi;
The following table shows the connection between Raspberry Pi pins and module pins (Raspberry Pi 3B+):
R800C GSM/GPRS HAT | Raspberry Pi |
5V | 5V |
GND | GND |
RXD | TXD (corresponding to 14 of BCM) |
TXD | RXD (corresponding to 15 of BCM) |
PWR | P7 (corresponding to P4 of BCM) |
The factory default PWR pin of the module is selected to the P4 pin of the Raspberry Pi through a jumper cap. In order to ensure that the R800C GSM/GPRS HAT can work normally after being connected to the Raspberry Pi, it is necessary to initialize the level of the Raspberry Pi pin output.
The reference operation is as follows:
chmod 777 pi_gpio_init.sh
sudo nano /etc/rc.local
sh /home/pi/SIM800C/pi_gpio_init.sh
Since the Raspberry Pi serial port is used for terminal debugging by default, if you want to use the serial port, you need to modify the Raspberry Pi settings.
sudo raspi-config
enable_uart=1
Insert the module into the Raspberry Pi, and install minicom. (Minicom is a serial port debugging tool on the Linux platform.)
sudo apt-get install minicom
Execute minicom -D /dev/ttyS0 to enter the minicom serial port debugging interface.
The default baud rate is 115200, ttyS0 is the serial port of Raspberry Pi 3B/3B+, Zero/2B is ttyAMA0.
In the Raspberry Pi Raspbian system, R800C supports pppd dial-up Internet access via serial port, and the steps are shown below:
1. Install PPP.
sudo apt-get install ppp
2. Switch to root user.
sudo su
3. Enter /etc/ppp/peers directory, copy provider file and name it as gprs.
cd /etc/ppp/peers cp provider gprs
4. Open and edit gprs (here use nano to open as an example).
5. Run the command to start dialing in the background.
pppd call gprs &
6. Run the ifconfig command to see the ppp0 network card.
Ifconfig
7. If you cannot access the Internet normally at this time, it will prompt that DNS cannot be resolved, you can add the following command to configure the routing table.
route add -net 0.0.0.0 ppp0
After using minicom to communicate with the serial port of the HAT, you need to restart the HAT first, and vice versa.
Download the demo, after decompression, enter the directory under R800C_python:
cd R800C_GSM_GPRS_HAT_Code/bcm2835/bcm2835 chmod +x configure && ./configure && sudo make && sudo make install #Wait for the bcm2835 library to be compiled and installed
If there is a problem in the compilation and installation process, please refer to the FAQ.
Enter basic AT commands and receive replies from the HAT.
make clean && make sudo ./main
After running the demo, the demo will first check whether the serial communication with the module is normal. After the communication is normal, it will automatically send a series of commands to check the status of the module; after completing the check, you can input AT commands to control the module according to the prompts.
After checking that the communication status of the HAT is normal, insert the headphone on the HAT, run this demo, and complete the dialing. After a period of time, the phone will automatically hang up. The dialed phone number and the time before hanging up can be set in the demo file.
make clean && make sudo ./main
After checking that the communication status of the HAT is normal, run this demo, and the demo will return the success sign after sending successfully according to the pre-set SMS recipient number and English SMS content. The recipient of the SMS and the content of the English SMS can be modified in the demo.
make clean && make sudo ./main
After using minicom to communicate with the serial port of the expansion board, you need to restart the expansion board first, and vice versa.
Download the demo, after decompression, enter the python directory:
cd R800C_GSM_GPRS_HAT_Code/python
Enter basic AT commands and receive replies from the HAT.
python AT.py
Send a series of commands to check the status of the HAT and obtain ITS connection information.
python check.py
After checking that the communication status of the HAT is normal, insert the headphone, run this demo, enter the correct phone number according to the prompts, and complete the dialing; use ctrl+C to hang up the phone and terminate the demo.
python call.py
After checking that the communication status of the HAT is normal, run this demo, input the SMS recipient number and the content of the English SMS according to the prompts, and the demo will end automatically after the sending is successful.
python send_message.py
If the communication status checks the result of the HAT is normal, but the sending of the SMS fails, you can try to change the SMS center number (do not modify it unless necessary).
nano send_message.py #Here we use nano as an example, other editors can also be used