Two way Bluetooth Data Communication Using Arduino UNO

Introduction

This project demonstrates the two way communication between two Bluetooth HC-05 modules. Here One Bluetooth module configures as master and the other is the slave. In this project we will learn how to configure HC-05 module as MASTER and SLAVE modes using ATCOMMANDS and then we will write the code for the individuals using Arduino IDE and Arduino UNO to test the whole project setup.

The main aim of this project is to demonstrate the two way communication. So, that we can use this process in any of our experiment, projects etc.

This project is built using Arduino UNO, SG90 servo, DHT11 sensor, LCD, LDR sensor, HC-05, and switch on the master side, whereas on the slave side Arduino UNO, LCD, 10K ohm variable pot, and HC-05 module is used.

Working of Project

The project works in the following manner

  • After turning ON both the system, Bluetooth modules automatically get connected, because the Master is configured to connect with a predefined Bluetooth module with the address.
  • After successful connection data from the master starts displaying on the slave LCD.
  • The user needs to turn the variable resistor and the servo movement and be seen on the master side.
  • Same at the master side a switch is there to turn ON the LED on the slave side.

Hardware Requirements

Disclaimer: It may contains Amazon affiliate links. which means I can get a small commission on the sale. This might be your indirect help to me. Thank You 🙏

The components requirement list is divided into two different parts. Part one is for master device components and part two is for slave side components.

Master Components

  • Arduino UNO (HERE)
  • I2C LCD Module (HERE)
  • 16×2 LCD Module (HERE)
  • HC-05 Bluetooth module (HERE)
  • Micro servo (HERE)
  • DHT11 sensor (HERE)
  • LDR sensor (HERE)
  • LDR sensor module (HERE)
  • Microswitch (HERE)
  • Variety of connectors (HERE)
  • Small Bread Board (HERE)

Slave Components

  • Arduino UNO (HERE)
  • I2C LCD Module (HERE)
  • 16×2 LCD Module (HERE)
  • HC-05 Bluetooth module (HERE)
  • 5mm LED (HERE)
  • Variable Resister POT 10K (HERE)
  • Variety of connectors (HERE)
  • Small Bread Board (HERE)

Software Requirements

  • Arduino IDE (You can download it from HERE)
  • Arduino DHT Library
  • Arduino I2C LCD Library
  • Wire Library (Inbuilt within the IDE)
  • Servo Library (Inbuilt within the IDE)

Configure HC-05 as Master and Slave

Here we will set the HC-05 module in configuration mode and apply ATCOMMANDS to configure the module as Master and Slave.

Follow the above circuit diagram and provide the below AT-COMMANDS one after another to convert as MASTER or SLAVE.

Configure as Slave

  • STEP1: AT to check the module status and it will respond with OK.
  • STEP2: AT+ROLE? is to get the module role if it responds with ‘0’ it is in SLAVE mode and if it is ‘1’ then it is in MASTER mode. After checking if it is ‘0’ then no need to change anything. But if it responds with ‘1’ then again provide AT+ROLE=0 in the serial terminal to change the module to SLAVE mode.
  • STEP3: AT+ADDR? the command is to get the address of the module. (mine 21:13:5B50) DONE!

Configure as Master

  • STEP1: AT to check the module status and it will respond with OK.
  • STEP2: AT+ROLE? is to get the module role if it responds with ‘0’ it is in SLAVE mode and if it is ‘1’ then it is in MASTER mode. After checking if it is ‘1’ then no need to change anything. But if it responds with ‘0’ then again provide AT+ROLE=1 in the serial terminal to change the module to MASTER mode.
  • STEP3: AT+CMODE=1 this command is provided to fix the address of the slave. And whenever the slave and master turned ON the master will automatically get connected with the slave’s address.
  • STEP4: AT+BIND=21,13,5B50 this command will bind with the slave address. As you can see my Bluetooth address is 21:13:5B50 but we have provided a comma-separated. So, you need to follow the same procedure to work properly. DONE!

Configuration Testing

Now just turn on both the modules, and you will see the master will connect automatically to the slave by changing the LED blinking frequency. It increases the time delay between the blinks.

Circuit Diagram

Here you will find two different circuit diagram for different mode of communication. The first circuit is for slave Bluetooth module and the second if for master Bluetooth module.

Slave Circuit Diagram

Circuit Explanation

5mm LED: An LED is connected at pin A0 of Arduino UNO. The negative terminal of LED is connected to the common ground and the positive terminal of LED is connected to the pin A0 of Arduino UNO through a 1K ohm resistor for some voltage drop.

Connection of I2C LCD with Arduino: Follow the below table and connect the circuit carefully.

I2C LCD ModuleArduino UNO
VCC5v
GRNDGRND
SDAPin 0
SCLPin 1

Bluetooth Module:

Connect the Slave Bluetooth module as shown in the circuit diagram and follow the below table.

HC-05 Bluetooth ModuleArduino UNO
VCC5v
GRNDGRND
TxA4 (SDA)
RxA5 (SCL)

Master Circuit Diagram

Circuit Explanation

LDR module: If you are using LDR module then connect the analog output of LDR to the A1 pin of Arduino UNO. The output of LDR is analog, please do not connect the digital output of LDR module. Whereas if you are using the bare LDR as shown in the circuit diagram then the output will be an analog output just go with the circuit diagram.

Switch Connection: Here we are using two terminal Push to ON switch and it is connected at pin A2 but used as digital input. One terminal of switch is connected to the common ground and the other terminal is connected to the pin A2 of Arduino UNO with a 1K ohm pull up resistor.

Servo Connection: Here we are using a SG90 micro servo. It has three terminal VCC, GRND, and Signal pin. So, connect the VCC to the 5v of Arduino UNO, GRND is connected to the common ground and the signal pin of servo is connected to the pin D9 of Arduino UNO.

Connection of DHT11 with Arduino: Follow the below table for the connection and connect carefully.

DHT11Arduino UNO
PIN1 (VCC)5v
PIN2 (OUT)A0
PIN3NC
PIN4 (GND)GND

Connection of I2C LCD with Arduino: Connect carefully I2C LCD as per the below table.

I2C LCD ModuleArduino UNO
VCC5v
GRNDGRND
SDAA4 (SDA)
SCLA5 (SCL)

Bluetooth Module:

Connect the Slave Bluetooth module as shown in the circuit diagram and follow the below table.

HC-05 Bluetooth ModuleArduino UNO
VCC5v
GRNDGRND
TxA4 (SDA)
RxA5 (SCL)

Video Tutorial

Download Source Code

Download the master source code: click here
Download the slave source code: click here

Leave a Comment