loading

This tutorial is going to teach you some basics on configuring two HC-05 Bluetooth Modules as Master and Slave respectively and also a simple tutorial to see how each HC-05 controls LEDs wirelessly.

Step 1: Introduction

Description:

HC-05 Bluetooth Module is an easy-to-use Bluetooth SPP (Serial Port Protocol) module, designed for transparent wireless serial connection setup. Its communication is via serial communication which makes an easy way to interface with controller or PC. HC-05 Bluetooth module provides switching mode between master and slave mode which means it able to use neither receiving nor transmitting data.

Specifications:

  • Model: HC-05
  • Input Voltage: 5VDC
  • Communication Method: Serial Communication
  • can switch between master mode and slave mode
  • Transmission Distance: 20m ~ 30m in free space

Step 2: Pin Definition

Step 3: To Configure and Pair Two HC-05 As Master and Slave (Step 1)

Components that you need:

  1. One Arduino board... ( In this tutorial, we use Arduino Uno)
  2. Two Bluetooth Module HC-05
  3. A bunch of jumper wires
  4. USB Cable A-B Type
  5. Breadboard

Step 4: To Configure and Pair Two HC-05 As Master and Slave (Step 2)

To configure HC-05, we will have to enter AT mode. But, how to do that? Let's check the steps below.

1. Firstly, connect the components as shown in the diagram above. From the diagram, the VCC of HC-05 is connected to the 3.3V of the Arduino Uno. If the VCC of HC-05 is connected directly to 5V of Arduino Uno, there is a high possibility that HC-05 will be damaged. But still if you insist to do so, DO IT AT YOUR OWN RISK.

2. Next, before connecting the Arduino board to the USB cable, REMOVE THE VCC WIRE FROM THE HC-05. Only after you have removed the VCC wire, connect the USB to the Arduino board.

3. Download the sample source code (file name: AT mode) attached below and upload it into your Arduino board.

4. After the uploading process is complete, then reconnect the VCC wire back to your HC-05.

5. Now you will see the LED on the HC-05 bluetooth module is blinking for every 2 seconds interval. This indicates that the bluetooth module has entered AT mode.

6. To give AT commands, open your Serial Monitor. For about 1 second, a sentence saying "Enter AT commands:" will pop up. But before that, remember to change "No Line Ending" to "Both NL & CR" and also fix the baud rate at 9600. You can refer to the diagram attached above.

7. To see whether everything is okay or not, enter "AT" and send. An "OK" will pop up on the Serial Monitor and this implies that no problems occur.

Step 5: To Configure and Pair Two HC-05 As Master and Slave (Step 3)

Slave Configuration:

The required AT commands to set the configuration

  • AT+RMAAD (To clear any paired devices)
  • AT+ROLE=0 (To set it as slave)
  • AT+ADDR (To get the address of this HC-05, remember to jot the address down as it will be used during master configuration)
  • AT+UART=38400,0,0 (To fix the baud rate at 38400)

If the commands entered are replied with "OK" then it indicates that the settings mentioned have been customized.

You may also try out other AT commands such as how to change the name, the password, and so on. A full set of AT commands is attached below and kindly download it for your own use. Note that the password for both master and slave must be the same otherwise pairing will not be done.

Step 6: To Configure and Pair Two HC-05 As Master and Slave (Step 4)

Master Configuration:

The required AT commands to set the configuration:

  • AT+RMAAD (To clear any paired devices)
  • AT+ROLE=1 (To set it as master)
  • AT+CMODE=0 (To connect the module to the specified Bluetooth address and this Bluetooth address can be specified by the binding command)
  • AT+BIND=xxxx,xx,xxxxxx (Now, type AT+BIND=98d3,34,906554 obviously with your respective address to the slave. Note the commas instead of colons given by the slave module.
  • AT+UART=38400,0,0 (To fix the baud rate at 38400)

If the commands entered are replied with "OK" then it indicates that the settings mentioned have been customized.

You may also try out other AT commands such as how to change the name, the password, and so on. A full set of AT commands is attached below and kindly download it for your own use. Note that the password for both master and slave must be the same otherwise pairing will not be done.

Step 7: Sample Communication Between Master and Slave (Step 1)

With the two HC-05 configured earlier just now, a simple example can be carried out to see how each of them functions. In this example, both master and slave will be controlling LEDs by using buttons. Button A at master will be controlling LED3 and LED4 at slave whereas Button B at slave will control LED1 and LED2 at master. Now let's get started.

Components that you need:

  1. Two bluetooth modules, HC-05
  2. Two Arduino boards (In this example, we use Arduino Uno)
  3. A bunch of jumper wires
  4. Two push buttons (In this example, a two-pin push button is used)
  5. Four LEDs (What colour it emits does not matter)
  6. Two USB cable A-B type
  7. Two resistor of 220Ω
  8. Breadboard

Step 8: Sample Communication Between Master and Slave (Step 2)

*Note that the above sample hardware installation is applicable to both master HC-05 and slave HC-05.

Step 9: Sample Communication Between Master and Slave (Step 3)

Kindly download the sample source code attached below and upload them into Arduino.

this_is_master must be uploaded into the Arduino connected to master HC-05 while this_is_slave must be uploaded into the Arduino connected to slave HC-05.

Step 10: Result

The result is displayed in video form. You can see how master and slave interact with each other in this video. Have FUN~

<p>hello</p><p>i trata with this project but no response?</p>

About This Instructable

6,924views

31favorites

More by mybotic:How to Use I2C Serial LCD 20X4 (Yellow Backlight) How to Use Arduino I2C Serial LCD 16x2 (Yellow Backlight) HOW TO USE ISD1820 VOICE RECORDER AND PLAYER 
Add instructable to: