Skip to content

Archive for September, 2013


Bluetooth HC-05 Mac Programmer App

After spending time writing a sketch for the Arduino so I could program the HC-05 Bluetooth modules, I had a mind tweak that the same should be able to be done with the Mac here. And since I’m a Macintosh programmer by nature, why not.

That’s right, there’s now an App for that.

I tried a couple of different USB to Serial (TTL) adapters and the one that worked the best and most reliable was the CP2102 from Silicon Labs. The 2102 is a USB to UART bridge chip. You can find these littered on FleaBay for a couple of bucks.

I used some Dupont jumpers to connect the HC-05 to the adapter:

IMG 4125

Wiring wise it’s this:

  • CP2102 —> HC05
  • 5V ——-> 5V
  • GND ——> GND
  • TX ——-> TX
  • RX ——-> RX
  • 3.3V —–> KEY

There are no connections on the CP2102 RST or the HC05 STATE lines.

Notice the TX–>TX and RX–>RX. If you’re thinking that’s not quite right, in the real world it’s probably not. In the fantasy world where the Bluetooth modules are made, the labels indicate where the signal is SUPPOSED to go. So the TX pin silk screen on the HC-05 means it’s supposed to GO to the TX on the UART adapter. Apparently some not so terribly bright engineer thought this might be a simpler concept for the unwashed masses to grasp. News flash for them, if your IQ is higher than an Alaskan winter temperature, this is dumb labelling.

Thus, be aware that if you use different Bluetooth modules, you MAY find the labelling is different. Just saying…

A close up of the connections:

IMG 4126

If you’re wondering why the KEY connection has 3.3V going in it, it’s because in order to get the HC-05 in command AT mode, you need to make the KEY line HIGH when the HC05 powers up. Since there’s a 3.3V output on the USB to Serial adapter, it’s easy to do that.

The Macintosh program to program the HC-05 can be downloaded from THIS link. Unzip the file, put it in your Applications folder, wire up the modules, plug in the USB to serial adapter to the Mac (install the SLAB drivers if you haven’t already) and then run iBT.

Note, when you plug in the USB to Serial adapter and the HC05 powers up in the AT mode, the LED indicator will blink, slow. Very slow. About every two seconds, on, then off.

In the Preferences tab, just match your settings to these, and then click the Bluetooth ON button.


Switch to the Bluetooth panel and the information should fill in for you. If it doesn’t, “sum ting wong”. Recheck the wiring. Once properly wired you’ll see the window values change, as the carnival barker used to say, “Before your very eyes!”.


Change what you want and click the SET button beside that option to update the HC05. iBT will write JUST that data to the HC05 for you. If you get an error, iBT will report it.

The UART setting is the Bluetooth wireless connection speed NOT the programming speed via USB. With USB these modules are always 38400,N,1.

A lot of these modules come with a passcode of ‘1234’, but the Mac’s normal default is ‘0000’, so you might want to change that.

The Set Default button will reset the HC-05 to this:

  • Device Type: 0 (Class)
  • Inquire Code: 0x009e8b33
  • Mode: Slave
  • Serial (wireless): 38400,1,N
  • Passcode: 1234
  • Name: H-C-2010-06-01

So there you have it. HC-05 programming from your Mac made simple. iBT written by Mel Patrick is NOT public domain, but freeware. It may be used by anyone but may not be sold or hosted on any other site.


Arduino Bluetooth HC-05 Revisited

Arduino Bluetooth modules have to be the cheapest way to get two way wireless communication within 30 feet or so that there is. I paid less per HC-05 than I did for a burger, fries and a Coke. Plus I know which one is better for me…

As far as I’m concerned the HC-05 is the Bluetooth module to get. It’s very programmable, can be a master or slave, and the darn thing is 100% reliable. That’s a welcome change from a lot of wireless modules I’ve used in the last year.

There is a difference in these HC-05s though and it largely depends where you get them from and if they have a backplane (some call it a breakout board). While you can indeed get one without a backplane, I’d suggest that you might save yourself some time and headache if you get one that’s already mounted on a breakout board.

For the six pin version, these seem to be one of the more popular ones on eBay:


The ones I got didn’t have the “arrows” on the TXD/RXD lines so I, incorrectly assumed that the pins denoted the function of that pin. Nope. The silkscreen was meant to tell you where to connect those pins. Once I got over that little snafflegrab, everything progressed nicely.

The second type of HC-05 were the 4 pin versions. Vcc, GND, TXD, RXD. With these, you’ll have to find where the AT jumper is to put them into programming mode.

For the JY-MCU versions, you need Vcc, GND, TXD, RXD and KEY. Wire the KEY pin to VCC and then power up the module. It will be in programming mode (slow blink on indicator LED).

I decided I needed a board to help program these and since I had a few prototype boards around, I built a sort of Lego style plug board. Which could be used for other things than just programming Bluetooth modules.

IMG 4117

I tend to work with Arduino MEGA 2560’s more than the smaller UNO’s so the board was kind of designed with that in mind and the sketch in this blog reflects that. I have some 20mm headers that will plug into the Arduino sockets and then protrude through the prototype PCB. I have scads of Dupont female jumpers that I prefer using instead of the male jumpers most people use. So that’s what I use.

You can see the 20mm plugs extend up a fair bit. Perfect.

IMG 4118

Next I solder in all the headers I want (there’s a number of power pins on these boards and I put a header in them). At the bottom of that row, I solder in a SMD LED and resistor to tell me when the board gets power.

IMG 4119

From the underside of the board, I bend over the pins from the female header so I can make a bridge to the male pins:

IMG 4120

If I needed more female headers, I’d solder those next to the headers than go into the Arduino board itself. Thus, lots of room for expansion.

I grabbed one of my Bluetooth 4 pin modules and put it on the protoboard, put the jumpers to where they had to go:

IMG 4121

After programming it, I took it out and put in one of the JY-MCU boards to program it:

IMG 4122

Pretty easy to do really.

The Sketch I use for programming the HC-05 is written for the MEGA, if you want to modify it for the UNO, use software serial to do it. The change all the “Serial1” to that bt reference you created. Again, not that hard to do. I normally use pins 2 and 3 for the Bluetooth serial.

If you read the documentation on the HC-05, which I might add is fairly extensive, you’ll find that you can actually program a “class” definition for the device. Why would you want to do this? Two reasons. A number of the modules I bought seem to come with a Class=1F00, which is “uncatagorized”. This shows up in your computers Bluetooth setup as “unknown”. This may actually be correct depending on what you’re doing with the module, but I found I change the name, password and the class to reflect what the module is used for.

However, you get a 32 bit number to program into the module so, here’s a link to a COD (class of device) generator or (checker) so you can create a meaningful class and program it in with my sketch:

Bluetooth CoD Calculator

And finally, there’s the sketch itself. As noted, written for MEGA, using Serial1 on the Mega.