Arduino Bluetooth with HC-06

This post describes the HC-06 Bluetooth module and shows a simple app to turn on and off a lamp with an Arduino board.

HC-06

HC-06 is a cheap Bluetooth module that supports SPP (Serial Port Profile), which allows the establishment of an emulated serial connection using Bluetooth. This connections is transparent for the microcontroller, since the module handles all the Bluetooth protocol details. So, we just send the data the same way we would do if we were directly communicating with a computer using a USB cable, for example.

This device has a maximum range of 10 meters and works only as a slave in the Bluetooth protocol [1]. It operates at 3.3 V and has a current consumption of 30-40 mA during the pairing procedure and of 8 mA during communication [2].

It supports communication rates to 1382400 Baud [1] and can be configured with AT commands, which can only be sent before the device pairs with the other communication entity. Those commands include configuring the communication rate, the name of the device and the pairing PIN [1].

The HC-06 can be bought already soldered in a baseboard, as shown in figure 1. This board has the pins easily accessible and supports a 5 V supply voltage. Of course that, by adding more components, the current consumption is a little bit higher that previously specified. It is available at eBay for less than 3.5 euros.

arduino bt

Figure 1 – HC-06 with baseboard.

Turning on and off lamps

In the example shown in the video, the Arduino board is connected to the HC-06 in order to receive data from a computer through Bluetooth. We used the Arduino IDE serial monitor to demonstrate that the communication is transparent once the pairing between the computer and the module is done.

The Arduino is also connected to a cheap 5 V relay, which controls the lamp. Whenever the a letter “t” is sent from the computer, the Arduino board toggles the relay state.

This is just a quick example to illustrate the potential of the module. It can also be connected to an Android smartphone, which would be much more user friendly to a home automation application. You can also check this post were I used the HC-06 to implement the Bluetooth communication of a prototype of a smart medication dispenser.

Important: Sending raw bytes to implement communication is not a good practice, specially in wireless protocols. This was done only to make a quick proof of concept. Check this post for a more robust way of doing it.

 

References

[1] http://wiki.pinguino.cc/index.php/SPP_Bluetooth_Modules
[2] http://www.electronicoscaldas.com/datasheet/HC-06_Wavesen.pdf

Advertisements
This entry was posted in Electronics, Microcontrollers and tagged , , , . Bookmark the permalink.

One Response to Arduino Bluetooth with HC-06

  1. Pingback: Toggling a LED with Arduino and HC-06 | techtutorialsx

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s