Arduino Bluetooth Example – Tutorial 1

In this tutorial, I will show you how easy it is to add bluetooth connectivity to your Arduino project. We will be using Fabric Shield from Hackabot Nano and HC-SR04 Bluetooth module here.

Fabric Shield:

fabric_shield_rev1_s

Bluetooth connector is located at the bottom edge of the Fabric Shield:

fabric_shield_WIFI_Bluetooth

HC 06 Bluetooth Module

HC 06 is a very popular bluetooth module for Arduino projects and it typically requires 3.3V. However, most of the Arduino boards operates at 5V. Fabric Shield takes care of the voltage conversion for you. All you need to do is to plug in the HC 06 bluetooth module into the designated connector.

“VCC” connects to “3V3”

“GND” connects to “GND”

“TXD” connects to “TX”

“RXD” connects to “RX”

hc06_bluetooth_modulepinout_of_hc06_bluetooth_module

arduino_nano_hc06_bluetooth_example

Programming

The following is the basic code. All it does is to set the baud rate on the serial port to 9600 and keeps increasing the counter every 3 seconds.

If you program your Arduino controller through USB, you need to unplug the bluetooth module first and put it back after programming.

int count;
void setup() {
  count=0;
  Serial.begin(9600);
}
void loop() {
  count++;
  Serial.println("Count = "+String(count));
  delay(3000);
}

Pairing your tablet or phone

Next step is to connect the power supply (ideally 7V-12V) to the Fabric Shield. If your HC06 bluetooth module blinks, it is a good sign because it is waiting to connect to other bluetooth devices.

In my case, I installed “Terminal For Bluetooth” app on my Nexus 7 Android tablet.

To pair your HC06 bluetooth module, you need to enter pairing password (typically 0000 or 1234).

Once they are paired, you may invoke the Android bluetooth terminal app and connect to Arduino.

You should see something like the followings:

android_arduino_hc06_bluetooth_terminal_example_small