Introduction: OldMan and Bluetooth2
So this Lazy Old Geek (L.O.G.) finally got a Bluetooth HC05 module from AliExpress.com. I ordered one after writing this Instructable:
Well, I spent several hours trying to get this working in command mode without success. I even destroyed an HC05 module (probably applying wrong voltages) so had to buy another one.
TIP: Command mode is talking to the HC05 or HC06 module itself. Communication mode is talking to another Bluetooth device.
What I found is a lot of differences between HC05 and HC06. The HC05 can be a master or slave, the HC06 is slave only. Basically, a master can talk to a slave, two slaves cannot talk to each other. The HC05 and HC06 have different commands. The HC05 has to be hardware-configured to go into command mode, it can have different baud rates for communication and command mode.
The HC06 is always in communication and command mode. Setting the baud rate for one will change the other.
TIP: Keep track of this as I didn’t and had some problems.
TIP: Different HC05s and HC06s may be different from the ones I got.
The HCO6 will perform commands, but doesn’t always show changed results, e.g. name change.
Step 1: Evaluation/modification
Attached is an HC05 schematic similar to mine. Two differences I know, are that there is a 2.2K resistor between PIO11 (34) and the EN pin and the 3.3v regulator is a 3 pin package and does not have a CE pin. The attached picture is a marked up schematic to what I think I have.
For programming purposes, what is important is that pin 34 Key is connected to the EN pin through a 2.2K resistor. (It is also connected to the pushbutton, the other side is connected to 3.3V)
The stock HC05 requires 5V power though it works with 3.3V signals so I modified my HCO5 to use 3.3V instead. I removed the 3.3V regulator and ran a jumper from the VCC pin directly to 3.3V. This is shown on the modified schematic and my modified HC05 picture.
By the way, the attached HC05 Command Set.pdf has some valuable information on using the HC05, Unfortunately, it’s not very user friendly.
Step 2: Programming the HC05
I decided the easiest way to use the HC05 was to connect it to one of my CP2102 3.3V serial adapters like I did in Old Man And Bluetooth Instructable with a HC06. See picture and schematic.
IMPORTANT TIP: To power up the HC05 in command mode, the PIO11 pin (34) needs to be high before 3.3V is applied. The EN pin on my HC05 is connected to PIO11 through a 2.2K resistor, so it just needs to be tied to 3.3V. The schematic shows this as the Program pins but just place a jumper from 3.3V to EN pin. Make sure you do this before you apply power. On mine, you can tell if you’re in command mode because the HC05 LED will blink slowly. If it’s blinking fast, then you’re in pairing mode and need to try again.
TIP: The HC05 in command mode always talks at 38400 baud rate. All commands are capitalized and need to be followed by a CR and LF. (This is different than the HC06)
TIP: The command format is very strict. Always use caps. They all start with “AT” Follow them exactly, you cannot add spaces where they aren’t shown.
Start up Arduino. Go to “Tools” “Port” and select the Com port that the CP2102 is connect to.
Open the Serial Monitor. Towards the bottom of that window, select “Both NL and CR” and “38400 baud”. (NL stands for New Line which is the same as LF which is Line Feed).
Towards the top, there is a box next to the Send button, click in it.
On your PC turn on Caps Lock
The big window should display “OK”.
You are communicating in command mode.
Some commands that work on mine
AT+NAME=BT1 This changes the name to BT1
AT+ROLE? 0 = Slave 1=Master
Step 3: HC06 Revisited
One of the main differences between the HC05 and the HC06 is that the HC05 can be master or slave while the HC06 is slave only. That means you can talk between a HC05 and a HC06. However there are a lot of other differences.
While I could’ve used an Arduino to setup my HC06, I chose to use a 3.3v CP2102. See Picture
This is basically the same as the HC05 except my HC06 only has four pins.
My CP2102 is modified to supply 3.3V
My HC06 is modified to accept 3.3V
The CP2102 USB is connected to my PC. On my PC I’m using the Arduino IDE.
Select the correct “Port” and open up the Serial Monitor.
On my HC06, the red LED is flashing fast, which indicates it is ready to pair but can also receive commands.
Some of this information came from Martyn Currey:
So each type of HC06 may be different, mine returns the VERSION linvorV1.5
For my HC06 (and probably all of them), there is no special procedure to get it into command mode. Apparently if it’s not paired, you can always send commands via the serial port.
TIP: you cannot send commands to any Bluetooth module(that I know of) via Bluetooth.
Open the Serial Monitor
Click on the first box at bottom of Serial Monitor and set to "no line ending"
Initially, my baud rate was 9600 baud
On your PC set Caps Lock on
In top box type AT
Type Enter or tap “Send” button
The screen should display OK
TIP: If you do not get an OK, it could be because the baud rate was changed or is different. You can try various ones, until you, hopefully, find the correct one.
NOTE: Sending multiple commands, the response data does not shift to the next line. Towards the bottom, you can click on Clear output.
Commands that work for me:
(It doesn’t tell you the name but if connected by Bluetooth, it will appear.)
NOTE: if you change the name, the old name will show on your smartphone until you un-pair and re-pair.
AT+PINxxx Haven’t tried it. The defaut is 1234
AT+BAUD8 Changes Baud rate to 115200
Response is baud rate, e.g. 115200
(After changing the baud rate, you have to change Serial Monitor baud rate to 115200 to send further commands.
Baud rate options
NOTE: I haven’t tried higher than 8 115200. I’ve hear of people trying higher rates with bad results.
The other commands that are supposed to work but not tested:
AT+PN no parity check(default)
AT+PO odd parity check
AT+PE even parity check
IMPORTANT: At this point, I would suggest you decide on a unique name and put it in. I would also suggest you decide on the baud rate you want to communicate at, put it in and marked your HC06 with it.
Step 4: Setting Up HC05 to HC06
Ok, this Instructable was most helpful to me:
SLAVE finding address
HC06 with CP2102 (automatically in command mode)
Plug the CP2102 USB cable in to power the HC06.
The HC06 LED should be flashing fast (Pairing mode).
On your smartphone, open settings
Go to Bluetooth
Search for new device
If you see something like HC06 or the name you gave it, select this.
You will most likely see a string of numbers like 00:12:09:27:19:13, that’s probably it.
Write down this address. (The number is its unique address)
When asked for a Pin, type in 1234.
The name should be displayed.
If you still don't have the address, under “Previously connected Devices” Select the name.
Click on Info, The address should be displayed. Write it down.
If it doesn’t show, get out of setup and open Bluetooth Terminal HC-05 app.
Under Paired Devices, find the name, the address should be below it, write it down.
If the HC06 LED is not flashing, cycle power to get it back into pairing mode.
Under “Tools” “Port” Select correct Com port
Open Serial Monitor
At the bottom of this window
Select “No line ending” and “9600 baud”
HC05 with CP2102 set in command mode (EN jumpered high)
Plug the USB cable from CP2102 into PC
I found out I can open up two Arduinos
On second Arduino, select correct Com port for HC05
Open Serial Monitor
At the bottom of the window
Select “Both NL&CR” and “38400 baud”
The following is from the above Instructable
The required AT commands to set the configuration:
COMMAND RESPONSE What it does
AT+ROLE=1 OK Set HC05 as master
AT+CMODE=1 OK Connect to specific address
NOTE: The HC06 address is probably formatted like this 00:12:09:27:19:13
The BIND command expects this 0012,09,27193 (you take out the colons, take the first four numbers, then comma, the next two numbers, then comma, then the last six numbers)
AT+BIND=0012,09,271913 OK Connects/binds with HC06
(By the way AT+BIND? responds with +BIND:12:9:271913)
(You want the HC05 communications speed to be the same as the HC06) for example:
AT+UART=115200,0,0 OK Baud rate 115200 (1stop bit, no parity)
To test communications:
Remove HC05 EN jumper, power cycle.
When the two are connected, the HC05 LED will blink twice every few seconds, the HC06 LED will stay on continuously.
Set both com ports to the same baud rate (whatever you setup)
Set both to “Both NL&CR”
Type something on Serial Monitor1, Serial Monitor2 should display it.
Type something on Serial Monitor2, Serial Monitor1 should display it.
Congratulations, you are communicating via Bluetooth.
Now the above Instructable has some sketches on how to uses the modules with Arduino. For this Instructable, I won’t delve into this.