Connecting HC-05 in Master and slave mode
Today, In this tutorial we are going to discuss about HC-05 and HC-06 bluetooth modules and Connecting HC-05 in master and slave modes.
The difference between HC05 and HC06 is that the HC05 can be used as a master and slave, both. So we can transmit and receive data, only one mode at a time But on the other hand, HC-06 can be used as slave only. So we can only receive data and can not send through it.
REQUIREMENT
You are going to require few things in order to set up HC05 in different modes and to communicate with it. These are as follows:-
1.) First you need is a USB to serial converter so that you can send and receive data from computer. I am using FT232RL for this purpose. There are other serial to USB converters, You can use anyone.
2.) Second, you are going to need a serial terminal to receive and transmit serial data. I am using ARDUINO serial monitor.
Connections
Now connect the HC-05 with the FT232RL as shown in the figure below.
SLAVE MODE
Use the following commands to set HC-05 in the slave mode:-
AT // should receive OK
AT+ROLE=0 // should receive OK
AT+PSWD? // should receive password maybe 1234
you can check more AT commands for HC05. Just google it.
The above commands will set the HC05 in the slave mode. Now disconnect it from the power and connect it again without pressing the button, This will force it in the ‘com’ mode.
As the device is in the slave mode, we will send some data to it via the phone which will act as master. So unlock your phone and pair with HC-05 with the pairing code as shown by password command, mostly it is ‘1234’. Download a bluetooth serial terminal app and send some data to the device, You will see that the data is being received in the PC terminal. Check the at the end for more information.
MASTER MODE
Before setting the device in the master mode, make sure you have another device which is in slave mode. I have HC-06 which is always in the slave mode. To find the mac address of the HC-06, you have to power it and than use your phone to search for the bluetooth devices. The result is shown below.
As you can see I have the mac address of HC-06. Note it down somewhere, we are going to use it.
Next, force the HC05 in the AT mode by pressing button again and use the following commands to set HC-05 in the slave mode:-
AT+ROLE=1 // response'ok'
AT+CMODE=0
AT+BIND=98d3,35,70bf8b // address formatting is abcd,ef,123456
Now disconnect both the devices and again connect them. IF you did everything properly, Both devices should connect and you can see that by noticing the LED blinking rate.
Transferring Data
Now we are going to transfer data from PC to HC-05 which will send it over the bluetooth to HC-06 and than we are going to read it from HC-06 via PC again. The connections are shown below
Tx(FT232) —> Rx(HC-05)
Rx(FT232) —> Tx(HC-06)
Vcc —-> Vcc
Gnd —> Gnd
Now try sending some data and you will see that it is being printed on the terminal itself. Actually it is being routed from HC05 to HC06 and than back to terminal.
As you can see above that data is routed back to terminal.
CHECK OUT THE VIDEO BELOW
CHECK OUT THE VIDEO BELOW
Connecting HC-05 in Master and slave mode
Reviewed by Controllerstech
on
July 21, 2018
Rating:
No comments: