2014-10-28

GSMIRRC: Configure Arduino + Bluetooth HC-05 Slave

How to connect Arduino to Bluetooth HC-05 module:


HC-05 is not visible for Android by default - because of "secure device class" of "1f00"
AT+CLASS? 1f00

We will set the Class to "1":
AT+CLASS=1

and the Role to "Slave"
AT+ROLE?
AT+ROLE=0


1.1. Connect Arduino to Bluetooth HC-05 according to the layout:


1.2. Do not supply the power yet

1.3. Connect the HC-05 "key" pin (1st pin from the left) to Arduino "VCC" pin


1.4. Power On HC-05 (connect Arduino to USB)


1.5.1  Connect on 38400, 8n1
or
1.5.2 Load the Arduino test sketch:

#include <SoftwareSerial.h>

SoftwareSerial BTSerial(5, 4); // RX | TX

void setup()
{
  Serial.begin(9600);
  Serial.println("Enter AT commands:");
  BTSerial.begin(38400);  // HC-05 default speed in AT command more

//38400?
}

void loop()
{

  // Keep reading from HC-05 and send to Arduino Serial Monitor
  if (BTSerial.available())
    Serial.write(BTSerial.read());

  // Keep reading from Arduino Serial Monitor and send to HC-05
  if (Serial.available())
    BTSerial.write(Serial.read());
}


1.7. Open Arduino Serial Monitor (Tools > Serial Monitor) and run the AT commands:

>OK



<AT+ROLE
>+ROLE:0
 

<AT+CLASS
>+CLASS:1f00 

>OK  

AT+PSWD=4321

>+UART=9600,0,0

>OK 
>+UART:4800,1,0


>+NAME:HC-05


Now restart HC-05 (reconnect Arduino USB) and try to find and pair HC-05 from your Android (Settings > Bluetooth > Discover new devices)
Default HC-05 pin is 1234

Let me know if you have any questions.

References:
http://www.instructables.com/id/Modify-The-HC-05-Bluetooth-Module-Defaults-Using-A/?ALLSTEPS
http://byron76.blogspot.com/2011/09/hc05-firmware.html

No comments: