Example Code for Arduino-AT Command Control

This example uses the serial port to send AT commands to control the SIM7000. With initialization completed, users can enter AT commands directly to the SIM7000. Users will learn how to interact with the SIM7000 using AT commands.

Hardware Preparation

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

Software Preparation

Wiring Diagram

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

SIM7000C

Other Preparation Work

  • SIM7000 NB-IoT Shield can be controlled by AT command through serial port and it recognizes 115200 baud rate in default. So we need to reset the baud rate to 19200 and below to avoid garbled. (The software serial port has an unreliable baudrate higher than 38400bps.)
  • AT command must end with a CR&LF.

Sample Code

/*
  * File  : DFRobot_SIM7000_ATtest.ino
  * Power : SIM7000 needs 7-12V DC power supply
  * Brief : This example use the serial port to send AT command to control the SIM7000
  * With initialization completed, we can enter AT command to SIM7000 directly
  * Note  : If you use Mega please connect PIN8 PIN10 and set PIN_RX = 10
  * The AT command must end with CR&LF
  */
#include <DFRobot_SIM7000.h>

#define PIN_TX     7
#define PIN_RX     8
SoftwareSerial     mySerial(PIN_RX,PIN_TX);
DFRobot_SIM7000    sim7000;

void setup() {
    Serial.begin(115200);
    sim7000.begin(mySerial);
    sim7000.turnOFF();
    delay(5000);

    Serial.println("Turn ON SIM7000......");
    if(sim7000.turnON()){                             //Turn ON SIM7000
        Serial.println("Turn ON !");
    }

    Serial.println("Set baud rate......");
    if(sim7000.setBaudRate(19200)){                   //Set baud rate from 115200 to 19200
        Serial.println("Set baud rate:19200");
    }else{
        Serial.println("Faile to set baud rate");
        while(1);
    }

    mySerial.begin(19200);
    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());
    }

    delay(20);
}

Result

SIM7000C

Additional Information

  • Common AT command Introduction:
    Common AT command Introduction
    command
    AT+CNMP=?
    AT+CMNB=?
    AT+CSQ
    AT+CGATT?
    AT+CSTT
    AT+CIFSR
    AT+CIPSTART="ptl","host","port"
    AT+CIPSEND="len"
    AT+CIPCLOSE
    AT+CIPSHUT

Was this article helpful?

TOP