How to Use a Bluetooth Controller with Arduino

Featured Arduino Uno With Bluetooth Hc 05

Earlier we discussed that Arduino boards are extensible with shields and work across a wide range of IoT connectivity protocols. Bluetooth is one of the most important ones in this regard.

There are several reasons why developers like to use Bluetooth in IoT projects. It is cheap, wireless, automatic and seamlessly connects with smartphones, tablets, PCs and even gaming controllers.

You can easily connect an Arduino board with a Bluetooth app on your smartphone. Alternatively, you can connect it with a Bluetooth dongle on your PC using a sketch on Arduino software. In this article we discuss simple ways to work both these techniques.

What Do You Need?

The following components are needed in this project.

  • Board: Arduino Uno
  • Breadboard: for conjunction of Uno with Bluetooth module
  • Power supply: from a PC’s USB connection or external AC/DC adapter or battery
  • Wires: 4 to 6 wires
  • Bluetooth control app: we will use BlueControl – Arduino + JY-MCU
  • Bluetooth module: wireless Bluetooth RF Transceiver Module for HC-05 or HC-06; we will use 4-pin modules in this case, not 6.
Hc 05 6 Pin Or 4 Pin Modules

Connecting with Mobile App

The following is a simple procedure to control a Bluetooth device on a smartphone. First, you need to arrange the wires so that they connect with each other across a breadboard as shown in the diagram.

Arduino Bluetooth Module Configurations Pins

The Vcc of Bluetooth module goes to the 5V connection in Uno. Similarly, the ground goes to the ground, The Tx, or transmit pin, goes to Rx in Uno or pin number 0. The Rx of Bluetooth goes to Tx of Uno or pin number 1.

Ideally, the 5V voltage may be too high for the Bluetooth component, so you might further need a couple of 10 ohm resistors to divide the voltage.

As soon as you connect the power supply, the Bluetooth LED should start blinking. This means there is no Bluetooth pairing at the moment. You need to create one to have better control over the device/project.

Bluetooth Led Blinking

To affect the pairing, we need to first download BlueControl, the Bluetooth-controlling app discussed earlier.

Bluecontrol App

In the next step, you must allow your smartphone to turn Bluetooth on.

Bluetooth Turn On Bluecontrol App

Select HC-06 as your paired Bluetooth module to be controlled by the app.

Search And Pair With Bluetooth Module

Using the app itself, you can now turn the Bluetooth LED on or off as necessary.

Bluecontrol Led On Off

Connecting with PC/Mac

To connect the Bluetooth module with PC/Mac, you must connect the USB cable to Uno’s power supply unit, then simply open the Arduino software and ensure the connection is available.

Arduino Board Uno Connect

In the next step, you need to load the Bluetooth control program onto the Arduino board. A tech blogger, Dotslashnotes, has shared the code to be used at this link.

After copy-pasting the 128-line code, you have to upload the program in the Arduino software. This code has two buttons to turn the Bluetoooth LED ON or OFF.

Upload Program Arduino

Of course, the above code is just one of the ways to do it.

DISCLAIMER: I haven’t tried it myself, but the code does look elegantly simple.

If this doesn’t work for you, then you need to find a code online which will support your PC/Mac connectivity. Arduino Forum is one of the best places to look for help and support on this and many other Arduino topics.

Summary

Arduino is one of the cheapest boards to experiment with IoT projects. As an alternative to Raspberry Pi, it supports Bluetooth among many other protocols to create a broad variety of IoT projects.

Have you worked with Bluetooth in Arduino or any other IoT projects? We’d love to hear your experience in the comments below.

Image credit: Rajib Ghosh

Subscribe to our newsletter!

Get the best of IoT Tech Trends delivered right to your inbox!

Sayak Boral

IoT-addicted since early 2016. Love to explore the challenges, opportunities and trend insights into what is becoming the third wave of Internet.