The Bluetooth module HC-05 is a MASTER/SLAVE module.The Role of the module (Master or Slave) can be configured only by AT COMMANDS.
By default the factory setting is SLAVE.
This post walks you through the AT commands of Bluetooth module .Through AT Commands you can change the ROLE of the module. Name,Password of the Module can be changed .The list of AT commands can be downloaded HERE
Remember the models HC-04 or HC-06 are SLAVE only modules .HC-05 is the module of interest in this post.To identify the model you can see the pin count.If the module has 5 or 6 pins it is HC-05.If the module has only 4 pins then it is HC-04 or HC-06.
The firmware for HC04 is LINVOR & for the HC05 it is HC05 itself.If you scan for bluetooth devices from your Android phone you can see this name.
The extra pins in HC-05 are the KEY & STATE pins.The KEY pin is used to enter the Command mode.
HC05 Pin count is 6 MASTER/SLAVE HC-04 Pins 4 SLAVE ONLY
The slave modules can not initiate a connection to another Bluetooth device, but can accept connections.Master module can initiate a connection to other devices. Be sure not to make the mistake of buying 2 slaves (HC-04) .
To enter the Command mode you can either use an USB TO TTL Module or your Arduino UNO board.
USB TO TTL DEVICE ARDUINO UNO
First let me explain how to use the Arduino board for the configuration.We need to use the USB – UART portion of the Arduino board bypassing the bootloader function of ATMEGA328.For this connect the Arduino to PC & just upload an empty sketch
————————–
void setup()
{
}
void loop()
{
}
————————–
Connect Rx (pin 0) of Arduino to Rx of Bluetooth module.
Tx (pin1) of Arduino to Tx of Bluetooth module.
Yes,I’m correct.The connection is one to one while using Arduino as USB-UART board.It is not the other way (Tx to Rx while using USB-TTL board).
Before connecting the power to HC05 module you should know that there are there are two ways of activating command mode on these devices.
One is to hold pin 34 high (KEY) as the device is powered on and it should enter command mode at 38400,8,N,1
The other is to hold pin 34 low then set it high after the module has been powered on and it will enter command mode at the pre-programmed speed (default is 9600,8,N,1).
Let us complete all the connections and finally provide power to the module.
HC-05 ARDUINO
Tx –—> Tx (1)
Rx –—> Rx (0)
Vcc ––> 5v
GND –-–> GND,
KEY –—> 3.3V
Now provide the power to the module by connecting USB cable to Arduino
The Status LED starts blinking slowly (once per 2 secs).This indicates that the module has entered the command mode at the BAUD RATE 38400.
You can use the SERIAL Monitor of the Arduino to feed AT commands.
At the bottom of the SERIAL monitor ensure that you select “BOTH NL & CR” .This will feed /r/n after each command.Generally while using Arduino ,the println() statement), appends both carriage return and newline .(In case of PIC or 8051 you should add terminator ( “0x0d 0x0a”) to the program.)
HC 05 module needs a CARRIAGE RETURN & LINE FEED after each command .
Now open the Serial monitor of Arduino with settings BOTH NL & CR , Baud Rate 38400
Type in AT & click on Send.
You should get a OK response from the module.
The default ROLE of HC-05 is SLAVE .To change this to MASTER type in
AT+ROLE = 1
The module responds with OK.
To confirm , type in AT+ROLE ?
The module will reply the status as ROLE 1.
You can also use a Terminal software like TERATERM to feed the AT Commands.
Close the Serial monitor of Arduino & then start the TERATERM terminal.
Select Serial at the start up window of TERATERM.
Under SETUP –> Terminal select CR+LF of Transmit & tick mark the LOCAL ECHO (to see what you type)
Under SETUP –> SERIAL PORT select the BAUDRATE 38400 , 8N1
Now you are ready to feed the AT commands.
To query a condition like Name, Password ,etc. you need to use a ? question mark after the command.
To change the condition use the equal to mark = after the command.
For e.g to query about password you type in AT+PSWD?
To change the password you type in AT+PSWD=1234
In the next post we shall see how to pair 2 nos. HC-05 modules so that it can replace the physical Serial connection.This can be an alternative to ZIGBEE , but with less range and more data speed (2Mbps).
hi…
deela here,
ehm… mind you tell me where I could get ardiono which allow me to use 38400 baud rate? you know… my arduino couldn’t show 38400 baud rate at all. not only mine, my friends too. and we don’t know why this happened.
thank you..
I think you’re using Arduino IDE version 1.5.8 which is still in beta and is for YUN & DUE boards.For some reason 38400 baud is omitted in this IDE.Always use version 1.0.6 if your Arduino is UNO or Mega.Use 1.5.8 only for Yun or Due boards
oh, i see. thank you for your information. yes I use IDE version 1.5.8
When i select 38400 baud in serial monitor the text in the monitor turns from “Enter AT commands:” to “x x0x0x0x0x0 x0 x0” please help me to correct whats wrong….
Remember to complete the connections & finally provide power to the Bluetooth.The KEY pin should be at 3.3v while providing power to the module.If you give Vcc first & then
connect Key pin to 3.3v , the module enters AT mode(or sometimes may not enter AT) at different Baud Rate of 9600 & not 38400.
Dear “alselectro”,
Your articles are of great help. I started to play with HC-05. When I interrogated a module straight from ebay from China, with AT+UART? command, I got back +UART:9600,0,0 . How come it has “zero” stop bits? Should I change anything if actually I want 9600bps, 1 stop bit, no parity? What is the interpretation of Param2 and Param3 of this command?
Regards,
Alex
While I took up HC05 ,initially I was confused on this.But on verifying the AT command datasheet , it says default is 9600,0,0 .First parameter is Bits/sec . 2nd parameter is stop bit ( 0 represents 1 bit , 1 represents 2 bits ) , 3rd parameter is parity ( 0- none, 1 – odd , 2- even).
For reasons known to them 2nd parameter 0 means 1 stop bit !!!!
Many thanks for quick reply!
Dear alselectro,
Since you seem to be a knowledgeable person, could you please recommend good VCP drivers for HC-05 (and HC-11 for tht matter) for Windows 8 (8.1). (I am using a USB “memory stick” style HC-05 and HC-11.)
It was relatively easy to get HC-11 and HC-05 running under Windows XP, but with WIN8… could not find a driver. Eventually got STMicroelectronics V1.4.0 (release 10/20/2014), but it so fiddly — requires manual driver update operation through Device Manager. I succeeded with HC-11 but not with HC-05 as yet, though they seem to have the same USB bridges. Your advice re WIN8 VCP drivers will be highly appreciated. (I guess driver issue surfaces regularly on forums…)
(By the way, IMO, FTDI USB bridge chips and drivers are the most robust, and a combination of USB-to-TTL bridge + bare HC-xx would work better than a “memory stick” styled HC-xx device, but convenience and size rule.)
Regards,
Alex
Virtual Com ports are provided by ICs like cp2102, ch340 , prolific 2303.Out of these cp2102 seems to have no issues with WIN8. But others have some issues.
The driver verification facility of WIN 8 has to be by passed.Now WIN8 will allow 3rd party driver installation.
You can follow this instruction to disable driver verification
https://alselectro.wordpress.com/2013/11/02/usbasp-drivers-not-installing-on-win-8-pc/
Hi alselectro,
In the bluetooth module FC 114, there is an EN pin. What is the use of that pin and where do I connect it with arduino uno . How do I use that bluetooth module in master mode while pairing it with other bluetooth module ( PI 05).
FC114 pinouts are different from that of the common breakout board available in the market.FC114 enters into AT mode when powered up & goes to communication mode when paired up.Refer this link for more details
http://www.martyncurrey.com/hc-05-fc-114-and-hc-06-fc-114-first-look/
Hi
5-6 months ago I bought HC-05 – bluetooth to serial port module.
With my android phone device work good but
I have problem to connect this device with my car android radio – I must remove device bluetooth paired code.
Do you know what command I should send to bluetooth (for example with bluetooth terminal program) for remove paired code?
Thank you for your attention.
AT+RMAAD will release the module from any previous PAIR.
AT+ORGL restores the module to original factory settings..
HELLO SIR I SAW ALL YOUR VIDEOS… IT’S VERY USEFUL FOR OUR PROJECTS.BUR ONE PROBLEM I AM USING SIM 908 MODULE. IN THIS GPS DID NOT WORK THE SERIAL MONITOR SHOWS ONLY CHAR RX VALUES. HOW TO ACTIVATE GPS IN SIM908 WILL U REPLY ME AS SOON AS POSSIBLE SIR… ITS MY KIND REQUEST
GPS enable AT commands should bring you the NMEA sentences.
GPS AT+CGPSPWR=1 enables GPS engine
AT+CGPSRST=0 COLD starts GPS.
AT+CGPSINF=0 returns a single NMEA sentence.
You can watch this video : https://www.youtube.com/watch?v=PkSD27pGz9M
is it possible to get connected device id or address using HC-05?
Still Doesn’t work, I have tried everything, Best I can get is a bunch of garbage in serial monitor that looks like this (⸮⸮xx⸮x⸮⸮)
I connected HC-05 to Arduino Uno and I was able to pair my android to it. I wish to make my android keep checking if my phone is there and open a relay switch. If I go away (and take my phone) the arduino see there is no phone and cut the relay. Now I do not get connection in STATE pin only if i use an BT app to connect to HC-05. Can I get this without an app on android?
Thanks.
Hi sir i saw your video, and its very useful to my project.
maybe you can help me on my problem sir i use HC 05 module, arduino uno and motor shield i already connected the BT module to my app the thing is my app is sending data to the module but the module cant recieved the data? maybe you can suggest a solution regarding on my problem thank you sir in advance