SIM7020E NB-IoT HAT
| ||
Introduction
NB-IoT HAT for Raspberry Pi, Based on SIM7020E
More |
User Manual
Overview
This is an NB-IoT (NarrowBand-Internet of Things) HAT for Raspberry Pi, controlled via serial AT commands, supports communication protocols like LWM2M/COAP/MQTT, etc. Due to the advantages of low delay, low power, low cost, and wide coverage, it is the ideal choice for IoT applications such as intelligent instruments, asset tracking, remote monitoring, and so on.
Features
- Raspberry Pi connectivity, compatible with any revision.
- Supports communication protocols such as LWM2M/COAP/MQTT/TCP/UDP/HTTP/HTTPS, etc.
- Onboard USB interface, for the power supply or debugging.
- Breakout UART control pins, to connect with host boards like Arduino/STM32.
- Onboard voltage translator, 3.3V by default, allows being switched to 5V via onboard jumper.
- SIM card slot, supports NB-IoT specific card.
- 2 x LED indicators, easy to monitor the working status.
- Baudrate: 300bps~921600bps (115200bps by default).
- Control via AT commands (V.25TER, 3GPP TS 27.007, and SIMCOM AT Commands).
- Comes with online development resources and manuals (examples for Raspberry Pi/Arduino/STM32/Python).
Specification
Communication
- Band
- FDD-LTE B1/B3/B5/B8/B20/B28
- Data rate
- Uplink≤62.5Kbps
- Downlink≤26.15Kbps
- SMS
- Text mode and PDU mode (depends on the NB card)
General
- Power supply: 5V
- Logic level: 5V/3.3V (3.3V by default)
- Overall current (idle mode): ~18mA
- Single module current (VBAT=3.3V):
- Idle mode: 5.6mA
- Sleep mode: 0.4mA
- PSM mode: 5uA
- eDRX mode: 70uA (eDRX=655.36s)
- Dimension: 30.5mm x 65.0mm
Interfaces
PIN | Description |
---|---|
5V | 5V power inut |
GND | Ground |
RX1 | Serial port 1 receives data |
TX1 | Serial port 1 sends data |
DTR | Sleep Control, High: Sleep; Low: Wake up (need to be set with "AT+CSCLK=1") |
RI | Interrupt PIN, High by default. It becomes Low (120ms) when messages are received or URC is reported) (need to be set with "AT+CFGRI=1") |
RX2 | Serial port 2 receives data |
TX2 | Serial port 2 sends data |
PWR | Power control |
RESET | Reset |
Jumpers
Jumpers | Descriptions |
---|---|
VCCIO | Set the operating voltage to 3.3V or 5V |
PWR | Set the power control, set to controllable by P4 (BCM) pin of Raspberry Pi by default |
Indicators
LEDs | Descriptions |
---|---|
PWR | On: The module is powered on |
NET | On(64ms)&OFF(800ms): Internet isn't registered On(64ms)&OFF(3000ms): Internet is registered On(64ms)&OFF(300ms): Data are transmitting OFF: Power off or PSM Sleep Mode |
Working with Windows PC
Hardware connection
The external components required:
- A special sim card that supported NB-IoT.
- A USB to TTL module (Recommend CP2102 USB to UART Module).
Connection:
- Insert sim card to the backside card slot, connect LTE antenna (The LTE antenna must be rotated to the outside of the board).
- Connect CP2102 module to UART1 (or UART2) of SIM7020E NB-IoT HAT(SIM7020 hereafter), and connect to your PC by USB cable.
- Power on SIM7020. (PWR: On; NET: OFF)
- Press PWRKEY buttons for about 1s (NET: Blinking).
- Download the serial assistance software and open it. Set it to 115200 8N1, and check the newline options.
- Click Extend to get the pre-configured commands. Testing:
Quick testing
Herein we list some common commands that can be used to quickly test the SIM7020.
Command | Description | Return |
---|---|---|
AT | Check module status | OK |
ATE | ATE1: Echo Mode On; ATE0: Echo Mode Off | OK |
AT+CSQ | Check Internet Signals Quality | OK |
AT+CGMR | Check Firmware Version | OK |
AT+CGREG? | Check Internet register status | OK |
AT+CGACT? | Check PDP status | OK |
AT+COPS? | Check Internet Information | OK |
AT+CGCONTRDP | Check Internet status | OK |
AT+CFUN=0 | Turn off RF | OK |
AT*MCGDEFCONT | Set APN, e,g: AT*MCGDEFCONT="IP","3GNET" | OK |
AT+CFUN=1 | Turn On RF | OK |
TCP/IP Communication
SIM7020 cannot support transparent and server mode.
TCP/IP of SIM7020 is a multiple-client structure, which supports up to 5 sockets (like TCP or UDP).
Connect modules and test network connection by following the instructions above before TCP/IP communicating.
For more information about TCP, UDP, DNS, etc. Please refer to SIM7020 Series_TCPIP_Application_Note.
【TCP Client】
Commands | Description | Return |
---|---|---|
AT+CSOC=1,1,1 | Create TCP socket, <socket_id>=0 | OK |
AT+CSOCON=0,2317,"118.190.93.84" | Connect to remote server | OK |
AT+CSOSEND=0,0,"Hello World" | Send data | OK |
AT+CSOCL=0 | Close socket | OK |
AT+CSOSENDFLAG | Enable Send ACK | OK |
AT+CSORCVFLAG | Enable receive ACK | OK |
AT+CSOCON? | Check communication port and type | OK |
【UDP Client】
Commands | Descriptions | Return |
---|---|---|
AT+CSOC=1,2,1 | Create UDP socket, <socket_id>=0 | OK |
AT+CSOCON=4,524,"116.247.119.165" | Connect remote server | |
AT+CSOSEND=4,0,"Waveshare" | Send data | OK |
AT+CSOCL=0 | Close socket | OK |
AT+CSOSENDFLAG | Enable send ACK | OK |
AT+CSORCVFLAG | Enable receive ACK | OK |
AT+CSOCON? | Check communication port and types | OK |
【Multiple Scokets】
The image below shows you how to create five sockets of communication at the same time using one SIM7020. Please refer to Commands of 【TCP Client】【UDP Client】.
【DNS and Ping】
Functions of DNS and Ping are only available when the network is accessible.
Commands | Description | Return |
---|---|---|
AT+CIPPING | Ping commands. e.g. AT+CIPPING="61.135.169.121" | OK |
AT+CDNSGIP | DNS, e.g. AT+CDNSGIP="www.baidu.com" | OK |
HTTP
SIM7020 supports two types of HTTP communication, HTTP GET and HTTP POST.
For more information about AT commands of HTTP communication, please refer to SIM7020 Series_HTTP_Application_Note.
【HTTP GET】
Commands | Description | Return |
---|---|---|
AT+CHTTPCREATE="https://www.waveshare.com/" | Create HTTP Host example | OK |
AT+CHTTPCON=0 | Connect to server | OK |
AT+CHTTPSEND=0,0,"/index.html" | Send HTTP Request | OK |
AT+CHTTPDISCON=0 | Disconnect | OK |
AT+CHTTPDESTROY=0 | Release and clear HTTP example | OK |
AT+CHTTPCREATE? | Check HTTP connecting status | OK |
Note: Request time is a little long because of the NB-IoT network when testing HTTP commands, please be patient.
MQTT
For more information about MQTT, please refer to SIM7020 Series_MQTT_Application_Note
【Subscribe and send a message】
Herein show you how to use MQTT by using the MQTT test tool which is found online.
Command | Description | Return |
---|---|---|
AT+CMQNEW="198.41.30.241","1883",12000,100 | Create MQTT connection | OK |
AT+CMQCON=0,3,"myclient",600,0,0 | Send MQTT request | OK |
AT+CMQSUB=0,"mytopic",1 | Subscribe | OK |
AT+CMQPUB=0,"mytopic",1,0,0,8,"31323334" | Publish theme and message | OK |
AT+CMQUNSUB=0,"mytopic" | Unsubscirbe | OK |
AT+CMQDISCON=0 | Disconnect MQTT | OK |
Note: Request time will be a little long because of the NB-IoT network when testing HTTP commands, please be patient.
Working with Raspberry Pi
SIM7020X NB-IoT HAT is compatible with Raspberry Pi 40PIN GPIO, and can directly plug into most types of Raspberry Pi. The used pins are as below:
SIM7020X NB-IoT HAT | Raspberry Pi |
---|---|
5V | 5V |
GND | GND |
RXD | TXD (BCM:P14) |
TXD | RXD (BCM: P15) |
PWR | P7 (BCM: P4) |
Software Setting
PWR is default shorted with P4 by jumpers. You need to initialize corresponding pins for properly working.
- Download the demo code, and copy the SIM7020x folder to /home/pi/ of your Raspberry Pi.
- Open Terminal, and execute:
chmod 777 sim7020_nbiot_hat_init
- Set script auto-executing:
- Modify rc.local file:
sudo nano /etc/rc.local
- Add the line in front of exit 1 as below:
sh /home/pi/SIM7020X/sim7020_nbiot_hat_init
- Modify rc.local file:
Serial Setting
To work with Raspberry Pi, you need to enable the hardware serial and disable the serial login shell function.
- Enter raspi-configure
sudo raspi-config
- Choose Interfacing Options -> Serial -> no -> yes.
- Open /boot/config.txt file, check if the line was added:
enable_uart=1
- Reboot.
Testing with minicom
Connect SIM7020 to Raspberry Pi, and install minicom to your Raspberry Pi:
sudo apt-get install minicom
Execute minicom -D /dev/ttyS0 to enter the minicom (ttyS0: Pi 3B/3B+, ttyAMA0: Zero/2B)
Demo codes
Download demo codes. Rename the bcm2835 folder to SIM7020X and copy it to /home/pi of Raspberry Pi.
【Install BCM2835 libraries】
Enter the SIM7020X/bcm2835 directory, and install the libraries with the commands:
wget https://files.waveshare.com/wiki/SIM7020X/SIM7020E%20NB-IoT%20HAT/demo/SIM7020X-NB-IoT-HAT-Demo-Code.zip sudo apt-get install unzip unzip SIM7020X-NB-IoT-HAT-Demo-Code.zip cd SIM7020X-NB-IoT-HAT-Demo-Code/Raspberry/bcm2835 sudo chmod +x configure && ./configure && sudo make check && sudo make install
【Compile and run】
The files tree:
cd /SIM7020X-NB-IoT-HAT-Demo-Code/SIM7020X-NB-IoT-HAT-Demo-Code/Raspberryexamples/AT sudo make clean && sudo make && sudo ./main
Expected result:
Arduino Demos
Hardware connection
Connect SIM7020C NB-IoT HAT to the development board UNO PLUS / Arduino UNO and CP2102 USB UART Board. Among them, PIN10 (RX) and PIN11 (TX) of UNO are software analog serial ports, and the hardware connection and test results are as shown in the figure below:
Install Arduino library
Download and decompress the sample program.
Copy the Waveshare_SIM7020X_Arduino_Library folder to the Library directory under the Arduino IDE installation path.
Open Arduino IDE --> File --> Examples --> Waveshare_SIM7020X_Arduino_Library, and choose to run the corresponding sample program:
Arduino Example Demo
Working with STM32
SIM7020X NB-IoT HAT is compatible with STM32 MCU. The used pins are as below: (Waveshare Open103V STM32F103V):
SIM7020X NB-IoT HAT | STM32F103V |
---|---|
5V | 5V |
GND | GND |
RXD | PA2 (corresponding to USART2 TX pin) |
TXD | PA3 (corresponding to USART2 RX pin) |
Note: The test TCP demos also require an additional serial communication module to be plugged into the USART1 interface of the development board to get the printout of the prompts after the demo is run.
Coming soon...
Resources
Scematic
Demo Code
Tools
SIM7020 Datasheets
- SIM7020E_SPEC_EN_190424
- SIM7020 Series_AT Command Manual_V1.03
- SIM7020G Hardware Design_V1.00
- SIM7020 Series MQTT Application Note
- SIM7020 Series_MQTT(S)_Application Note_V1.03
- SIM7020 Series_MQTT(S)_Application Note_V1.05
- SIM7020 Series_CoAP_Application Note_V1.02
- SIM7020 Series_FOTA_Application_Note_V1.01
- SIM7020 Series HTTP(S) Application Note V1.04
- SIM7020 Series_TCPIP_Application_Note_V1.02
- SIM7020 Series_Low Power Mode_Application Note_V1.03
- SIM7020 Series_TLS_Application Note_V1.01
- SIM7020 Series_NVRAM_Application Note_V1.01.pdf
- SIM7020 Series_SNTP_Application Note_V1.01.pdf
- More...
Others
FAQ
- Check out whether the SIM card is inserted.
- Confirm if the frequency band of the SIM card's network operator is supported by SIM7020X.
- Confirm if the local area is covered by the operator's NB-IoT network.
{{{5}}}
No, the USB connector on the SIM7020X is only for the power supply, for example, can be used when connecting to an external DC 5V power supply.
{{{5}}}
- Press and hold the PWRKEY button for 3-5s to enter sleep mode.
- Send the following AT command to enter sleep mode. After entering sleep mode, pull the DTR pin high for 3-5 seconds to power on.
AT+CPOWD=1
{{{5}}}
Send the following AT command to enter sleep low-power mode and exit:
AT+CPSMSTATUS=1 AT+CPSMSTATUS=0
{{{5}}}
Support
Technical Support
If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 PM GMT+8 (Monday to Friday)