Jan 7, 2014

HC-05 Bluetooth link of 2 Arduino

In my first Arduino bluetooth experiment, I made an automatic connection between 2 Arduino using BlueSmirf modules. Based on the popularity of that post, it seems that many people are trying to do the same.

On the down side, many of the visitors are looking for a solution using the HC-05 (or other HC-XX type) modules with an AT command interface. I planned to eventually use this type of device but never got around to doing it for every bad reason imaginable including procrastination. This delay was clearly unacceptable for Lyman (one of my readers) who decided to send me 2 extra modules he could spare.

On a side note, this kind soul only has 2 followers on Twitter. Please help me fix this grievous situation.

After playing a bit with my new toy, here's what I've got:

In this first simple example, the code sets the module to be either Master or Slave, connects to one hard-coded address and starts the communication loop. While connected, the Master sends 1s and 0s to the slave who is using this 'command' to switch an LED on or off.

You can get the code on this Git repo.

Breadboard diagram (without the reset connection)

The biggest problem was to figure out how to reset the module programmatically. The [not so good] documentation explains how this can be done by cycling the power but the bluetooth chip has a reset pin that is supposed to do the same trick. I have the code to use the reset pin which I got from this blog post and I will test it soon.

On the HC-05 modules I received, the reset pin is not connected which 'forced' me into making a little hack that can barely be noticed...

The next step will be to recreate the same query and auto-connect loop that I did with the BlueSmirf. It should be straight forward since I've already tested all the necessary AT commands successfully.

Edit 1: Get some tips about using HC-05 in this video I made
Edit 2: I have a new post describing the automatic bind of 2 HC-05 module without having to write code.