Usage Example for Two Modules-Data Transmission

Last revision 2026/01/12

This tutorial details the setup and configuration of two Bluetooth modules for data transmission using Arduino. It covers the hardware and software preparation, module configuration, and provides sample code for transmitting and receiving data, ensuring seamless wireless communication.

Hardware Preparation

Software Preparation

Bluetooth Module Configuration

  1. Set one module as master and the other as slave via AT commands.
  2. Set both modules' baud rate to 115200.
  3. Connection Mode: if the module cannnot be searched/connected by/with adapter or PC, this parameter needs to be configured:AT+CMODE=1.

Other parameters can directly adopt the default setting. Master-slave pairing does not need a driver, and the two modules can transmit data when powered on. When the indicator lights LINK on the two Bluetooth modules keep ON, the pairing is successful. At this time, the serial port function has been started. When the master and slave pair are used normally, the lights will not go out. If the distance between the master and the slave is too far and the connection is lost, the lights will keep flashing. Put the two modules closer then they will find each other and connect automatically. The master will remember the slave it has configured, and it will find the slave address it has remembered as soon as it is powered on.

Hardware Connection

  1. Mount each Bluetooth module on an IO shield → plug into UNO boards.
  2. Connect both UNOs to the PC via USB cables.

Connection Diagram 1

Notes:

  • For new I/O shields: dial to "prog" before code downloading → dial back to "run" after.
  • For old I/O shields: unplug the module before downloading → replug after.
  • When downloading codes, you don't need to consider the order of master-slave above. Any module can be transmitting end or receiving end.

Sample Code

Transmitting End Code

void setup() {
  Serial.begin(115200);    //init serial and set baud rate to 115200
}

void loop() {
  Serial.print("Hello!");
  Serial.println("DFRobot");
  delay(1000);
}

Receiving End Code

void setup() {
  Serial.begin(115200);   //Init serial port and set baud rate to 115200
}

void loop() {
  char val;
  val = Serial.read();     //Read serial port 
  if (val != -1) {
    Serial.print(val);  //Send out the received data again via serial port 
  }
}

Result

Open two serial monitors (baud rate 115200) to view data transmission.

Transmitting End:

Transmitting

Receiving End:

Receiving

Was this article helpful?

TOP