Setting up Bluetooth HC-05 with Arduino
Even though Bluetooth Low Energy Modules available at a reasonable cost, most of these modules are not compatible with existing devices that support the classic Bluetooth. The HC-05 is an expensive module that is compatible with wide range of devices including smartphone, laptops and tablets. Adding a Bluetooth to Arduino can take your project to the next level. It opens up lots of possibilities for user interface (UI) and communication. The phone/tablet etc can act as an UI element or data logger and interpreter for your next project.
So let's get started , in the first part we will simply look at how easy it use the module with Arduino and transfer data to a Smart Phone. Later we will look at various configurations the HC-05 module like the device name, pass-code, modes of operations and all of that with the help of AT commands.Later we will also look at pairing to Bluetooth modules, configuring one as Master and other as Slave. You need not configure the module, if you simple want to use it.
Contents
HC-05 Basics
Simple Data Transfer Example
Hookup
Code
#include <SoftwareSerial.h> SoftwareSerial EEBlue(10, 11); // RX | TX void setup() { Serial.begin(9600); EEBlue.begin(9600); //Default Baud for comm, it may be different for your Module. Serial.println("The bluetooth gates are open.\n Connect to HC-05 from any other bluetooth device with 1234 as pairing key!."); } void loop() { // Feed any data from bluetooth to Terminal. if (EEBlue.available()) Serial.write(EEBlue.read()); // Feed all data from termial to bluetooth if (Serial.available()) EEBlue.write(Serial.read()); }
Demo
There are numerous Android apps to connect your phone the blue-tooth Module. I used the Bluetooth Terminal to connect it to the HC-05.
The output as seen on the Arduino Terminal. This way we have established a blue-tooth link to send messages form the phone to the Arduino with HC-05.