Example Code for Arduino-Serial AT Command

Last revision 2025/12/09

This example uses serial port to send AT commands to control the SIM7070G expansion board. Users can learn how to communicate with the SIM7070G using AT commands via serial.

Hardware Preparation

  • DFR0216 DFRduino UNO R3 - Arduino Compatible x1
  • SIM7070G Arduino NB-IoT/LTE/GPRS Expansion Shield x1
  • USB Wire x1
  • 7V~12V DC Power Supply x1

Software Preparation

Wiring Diagram

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

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.

Wiring Diagram

Other Preparation Work

  • Since Arduino UNO only has one hardware serial port, it is recommended to use software serial communication when using it. The SIM7000 library file uses software serial by default. Please switch the software/hardware serial control switch to TX>D8, RX>D7.

Sample Code

#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());
  }
}

Result

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

Was this article helpful?

TOP