Usage Example for Arduino-Modify Baud Rate

Last revision 2025/12/30

This article provides a comprehensive guide on modifying the baud rate for Arduino projects using a 4G module. It includes hardware preparation, software setup, connection diagrams, and step-by-step instructions to adjust the baud rate and ensure successful communication with AT commands.

Hardware Preparation

Software Preparation

Connection Diagram and Steps

Connection Diagram

Mainboard Pin name Module Pin name
DFRduino UNO R3 5 A7670G 4G Module RX
DFRduino UNO R3 4 A7670G 4G Module TX
DFRduino UNO R3 5V A7670G 4G Module +
DFRduino UNO R3 GNG A7670G 4G Module -

Steps

  1. Insert the SIM card into the expansion board and connect it to the DFRduino UNO R3 mainboard as shown in the diagram. Connect an external power supply as well.
  2. Wait for the SIM card to register on the network. The NET status indicator LED should start flashing rapidly (once every 1 second).
  3. Download the program below to the DFRduino UNO R3 and open the serial monitor, setting the baud rate to 115200.
#include "SoftwareSerial.h"
   SoftwareSerial softSerial(/*rx =*/4, /*tx =*/5);

void setup() {
  
  Serial.begin(115200); // Initialize the hardware UART
  softSerial.begin(115200); // Initialize the software UART
  Serial.println("For example, if you type AT\\r\\n, OK\\r\\n will be responsed!");
  Serial.println("Enter your AT command :");
}

void loop() {
  if (softSerial.available()) {
    char data = softSerial.read(); // Read data from the software UART
    Serial.write(data); // Transmit to the hardware UART
  }

  if (Serial.available()) {
    char data = Serial.read(); // Read data from the hardware UART
    softSerial.write(data); // Transmit to the software UART
  }
}

Serial port monitor

Transmitting AT commands, receiving "OK" as the serial response, signifies successful communication.

AT command

Please note that when using an Arduino UNO for serial communication, the module's default communication rate is 115200. The oscillation frequency of the external crystal can result in significant baud rate errors, causing data corruption. It is necessary to set both the module's baud rate and the program's baud rate to 9600.

To achieve this, send the command "AT+IPREX=9600" to set the module's baud rate to 9600 after a restart.

set baud rate

Subsequently, modify the UNO's serial communication rate and re-upload the program.

#include "SoftwareSerial.h"
   SoftwareSerial softSerial(/*rx =*/4, /*tx =*/5);

void setup() {
  
  Serial.begin(9600); // Initialize the hardware UART
  softSerial.begin(9600); // Initialize the software UART
  Serial.println("For example, if you type AT\\r\\n, OK\\r\\n will be responsed!");
  Serial.println("Enter your AT command :");
}

void loop() {
  if (softSerial.available()) {
    char data = softSerial.read(); // Read data from the software UART
    Serial.write(data); // Transmit to the hardware UART
  }

  if (Serial.available()) {
    char data = Serial.read(); // Read data from the hardware UART
    softSerial.write(data); // Transmit to the software UART
  }
}

Using a baud rate of 9600, send "AT" and "AT+IPREX?" to the serial port, which should return "OK" and the current baud rate value of 9600, confirming the successful modification of the communication rate.

success

Was this article helpful?

TOP