Difference between revisions of "Template:SIM7020E BV IOT User Manual"

From Waveshare Wiki
Jump to: navigation, search
 
(22 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
===Overview===
 
===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.
  
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===
 
===Features===
----
+
*Raspberry Pi connectivity, compatible with any revision.
 
 
*Raspberry Pi connectivity, compatible with any revision
 
 
*Supports communication protocols such as LWM2M/COAP/MQTT/TCP/UDP/HTTP/HTTPS, etc.
 
*Supports communication protocols such as LWM2M/COAP/MQTT/TCP/UDP/HTTP/HTTPS, etc.
*Onboard USB interface, for power supply or debugging
+
*Onboard USB interface, for the power supply or debugging.
*Breakout UART control pins, to connect with host boards like Arduino/STM32
+
*Breakout UART control pins, to connect with host boards like Arduino/STM32.
*Onboard voltage translator, 3.3V by default, allows to be switched to 5V via onboard jumper
+
*Onboard voltage translator, 3.3V by default, allows being switched to 5V via onboard jumper.
*SIM card slot, supports NB-IoT specific card
+
*SIM card slot, supports NB-IoT specific card.
*2x LED indicators, easy to monitor the working status
+
*2 x LED indicators, easy to monitor the working status.
*Baudrate: 300bps~921600bps (115200bps by default)
+
*Baudrate: 300bps~921600bps (115200bps by default).
*Control via AT commands (V.25TER, 3GPP TS 27.007, and SIMCOM AT Commands)
+
*Control via AT commands (V.25TER, 3GPP TS 27.007, and SIMCOM AT Commands).
*Comes with development resources and manual (examples for Raspberry Pi/Arduino/STM32/Python)
+
*Comes with online development resources and manuals (examples for Raspberry Pi/Arduino/STM32/Python).
  
 
===Specification===
 
===Specification===
----
 
 
 
'''Communication'''
 
'''Communication'''
 
 
*Band
 
*Band
 
**FDD-LTE B1/B3/B5/B8/B20/B28  
 
**FDD-LTE B1/B3/B5/B8/B20/B28  
Line 29: Line 23:
 
*SMS
 
*SMS
 
**Text mode and PDU mode (depends on the NB card)
 
**Text mode and PDU mode (depends on the NB card)
 
 
'''General'''
 
'''General'''
 
*Power supply: 5V
 
*Power supply: 5V
Line 40: Line 33:
 
**eDRX mode: 70uA (eDRX=655.36s)
 
**eDRX mode: 70uA (eDRX=655.36s)
 
*Dimension: 30.5mm x 65.0mm
 
*Dimension: 30.5mm x 65.0mm
 +
 
===Interfaces===
 
===Interfaces===
----
 
 
{| class="wikitable"
 
{| class="wikitable"
 
!PIN!!Description
 
!PIN!!Description
Line 67: Line 60:
  
 
===Jumpers===
 
===Jumpers===
----
 
 
{|class="wikitable"
 
{|class="wikitable"
 
!Jumpers!!Descriptions
 
!Jumpers!!Descriptions
Line 76: Line 68:
 
|}
 
|}
 
[[File:Raspberry-Pi-P4.jpg|300px|thumb|Raspberry Pi 40PIN GPIO]]
 
[[File:Raspberry-Pi-P4.jpg|300px|thumb|Raspberry Pi 40PIN GPIO]]
 +
 
===Indicators===
 
===Indicators===
----
 
 
{|class="wikitable"
 
{|class="wikitable"
 
!LEDs!!Descriptions
 
!LEDs!!Descriptions
Line 85: Line 77:
 
|NET|| On(64ms)&OFF(800ms): Internet isn't registered<br /> On(64ms)&OFF(3000ms): Internet is registered<br />On(64ms)&OFF(300ms): Data are transmitting<br />OFF: Power off or PSM Sleep Mode
 
|NET|| On(64ms)&OFF(800ms): Internet isn't registered<br /> On(64ms)&OFF(3000ms): Internet is registered<br />On(64ms)&OFF(300ms): Data are transmitting<br />OFF: Power off or PSM Sleep Mode
 
|}
 
|}
 +
 
===Working with Windows PC===
 
===Working with Windows PC===
----
 
 
'''Hardware connection'''
 
'''Hardware connection'''
 
[[File:SIM7020X-NB-IoT-HAT-04.jpg|300px|thumb|Hardware connection]]
 
[[File:SIM7020X-NB-IoT-HAT-04.jpg|300px|thumb|Hardware connection]]
 
The external components required:
 
The external components required:
*A special sim card which supported NB-IoT
+
*A special sim card that supported NB-IoT.
*A USB to TTL module (Recommend [https://www.waveshare.com/cp2102-usb-uart-board-micro.htm CP2102 USB to UART Module])
+
*A USB to TTL module (Recommend [https://www.waveshare.com/cp2102-usb-uart-board-micro.htm CP2102 USB to UART Module]).
  
 
Connection:
 
Connection:
#Insert sim card to the backside card slot, connect LTE antenna <font color="red">(The '''LTE antenna''' must be rotated to the outside of the board)</font>
+
#Insert sim card to the backside card slot, connect LTE antenna <font color="red">(The '''LTE antenna''' must be rotated to the outside of the board).</font>
#Connect CP2102 module to UART1 (or UART2) of SIM7020E NB-IoT HAT(SIM7020 hereafter), and connect to your PC by USB cable
+
#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)
+
#Power on SIM7020. (PWR: On; NET: OFF)
#Press PWRKEY buttons for about 1s (NET: Blinking)
+
#Press PWRKEY buttons for about 1s (NET: Blinking).
#Download the serial assistance software and open it. Set it 115200 8N1, and check the newline options
+
#Download the serial assistance software and open it. Set it to 115200 8N1, and check the newline options.
#Click Extend to get the pre-configure commands. Testing
+
#Click Extend to get the pre-configured commands. Testing
 
[[File:SIM7020X-NB-IoT-HAT-tt.jpg|600px]]
 
[[File:SIM7020X-NB-IoT-HAT-tt.jpg|600px]]
  
 
'''Quick testing'''
 
'''Quick testing'''
  
Herein we list some common commands which can be used to quick test the SIM7020.
+
Herein we list some common commands which can be used to quickly test the SIM7020.
  
 
{|class="wikitable"
 
{|class="wikitable"
Line 112: Line 104:
 
|AT|| Check module status||OK
 
|AT|| Check module status||OK
 
|-
 
|-
|ATE|| ATE1:Echo Mode On; ATE0: Echo Mode Off||OK
+
|ATE|| ATE1: Echo Mode On; ATE0: Echo Mode Off||OK
 
|-
 
|-
 
|AT+CSQ||Check Internet Signals Quality||OK
 
|AT+CSQ||Check Internet Signals Quality||OK
Line 138: Line 130:
 
SIM7020 cannot support transparent and server mode.
 
SIM7020 cannot support transparent and server mode.
  
TCP/IP of SIM7020 is multiple client structure, supports up to 5 sockets (like TCP or UDP)
+
TCP/IP of SIM7020 is a multiple client structure, which supports up to 5 sockets (like TCP or UDP).
  
 
[[File:SIM7020X-NB-IoT-HAT-08.png|600px]]
 
[[File:SIM7020X-NB-IoT-HAT-08.png|600px]]
  
Connect modules and test network connection by following instruction above before TCP/IP communicating.
+
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
 
For more information about TCP, UDP, DNS, etc. Please refer to SIM7020 Series_TCPIP_Application_Note
Line 186: Line 178:
 
【Multiple Scokets】
 
【Multiple Scokets】
  
The image below shows you how to create five sockets communication at the same time using one SIM7020. Please refer to Commands of 【TCP Client】【UDP Client】
+
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】
  
 
[[File:SIM7020X-NB-IoT-HAT-11.png|900px]]
 
[[File:SIM7020X-NB-IoT-HAT-11.png|900px]]
Line 192: Line 184:
 
【DNS and Ping】
 
【DNS and Ping】
  
Functions of DNS and Ping are only available when network is acceasble
+
Functions of DNS and Ping are only available when the network is accessible.
  
 
{|class="wikitable"
 
{|class="wikitable"
Line 207: Line 199:
  
 
'''HTTP'''
 
'''HTTP'''
----
+
SIM7020 supports two types of HTTP communication, HTTP GET and HTTP POST
 
 
SIM7020 supports two types of HTTP communicating, HTTP GET and HTTP POST
 
  
 
For more information about AT commands of HTTP communication, please refer to SIM7020 Series_HTTP_Application_Note
 
For more information about AT commands of HTTP communication, please refer to SIM7020 Series_HTTP_Application_Note
Line 230: Line 220:
 
|AT+CHTTPCREATE?||Check HTTP connecting status||OK
 
|AT+CHTTPCREATE?||Check HTTP connecting status||OK
 
|}
 
|}
Note: Request time is a little long because of NB-IoT network when testing HTTP commands, please be patient.
+
Note: Request time is a little long because of the NB-IoT network when testing HTTP commands, please be patient.
  
 
[[File:SIM7020X-NB-IoT-HAT-14.png|600px]][[File:SIM7020X-NB-IoT-HAT-15.png|600px]]
 
[[File:SIM7020X-NB-IoT-HAT-14.png|600px]][[File:SIM7020X-NB-IoT-HAT-15.png|600px]]
  
 
'''MQTT'''
 
'''MQTT'''
----
 
 
 
For more information about MQTT, please refer to SIM7020 Series_MQTT_Application_Note
 
For more information about MQTT, please refer to SIM7020 Series_MQTT_Application_Note
  
【Subscribe and send message】
+
【Subscribe and send a message】
  
Herein show you how use MQTT by using MQTT test tool which is found online
+
Herein show you how to use MQTT by using the MQTT test tool which is found online.
  
 
{|class="wikitable"
 
{|class="wikitable"
Line 258: Line 246:
 
|AT+CMQDISCON=0||Disconnect MQTT||OK
 
|AT+CMQDISCON=0||Disconnect MQTT||OK
 
|}
 
|}
Note: Request time is a little long because of NB-IoT network when testing HTTP commands, please be patient.
+
Note: Request time is a little long because of the NB-IoT network when testing HTTP commands, please be patient.
  
 
[[File:SIM7020X-NB-IoT-HAT-17.png|700px]][[File:SIM7020X-NB-IoT-HAT-18.png|700px]]
 
[[File:SIM7020X-NB-IoT-HAT-17.png|700px]][[File:SIM7020X-NB-IoT-HAT-18.png|700px]]
  
 
===Working with Raspberry Pi===
 
===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 is compatible with Raspberry Pi 40PIN GPIO, can directly plug to most types of Raspberry Pi. The used pins are as below:
 
  
 
[[File:SIM7020X-Connect.jpg|300px|thumb]]
 
[[File:SIM7020X-Connect.jpg|300px|thumb]]
Line 276: Line 263:
 
|RXD||TXD (BCM:P14)
 
|RXD||TXD (BCM:P14)
 
|-
 
|-
|TXD||RXD(BCM: P15)
+
|TXD||RXD (BCM: P15)
 
|-
 
|-
 
|PWR||P7 (BCM: P4)
 
|PWR||P7 (BCM: P4)
 
|}
 
|}
  
'''Software Setting'''
+
'''Software Setting'''<br/>
----
 
 
 
 
PWR is default shorted with P4 by jumpers. You need to initialize corresponding pins for properly working.
 
PWR is default shorted with P4 by jumpers. You need to initialize corresponding pins for properly working.
 
[[File:SIM7020X-NB-IoT-HAT-20.png|300px|thumb]]
 
[[File:SIM7020X-NB-IoT-HAT-20.png|300px|thumb]]
*Download demo code, copy SIM7020x folder to /home/pi/ of your Raspberry Pi
+
*Download the demo code, and copy the SIM7020x folder to /home/pi/ of your Raspberry Pi.
 
*Open Terminal, and execute:<pre>chmod 777 sim7020_nbiot_hat_init</pre>
 
*Open Terminal, and execute:<pre>chmod 777 sim7020_nbiot_hat_init</pre>
 
*Set script auto-executing:
 
*Set script auto-executing:
Line 293: Line 278:
  
 
'''Serial Setting'''
 
'''Serial Setting'''
----
+
To work with Raspberry Pi, you need to enable the hardware serial and disable the serial login shell function.
 
 
To work with Raspberry Pi, you need to enable hardware serial and disable serial login shell function.
 
  
 
*Enter raspi-configure <pre>sudo raspi-config</pre>
 
*Enter raspi-configure <pre>sudo raspi-config</pre>
Line 302: Line 285:
 
*Reboot
 
*Reboot
  
'''Testing with minicom'''
+
'''Testing with minicom'''<br/>
----
 
 
[[File:SIM7020X-NB-IoT-HAT-23.png|300px|thumb|minicom debugging]]
 
[[File:SIM7020X-NB-IoT-HAT-23.png|300px|thumb|minicom debugging]]
Connect SIM7020 to Raspbery Pi, install minicom to your Raspberry Pi:
+
Connect SIM7020 to Raspberry Pi, and install minicom to your Raspberry Pi:
  
 
<pre>sudo apt-get install minicom</pre>
 
<pre>sudo apt-get install minicom</pre>
Line 312: Line 294:
  
  
'''Demo codes'''
+
'''Demo codes'''<br/>
----
+
Download demo codes. Rename the bcm2835 folder to SIM7020X and copy it to /home/pi of Raspberry Pi.
 
 
Download demo codes. Rename bcm2835 folder to SIM7020X and copy it to /home/pi of Raspberry Pi
 
  
 
【Install BCM2835 libraries】
 
【Install BCM2835 libraries】
  
Enter SIM7020X/bcm2835 directory, install the libraries with commands:
+
Enter the SIM7020X/bcm2835 directory, and install the libraries with the commands:
 
<pre>
 
<pre>
chmod +x configure && ./configure && sudo make check && sudo make install
+
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
 +
 
 
</pre>
 
</pre>
  
Line 331: Line 316:
  
 
<pre>
 
<pre>
cd /home/pi/SIM7020X/examples/AT
+
cd /SIM7020X-NB-IoT-HAT-Demo-Code/SIM7020X-NB-IoT-HAT-Demo-Code/Raspberryexamples/AT
 
sudo make clean && sudo make && sudo ./main
 
sudo make clean && sudo make && sudo ./main
 
</pre>
 
</pre>
  
Expectre result:
+
Expected result:
  
 
<gallery>
 
<gallery>
Line 344: Line 329:
  
 
</gallery>
 
</gallery>
 +
 +
==Arduino Demos==
 +
=== Hardware connection ===
 +
[https://www.waveshare.net/shop/SIM7020C-NB-IoT-HAT.htm SIM7020C NB-IoT HAT] Connect to the development board [https://www.waveshare.net/shop/UNO-PLUS.htm UNO PLUS / Arduino UNO] and [https://{{SERVERNAME}}/shop/CP2102-USB-UART-Board-micro.htm 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:<br>
 +
[[File:SIM7020_link.png|9000px]]<br>
 +
 +
=== Install Arduino library ===
 +
Download and decompress the sample program.<br />
 +
Copy the Waveshare_SIM7020X_Arduino_Library folder to the Library directory under the Arduino IDE installation path.<br />
 +
Open Arduino IDE --> File --> Examples --> Waveshare_SIM7020X_Arduino_Library, and choose to run the corresponding sample program:<br />
 +
[[File:SIM7020X_Arduino_Demo1.png|800px]]
 +
 +
=== '''Arduino Example Demo''' ===
 +
[[File:SIM7020X_print.png|800px]] <br>
  
 
===Working with STM32===
 
===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 is compatible with STM32 MCU. The used pins are as below (Waveshare Open103V STM32F103V):
  

Latest revision as of 09:14, 14 December 2023

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 Data receive of Serial port 1
TX1 Data send of Serial port 1
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 message received or URC reported) (need to be set with "AT+CFGRI=1")
RX2 Data receive of Serial port 2
TX2 Data send of Serial port 2
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
Raspberry Pi 40PIN GPIO

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

Hardware connection

The external components required:

Connection:

  1. Insert sim card to the backside card slot, connect LTE antenna (The LTE antenna must be rotated to the outside of the board).
  2. Connect CP2102 module to UART1 (or UART2) of SIM7020E NB-IoT HAT(SIM7020 hereafter), and connect to your PC by USB cable.
  3. Power on SIM7020. (PWR: On; NET: OFF)
  4. Press PWRKEY buttons for about 1s (NET: Blinking).
  5. Download the serial assistance software and open it. Set it to 115200 8N1, and check the newline options.
  6. Click Extend to get the pre-configured commands. Testing

SIM7020X-NB-IoT-HAT-tt.jpg

Quick testing

Herein we list some common commands which 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

SIM7020X-NB-IoT-HAT-07.png

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).

SIM7020X-NB-IoT-HAT-08.png

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

【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

【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】

SIM7020X-NB-IoT-HAT-11.png

【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

SIM7020X-NB-IoT-HAT-12.png

SIM7020X-NB-IoT-HAT-13.png

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.

SIM7020X-NB-IoT-HAT-14.pngSIM7020X-NB-IoT-HAT-15.png

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 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 is a little long because of the NB-IoT network when testing HTTP commands, please be patient.

SIM7020X-NB-IoT-HAT-17.pngSIM7020X-NB-IoT-HAT-18.png

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-Connect.jpg
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.

SIM7020X-NB-IoT-HAT-20.png
  • 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

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

minicom debugging

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:

SIM7020X-Demo-Code-intro.jpg

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

SIM7020C NB-IoT HAT Connect 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:
SIM7020 link.png

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:
SIM7020X Arduino Demo1.png

Arduino Example Demo

SIM7020X print.png

Working with STM32

SIM7020X NB-IoT HAT is compatible with STM32 MCU. The used pins are as below (Waveshare Open103V STM32F103V):

SIM7020-STM32-TCP-en.jpg
SIM7020X NB-IoT HAT STM32F103V
5V 5V
GND GND
RXD PA2 (对应USART2的TX)
TXD PA3 (对应USART2的RX)