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.



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.


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.



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".


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

Get