Bluetooth is a wireless technology that allows two devices to communicate with each other. It can be used to connect a variety of devices, including phones, computers, and headphones.
In this tutorial we will use the HC-05 Bluetooth module to send data to the Arduino via your smartphone. This data will be used to control the Arduino’s built-in LED on and off.
Connect the wires between the Bluetooth module and the Arduino, as shown in the image below.
Connections from the Bluetooth to the Arduino:
• Bluetooth VCC pin → Arduino 5V pin
• Bluetooth GND pin → Arduino GND pin
• Bluetooth TX pin → Arduino pin 0 (RX)
• Bluetooth RX pin → Arduino pin 1 (TX)
Now you must have correctly wired the Bluetooth to the Arduino as we explained in the wiring section, as well as uploaded the code to your Arduino board.
For the next step, you need to download an app that allows you to send data via Bluetooth to your Arduino through a terminal.
The app is available to download from Google Play store for free. You can download it from here!
Unfortunately, the HC-05 doesn’t work with the iPhone. For the iPhone, you need to use the BLE 4.0 Bluetooth module. It works exactly the same.
After installing the app on your smartphone, simply open it. The app will ask you to provide it with access to your phone’s Bluetooth, which you must do.
The app will ask you to choose the Bluetooth name, which will be HC-05 by default. If it asks you to enter a password, try 1234 or 0000 as the password.
The connection to the HC-05 Bluetooth module will take a while.
Now look at the HC-05’s built-in LED. If it is blinking fast, it means there is no connection, but if it is blinking every 5 seconds, it means the Bluetooth is connected successfully to your phone.
The app is very simple and has a user-friendly interface. It may be used in many applications. For this tutorial, we will just use the
terminal indicated by the arrow in the next image.
After opening the terminal, it will allow you to send commands to your Arduino over the Bluetooth connection. It is as simple as chatting with your friend. Let’s chat with your Arduino!
As you see in the previous image, when you send the character ‘o’ to your Arduino, the LED is turned on, but if you send the character ‘f’, the LED is turned off.
You can develop this code to have more functionality, like controlling an RGB strip or even a robot!
Now access the serial monitor on your Arduino IDE by clicking on the magnifying glass icon at the top right corner.
The serial monitor will also print the status of the LED according to the data it receives.