Bluetooth HC-05 with Arduino: Communicating width Smartphone




At tutorial Bluetooth HC-05 com Arduino: Comunicando com PC we learn how to control the LED on pin 13 of the BlackBoard from a computer using the Módulo Bluetooth HC-05. This time we will do the same thing, but now using a smartphone with Android instead of a computer.

Notice: The Bluetooth module HC-05 is not compatible with iOS systems.

In this tutorial we will learn:
  • Pair the Bluetooth module with your smartphone;
  • Control the LED on pin 13 via Bluetooth.
To do that, we will need:

Notice: The Bluetooth module HC-05 can be powered with 5V, but the RX/TX pins work with 3.3V: for this reason, is highly recommended the use of a Level Logic Converter: It will perform voltage adaptations (both 5V to 3.3V, as well as the reverse) for proper communication to occur.

Upload the following code on BlackBoard:

What this code basically does is turn on the LED connected to the Pin 13 of BlackBoard when it receives via Bluetooth the letter "H" and turn off When you receive the letter"L".

After uploading, if everything is correct, you should see the led on bluetooth module blinking quickly like in the below gif:


The module is ready to connect to another device.

Open the application, enable Bluetooth and click "Connect a device - Secure". Now just click on "Scan for devices" and choose the device called " HC-05 " (or the name that you have previously configured). By default, the factory pairing code is 1234, so simply enter the code and click OK.



You can change the name, password and other settings of your HC-05 module by following our tutorial Bluetooth HC-05: Configuring via Arduino.


After entering the code the connection will be established and the LED of the module will begin to flash slowly as the below gif indicates that it is ready to receive the data.



Now just send "H" to turn on the LED or "L" to turn off.