SIM7020E NB-IoT HAT

From Diustou Wiki
Revision as of 15:49, 22 March 2021 by Admin (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
SIM7020E NB-IoT HAT
Compatible with Raspberry Pi 2B/3B/Zero/Zero W
SIM7020E.JPG
Information

Categories: Modules, NB-IoT, GPS/GSM, Raspberry Pi

Brand: Waveshare

Description
Features

---

Interfaces

RPiUART

Related products

{{{related}}}

Introduction

NB-IoT HAT for Raspberry Pi, Based on SIM7020E

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 power supply OR debugging
  • 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
  • SIM card slot, supports NB-IoT specific card
  • 2x 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 development resources and manual (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 registeredOn(64ms)&OFF(300ms): Data are transmittingOFF: 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 115200 8N1, and check the newline options
  6. Click Extend to get the pre-configure commands. Testing

SIM7020X-NB-IoT-HAT-tt.jpg Quick testing Herein we list some common commands which can be used to quick 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 multiple client structure, supports up to 5 sockets (like TCP or UDP) SIM7020X-NB-IoT-HAT-08.png Connect modules and test network connection by following instruction 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, =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, =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 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 network is acceasble

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 communicating, 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://wiki.diustou.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 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 message】 Herein show you how use MQTT by using 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 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, can directly plug to 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 demo code, copy 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 belowsh /home/pi/SIM7020X/sim7020_nbiot_hat_init

Serial Setting


To work with Raspberry Pi, you need to enable hardware serial and disable 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 Raspbery Pi, 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 bcm2835 folder to SIM7020X and copy it to /home/pi of Raspberry Pi 【Install BCM2835 libraries】 Enter SIM7020X/bcm2835 directory, install the libraries with commands: chmod +x configure && ./configure && sudo make check && sudo make install 【Compile and run】 The files tree: SIM7020X-Demo-Code-intro.jpg cd /home/pi/SIM7020X/examples/AT sudo make clean && sudo make && sudo ./main Expectre result: File:SIM7020-RPI-AT-TEST.png|AT File:SIM7020C-TCP-TEST.jpg|TCP File:SIM7020C-UDP-TEST.jpg|UDP

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)

Coming soon...

Resources

Tools

SIM7020 Datasheets

FAQ

Question:
Is possible to change the IMEI ID of SIM7020E?
Answer:

Yes,you can change IMEI ID by sending the at command: AT+SIMEI See the picture below:SIM7020E-IMEI.png


Icon-mail.png Contact us

Working hours: 09:00-18:00 (UTC+8 Monday to Saturday)