Familiarization Of HC05 (Master-Slave) Bluetooth Module

To establish communication between two Bluetooth modules, configure one as master and other as slave. Bluetooth uses piconet protocol for communication. The master establishes connection with slave devices found within its range, called access points, there is nothing to do slave until the communication channel creates by master.

To communicate with modem, you can use any terminal software. This example is done with RealTerm.

1. Select Display as  Ansi. Check Half Duplex mode. This helps you to view the commands issued on terminal. On keeping this unchecked, you can see the response only.

2.  Select Port option, select Baud as 38400, select proper com Port, click Change then Open to ready   communication.

3. The AT commands end with line feed and carriage return, so check +CR and +LF. You can type command to send and click Send ASCII.

AT command mode

In AT command mode, open the Key pin to give 3.3V to PIO11 and  power up the module. In this mode, we can configure the different parameters which finally determine the working of the module. In this mode, we can’t communicate with other devices. The default baudrate in command mode is 38400.

Lets look at some of the most commonly used AT commands. Notice that all AT commands end with carriage return and line feed.
AT                  :  To enter command mode
AT+NAME     :  Set/check the name of the Bluetooth module
AT+ROLE      :  set/check the role of the module; 0 – Slave, 1 – Master
AT+PSWD     :  set/check the password/PIN code
AT+ADDR     :  get module address
AT+RMAAD  :  Delete all authenticated previous paired devices
AT+CMOD    :  Set/Check connect mode
AT+UART      :  Set communication baudrate
AT+ORGL     :  Restore default
AT+RESET     :  Reset the module
AT+INIT         :  Initialize the SPP profile
AT+INQ         :  Inquiry Bluetooth Device
AT+RNAME  :  Get the Bluetooth device name
AT+LINK       :  Connect Device

The figure below shows the factory set name, address, role and password.

Bluetooth as slave

All Bluetooth modules are slave by default. So it is not necessary to configure it as slave. But in case the module is set as master, then you have to change it to slave. Use the commands given below. Ensure that the key pin is open.

1. Type AT  to enter command mode.
2. Give suitable name. eg ; AT+NAME=Bluelink_SLAVE
3. Set the role as slave using AT+ROLE=0.
4. AT+CMODE=1 helps to connect any address.
5. If you want to set password, use the command AT+PSWD
6. You can delete previous paired devices using AT+RMAAD

After configuration short the Key pin to enter communication mode.

Bluetooth as Master

1. Type AT  to enter command mode.
2. Give suitable name. eg ; AT+NAME=Bluelink_MASTER
3. Set the role as slave using AT+ROLE=1.
4. AT+CMODE=1 helps to connect any address.
5. If you want to set password, use the command AT+PSWD. Password must be same for both modules.
6. You can delete previous paired devices using AT+RMAAD

 Pairing master and slave

Establishing a connection begins with a phase called “inquiry“, during which the master sends an inquiry request to all devices found within its range, called access points. All devices which receive the query reply with their address. Make sure the key pin is open before enter commands.

1. To initialize the SPP profile, use AT+INIT. Getting error message as response indicates that the command was already given.
2. AT+INQ sends inquiry request to the slaves. You will get the address, Device class and signal strength. e.g, +INQ:1014:7:103115,0,7FFF.  The LED D1(blue) blinks fastly in inquiry stage
3. Optionally you can send command to get name by using AT+RNAME?<address>. The full colon in the address must be  replace with commas. eg; AT+RNAME?1014,7,103115.
4. Send AT+LINK to pair with slave. If slave response OK, the connection is established.Led D2(yellow) become on.

Communication with slave

Now both the modules are ready for communication. you can transfer data between the modules. The communication between the master and slave as shown below.

If the key pin is short, the module will auto connect with slave when powered up. So master can directly communicate with slave.

Resources

Shop with us



Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">