Bluetooth HC-05, HC-06 Command/ Master Mode and AT Commands

Interfacing Bluetooth HC-05 with Arduino, Connection Diagram - bluetooth device in command/ Master mode

Interfacing Bluetooth HC-05 and HC-06 with Arduino using AT Commands in Master Mode.

Bluetooth HC-05 pinouts

Connections:

To Bring Bluetooth HC-05 and HC-06 in command mode, connect Pin 34 (command) with 3.3v (Vcc), but remember, when HC-05 or HC-06 will be in command mode, its baud rate will automatically change to 38400, which is default, no matter what have you set your baud rate earlier for data transfer.

 

Interfacing Bluetooth HC-05 with Arduino, Connection Diagram - bluetooth device in command/ Master mode

Connect Bluetooth Module HC-05 or HC-06 with Arduino as:

BluetoothArduino Mega 2560
1 – TXRX1
2 – RXTX1
12 – Vcc+3.3v
13 – GndGND
34 – PIO11+3.3v

AT Commands for Bluetooth:

Make sure to use CR and \n at the end of each command or in Arduino use Both NL and CR option in Serial Monitor
AT Commands used by HC-05 & HC-06 and most of other Bluetooth Devices

Code for Arduino Mega:

void setup()
{
Serial1.begin(38400);
Serial.begin(38400);
}

void loop()
{
if(Serial1.available())
{
byte a=Serial1.read();
Serial.write(a);
}

if(Serial.available())
{
byte a=Serial.read();
Serial1.write(a);
}

Sequence to Search and Pair a Device:

AT
OK
AT+CMODE=0
OK
AT+ROLE=1
OK
AT+INIT
OK
AT+INQ
+INQ:4D65:4D:CA6612,5A0204,7FFF
OK
AT+BIND=4D65,4D,CA6612
OK
AT+PAIR=4D65,4D,CA6612,30
OK

 

Bluetooth Data Mode:

To bring Bluetooth back in Data Mode, just disconnect Pin34 (PIO11) from +3.3v and leave it open / disconnected.

Video on Interfacing Bluetooth Modules with Arduino Mega 2560:

Leave a Reply