DFRobot SIM7070G_Arduino_NB-IoT_LTE_GPRS_Expansion_Shield_SKU_DFR0572

Introduction

This NB-IoT expansion board, designed specifically for Arduino controllers, is globally frequency-compatible, supporting CAT-M, NB-IoT, GSM, GPRS, EDGE communication methods, and GNSS satellite positioning functions.

Its ultra-low power consumption and precise positioning characteristics, coupled with support for CAT-M and GNSS satellite positioning, make it an ideal choice for smart logistics, asset tracking, smart cities, and other fields.

This expansion board is not only suitable for prototype development but also for small batch production, making it an optimal choice for low-power, low-latency, and medium-throughput applications. It has built-in GNSS satellite positioning, including GPS, GLONASS, Galileo, and BD, making it highly suited for IoT applications such as remote control and mobile tracking.

The SIM7070G also comes with a rich set of built-in AT commands and provides detailed libraries, user manuals, and application documents, including usage methods for network communication protocols such as HTTP, MQTT, FTP, CoAP, NIDD, PING, etc., enabling quick start without deep understanding of underlying network protocols.

Most importantly, the SIM7070G has passed relevant certifications in multiple countries and regions worldwide, specifically:

With the above testing and certification from relevant agencies, you can confidently use the SIM7070G in your products or projects without worrying about compliance issues.

Features

Application Scenarios

Technical Specifications

Functional Diagram

Please Note:

  1. Software/Hardware Serial Switch: Since controllers such as Arduino UNO/Mega default D0 and D1 as hardware serial ports connected to the USB port, many expansion boards that require the use of serial ports may encounter serial port conflicts during use. Therefore, a software serial port interface is specially designed, allowing users to communicate with Arduino using the software serial port. For extended reading:

  2. For convenient program control, the Boot button is by default connected to the D12 pin. The module can be powered on by pulling the D12 pin high for 2 seconds. After powering on, the SIM7070G will have an initialization time of about 2 seconds. After initialization, it can be used normally.

Dimensional Diagram

Tutorial (Based on SIM7070G Library)

Requirements

Connection Diagram

Plug the SIM7070G Arduino NB-IoT/LTE/GPRS Expansion Shield to DFRduino UNO R3 directly.

warning_yellow.png **NOTE: The module SIM7070G requires a 7-12V external power supply. And please switch the hardware and software serial control switch to TX-D8, RX-D7.

Sample Code (Serial AT Command)

#include <DFRobot_SIM7070G.h>

#define PIN_TX     7
#define PIN_RX     8
SoftwareSerial     mySerial(PIN_RX, PIN_TX);
DFRobot_SIM7070G    sim7070g(&mySerial);

void setup()
{
  delay(1500);  
  Serial.begin(19200);
  mySerial.begin(19200);

  Serial.println("Turn ON SIM7070G......");
  if (sim7070g.turnON()) {      
    Serial.println("Turn ON !");
  }

  Serial.println("Set baud rate......");
  while (1) {
    if (sim7070g.setBaudRate(19200)) {              
      Serial.println("Set baud rate:19200");
      break;
    } else {
      Serial.println("Faile to set baud rate");
      delay(1000);
    }
  }

  Serial.println("For example, if you type AT\\r\\n, OK\\r\\n will be responsed!");
  Serial.println("Enter your AT command :");
}

void loop()
{
  mySerial.listen();
  while (mySerial.available()) {
    Serial.write(mySerial.read());
  }
  mySerial.flush();
  while (Serial.available()) {
    mySerial.write(Serial.read());
  }
}

Results

Control the SIM7070G expansion board by sending AT commands in the serial monitor and observe the response of the expansion board.

Sample Code (GNSS Positioning)

#include <DFRobot_SIM7070G.h>

#define PIN_TX     7
#define PIN_RX     8
SoftwareSerial     mySerial(PIN_RX, PIN_TX);
DFRobot_SIM7070G    sim7070g(&mySerial);

