Sunday, July 31, 2016
Config HC 05 s as paired Master and Slave
Config HC 05 s as paired Master and Slave
This post show how to set a HC-05 as Master, and bind to another Slave HC-05. By default, HC-05 is set as Slave (ROLE=0), UART=9600,0,0 and PSWD="1,2,3,4", what we have to do on Slave is to copy the ADDR used to bind in Master. In Master side, what we have to do is set as Master (ROLE=1), make sure same UART and PSWD, BIND to Slaves ADDR, and set CMODE=0, such that the Master will connect the assigned Slave only. Once set, the Master/Slave pair will auto-connect when power-up in range.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhB5QU9nWIEm0q0uetISHaFeW_JjTdbPkUK6Ppw6I6NRYL-fzKeEAqlm9rfO9LCDg6P7utRxGkcbBg8k9NWp3kn03IpVfs1mGU0RN_JF2xsRTta0lz0BDrqtnl7IyTyyykMgvv4pbLMjhQ/s640/HC-05+pair.jpg)
In my setup, a FTDI USB-to-Serial adapter is used to check/set the HC-05(s), Arduino Softwares Serial Monitor is used to enter AT command to HC-05, all FTDI adapter, both HC-05 are set working on 3.3V.
Check the config of Slave HC-05:
Connection:
FTDI Tx - Slave HC-05 Rx
FTDI Rx - Slave HC-05 Tx
FTDI GND - Slave HC-05 GND
Conenct USB to FTDI, and open Arduino Serial Monitor, set baud rate to 38400, "Both NL & CR".
Press the on-board button of Slave HC-05 and apply power to Slave HC-05.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCTu2ASDuDoR_N-8bZ8qgueBsEp7dW_Ow_tfEjhehg2Wd9tGdTpsK_gYLnOm5eMWisCZIQB89_3INo17bgZpISwHO0udQZF_FlwsJmiWXCOSdQS9h_Hi2xjynXuNH82OyJxIC521GygnQ/s640/pair+HC-05_slave.png)
Make sure ROLE=0, UART=9600,0,0, PSWD="1234" by entering AT Commands:
AT+ROLE?
AT+UART?
AT+PSWD?
Copy the ADDR:
AT+ADDR?
In my case, ADDR is 2014:12:20016
Power-off and disconnect the Slave HC-05.
Set the config of Master HC-05:
Connection:
FTDI Tx - Master HC-05 Rx
FTDI Rx - Master HC-05 Tx
FTDI GND - Master HC-05 GND
Press the on-board button of Master HC-05 and apply power to Master HC-05.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSxLHTcvxVhhoYCoN4sYC114ZbYULJ7iO9dByyf51O5UhNbgQPXm96FqC97HZ-7IJ3gv2ZlIIe4Qkl-Ez7NELptLVtv19G8Fif5VJaMmeSj_3ioS4zI7PHsNucjU1ARs8wY8pKkDf4E5w/s640/pair+HC-05_master.png)
Make suew UART and PSWD match with Slave side:
AT+UART?
AT+PSWD?
Change ROLE to Master
AT+ROLE=1
Bind to the ADDR of Slave. In my case Slaves ADDR is 2014:12:20016, replace : by ,, enter:
AT+BIND=2014,12,20016
And set CMODE=0:
AT+CMODE=0
Power-off the Master HC-05.
Auto connect:
Keep FTDI connect to Master HC-05. Connect TXD and RXD of Slave HC-05 together, to echo the received data back to sender.
Power-up both Master and Slave HC-05, dont press the on-board button.
Change baud rate of Arduino Serial Monitor to 9600 (match with the UART in HC-05), keep using "Both NL & CR".
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi39_bcKCJ0XN6AFtq17mJptt7pkb7PtPdWcF4qL6CnsrhzVepk5kv19aREUmgksZAAF4vPbATAmERqd3DzVftcqnnW5lRrBSdwracby-q9a2bz4jJ8Z9Fukq7rRcUAFKqhYQSi4vhlMlo/s640/pair+HC-05_paired.png)
Notice the blinking pattern of the on-board LED of HC-05(s), they will auto-connect once power-up.
Enter anything in Arduino Serial Monitor, it will be send to Master HC-05, and send to paired Slave HC-05 and echo back via Bluetooth,
Reference:
- Elastic Sheep - Serial Bluetooth module Master/Slave connection
- iteadstudio - Serial Port Bluetooth Module (Master/Slave) : HC-05
- AT Command mode of HC-05