void setup()
{
  delay(1500);   
  Serial.begin(115200);
  mySerial.begin(19200);

  Serial.println("Turn ON SIM7070G......");
  if (sim7070g.turnON()) {                                          
    Serial.println("Turn ON !");
  }

  Serial.println("Set baud rate......");
  while (1) {
    if (sim7070g.setBaudRate(19200)) {                            
      Serial.println("Set baud rate:19200");
      break;
    } else {
      Serial.println("Faile to set baud rate");
      delay(1000);
    }
  }

  Serial.println("Check SIM card......");
  if (sim7070g.checkSIMStatus()) {                                  
    Serial.println("SIM card READY");
  } else {
    Serial.println("SIM card ERROR, Check if you have insert SIM card and restart SIM7070G");
    while (1);
  }

  Serial.println("Init positioning function......");
  while (1) {
    if (sim7070g.initPos()) {
      Serial.println("Positioning function initialized");
      break;
    } else {
      Serial.println("Fail to init positioning function");
      delay(1000);
    }
  }
}

void loop()
{
  Serial.println("Enter anything end with CRLF to get positioning ");
  char loge[10];
  readSerial(loge);
  Serial.println("Getting position......");
  if (sim7070g.getPosition()) {                                     
    Serial.print(" Longitude : ");
    Serial.println(sim7070g.getLongitude());                    
    Serial.print(" Latitude : ");
    Serial.println(sim7070g.getLatitude());                    
  } else {
    Serial.println("Wrong data try again");
  }
}

int readSerial(char result[])
{
  int i = 0;
  while (1) {
    while (Serial.available() > 0) {
      char inChar = Serial.read();
      if (inChar == '\n') {
        result[i] = '\0';
        Serial.flush();
        return 0;
      }
      if (inChar != '\r') {
        result[i] = inChar;
        i++;
      }
    }
  }
}

Results

The serial monitor will print some successful initialization information, followed by latitude and longitude information.

Sample Code (MQTT Connection)

#include <DFRobot_SIM7070G.h>

#define serverIP        "iot.dfrobot.com"
#define IOT_USERNAME    "USERNAME"
#define IOT_KEY         "PASSWORD"
#define IOT_TOPIC       "TOPIC"
#define IOT_CLIENT      "dfrobot"

#define PIN_TX          7
#define PIN_RX          8

SoftwareSerial          mySerial(PIN_RX, PIN_TX);
DFRobot_SIM7070G         sim7070g(&mySerial);

void setup()
{
  delay(1500);   
  int signalStrength;
  Serial.begin(115200);
  mySerial.begin(19200);

  Serial.println("Turn ON SIM7070G......");
  if (sim7070g.turnON()) {                                        
    Serial.println("Turn ON !");
  }

  Serial.println("Set baud rate......");
  while (1) {
    if (sim7070g.setBaudRate(19200)) {                          
      Serial.println("Set baud rate:19200");
      break;
    } else {
      Serial.println("Faile to set baud rate");
      delay(1000);
    }
  }

  Serial.println("Check SIM card......");
  if (sim7070g.checkSIMStatus()) {                                
    Serial.println("SIM card READY");
  } else {
    Serial.println("SIM card ERROR, Check if you have insert SIM card and restart SIM7070G");
    while (1);
  }


  Serial.println("Set net mode......");
  while (1) {
    if (sim7070g.setNetMode(sim7070g.eNB)) {                              
      Serial.println("Set NB mode");
      break;
    } else {
      Serial.println("Fail to set mode");
      delay(1000);
    }
  }

  Serial.println("Get signal quality......");
  delay(1500);
  signalStrength = sim7070g.checkSignalQuality();                 
  Serial.print("signalStrength =");
  Serial.println(signalStrength);
  delay(500);

  Serial.println("Attaching service......");
  while (1) {
    if (sim7070g.attacthService()) {                            
      Serial.println("Attach service");
      break;
    } else {
      Serial.println("Fail to Attach service");
      delay(1000);
    }
  }
}

void loop()
{
  String  sendData;
  Serial.print("Connect to :");
  Serial.println(serverIP);
  if (sim7070g.openNetwork(sim7070g.eTCP, serverIP, 1883)) {                  //Connect to server
    Serial.println("Connected !");
  } else {
    Serial.println("Failed to connect");
    return;
  }
  delay(200);

  Serial.print("Connect to : ");
  Serial.println(IOT_USERNAME);
  if (sim7070g.mqttConnect(IOT_CLIENT, IOT_USERNAME, IOT_KEY)) {    
    Serial.println("Connected !");
  } else {
    Serial.println("Failed to connect");
    return;
  }
  delay(200);

  Serial.println("Input data end with CRLF : ");
  sendData = readSerial(sendData);
  Serial.print("Send data : ");
  Serial.print(sendData);
  Serial.println(" ......");
  if (sim7070g.mqttPublish(IOT_TOPIC, sendData)) {                 
    Serial.println("Send OK");
  } else {
    Serial.println("Failed to send");
    return;
  }
  delay(200);

  Serial.println("Close connection......");
  if (sim7070g.closeNetwork()) {                                  
    Serial.println("Close connection !");
  } else {
    Serial.println("Fail to close connection !");
    return;
  }
  delay(2000);
}

String readSerial(String result)
{
  int i = 0;
  while (1) {
    while (Serial.available() > 0) {
      char inChar = Serial.read();
      if (inChar == '\n') {
        result += '\0';
        while (Serial.read() >= 0);
        return result;
      }
      if (i == 50) {
        Serial.println("The data is too long");
        result += '\0';
        while (Serial.read() >= 0);
        return result;
      }
      if (inChar != '\r') {
        result += inChar;
        i++;
      }
    }
  }
}

Results

The serial monitor will print some information, read the data you input, and send the data to the specified topic.

API Functions

  /**
   * @fn DFRobot_SIM7070G
   * @brief DFRobot_SIMcore constructor of abstract class. Construct serial ports
   * @param s The pointer to abstract class, where you can fill in the pointer to serial object.
   * @return None
   */
  DFRobot_SIM7070G(Stream *s);
  ~DFRobot_SIM7070G(){};

  /**
   * @fn recv
   * @brief Receive
   * @param buf Receive data content
   * @param maxlen Receive data length
   * @return Get data length
   */
  int recv(char* buf, int maxlen);

  /**
   * @fn checkSignalQuality
   * @brief Check signal quality
   * @return 0-30:Signal quality
   */
  int checkSignalQuality(void);

  /**
   * @fn batteryPower
   * @brief Battery power
   * @return Battery power
   */
  int batteryPower(void);

  /**
   * @fn setNetMode
   * @brief Set net mode
   * @param net The net mode
   * @n    GPRS: GPRS mode
   * @n    NB:   NB-IOT mode
   * @return bool type, indicating the status of setting
   * @retval ture Success 
   * @retval false Failed
   */
  bool setNetMode(eNet net);

  /**
   * @fn attacthService
   * @brief Open the connection
   * @return bool type, indicating the status of opening the connection
   * @retval true Success 
   * @retval false Failed
   */
  bool attacthService(void);

  /**
   * @fn setBaudRate
   * @brief Set baud rate to avoid garbled
   * @param rate Baud rate value
   * @n    Possible values:1200 2400 4800 9600 19200 38400
   * @note SIM7070G default baud rate is 115200, reduce the baud rate to avoid distortion
   * @return bool type, indicating the status of setting
   * @retval true Success 
   * @retval false Failed
   */
  bool setBaudRate(long rate);

  /**
   * @fn checkSIMStatus
   * @brief Check SIM card
   * @return bool type, indicating the status of checking SIM card
   * @retval true Success 
   * @retval false Failed
   */
  bool checkSIMStatus(void);

  /**
   * @fn openNetwork
   * @brief Start up connection
   * @param ptl  Choose connection protocol
   * @n    TCP  Choose TCP
   * @n    UDP  Choose UDP
   * @param host Host domain name
   * @param port  Contented port
   * @return bool type, indicating the status of opening Network
   * @retval true Success 
   * @retval false Failed
   */
  bool openNetwork(eProtocol ptl, const char *host, uint16_t port);

  /**
   * @fn closeNetwork
   * @brief End the connection
   * @return bool type, indicating the status of closing Network
   * @retval true Success 
   * @retval false Failed
   */
  bool closeNetwork(void);

  /**
   * @fn turnON
   * @brief Turn ON SIM7070G
   * @return bool type, indicating the status of turning on
   * @retval true Success 
   * @retval false Failed
   */
  bool turnON(void);

  /**
   * @fn initPos
   * @brief Init SIM7070G positioning module
   * @return bool type, indicating the initialization status
   * @retval true Success 
   * @retval false Failed
   */
  bool initPos(void);

  /**
   * @fn mqttConnect
   * @brief MQTT connect request
   * @param iot_client Client name user-defined
   * @param iot_username The user name identifies the name of the user who is connecting
   * @param iot_key The password for user
   * @return bool type, indicating the connection status
   * @retval true Success 
   * @retval false Failed
   */
  bool mqttConnect(const char* iot_client, const char* iot_username, const char* iot_key);

  /**
   * @fn mqttPublish
   * @brief MQTT send command
   * @param iot_topic Target topic
   * @param iot_data  The data you want to send
   * @return bool type, indicating status of sending
   * @retval true Success 
   * @retval false Failed
   */
  bool mqttPublish(const char* iot_topic, String iot_data);

  /**
   * @fn mqttSubscribe
   * @brief Subscribe MQTT channel
   * @param iot_topic The subscribed MQTT key 
   * @return bool type, indicating subscription status
   * @retval true Success 
   * @retval false Failed
   */
  bool mqttSubscribe(const char* iot_topic);

  /**
   * @fn mqttUnsubscribe
   * @brief Unsubscribe MQTT channel
   * @param iot_topic The unsubscribed MQTT key
   * @return bool type, indicating unsubscribe status
   * @retval true Success 
   * @retval false Failed
   */
  bool mqttUnsubscribe(const char* iot_topic);

  /**
   * @fn mqttRecv
   * @brief MQTT send data
   * @param iot_topic Subscribe channel key
   * @param buf Send data
   * @param maxlen Send data length
   * @return bool type, indicating subscription status
   * @retval true Success 
   * @retval false Failed
   */
  bool mqttRecv(char* iot_topic, char* buf,int maxlen);

  /**
   * @fn mqttDisconnect
   * @brief MQTT disconnection
   * @return bool type, indicating disconnection status
   * @retval true Success 
   * @retval false Failed
   */
  bool mqttDisconnect(void);

  /**
   * @fn httpInit
   * @brief Initialize HTTP service
   * @param net The net mode
   * @n    eGPRS: GPRS mode
   * @n    eNB:   NB-IOT mode
   * @return bool type, indicating initialization status
   * @retval true Success 
   * @retval false Failed
   */
  bool httpInit(eNet net);

  /**
   * @fn httpConnect
   * @brief Connect to server
   * @param host Server IP
   * @return bool type, indicating connection status
   * @retval true Success 
   * @retval false Failed
   */
  bool httpConnect(const char *host);

  /**
   * @fn httpPost
   * @brief HTTP POST
   * @param host URL
   * @param data POST data
   * @return bool type, indicating request status
   * @retval true Success 
   * @retval false Failed
   */
  bool httpPost(const char *host , String data);

  /**
   * @fn httpGet
   * @brief HTTP GET This function print the get data
   * @param host URL
   */
  void httpGet(const char *host);

  /**
   * @fn httpDisconnect
   * @brief Disconnect from server and cancel initialization
   */
  void httpDisconnect(void);

  /**
   * @fn send
   * @brief Send data with specify the length
   * @param buf The buffer for data to be sent
   * @param len The length of data to be sent
   * @return bool type, indicating status of sending
   * @retval true Success 
   * @retval false Failed
   */
  bool send(char *buf,size_t len);

  /**
   * @fn send
   * @brief Send data
   * @param data The data to send
   * @return bool type, indicating status of sending
   * @retval true Success 
   * @retval false Failed
   */
  bool send(char *data);

  /**
   * @fn getPosition
   * @brief Get the current position
   * @return bool type, indicating the status of getting position
   * @retval true Success 
   * @retval false Failed
   */
  bool getPosition(void);

  /**
   * @fn getLatitude
   * @brief Get latitude
   * @return Latitude value
   */
  const char* getLatitude(void);

  /**
   * @fn getLongitude
   * @brief Get longitude
   * @return Longitude value
   */
  const char* getLongitude(void);

More Document Downloads

FAQ

Q: After burning the sample code, the serial port output cannot be initialized?

A: (1) Check whether the external power supply is 7~12V, powered through the DC2.1 black round hole on the main board, or through the vin, gnd port on the expansion board. (2) Check whether two antennas are installed. (3) Check the TX>D8, RX>D7 dip switch on the expansion board. (4) See if the red power indicator light on the expansion board is always on, and the NET indicator light is blinking. (5) Check whether the NB card is inserted. After checking, press the Boot button to restart and observe.

Q: Can SIM7070G use communication and GNSS positioning at the same time?

A: SIM7070G cannot use communication and GNSS positioning functions at the same time.

For more questions and interesting applications, you can visit the forum for reference or to post.