How to Change Arduino Bluetooth Name [If You Are Using HC05 Module]
Once in a while, I have an idea to create something using Arduino that is connected to my Android phone via Bluetooth connection. The reason I’m connecting my Arduino project to my phone as much as possible is that my phone can serve as a display, data logger, and user interface for my Arduino device.
This will eliminate or reduce the needs for buttons, storage, and display to be builtin into my Arduino board which will result in a more compact device.
Like right now, I have the need to create a simple portable system that I can use to manage my electronic components inventory. So I come up with a portable RFID reader which basic I have described in the previous post and connected to my Android phone via Bluetooth.
My Android phone runs a custom app that serves as the display for the RFID reader and database for my inventory management system. This app is essentially a simple Bluetooth app that has been expanded with a cloud database and some other functions like the search function and RFID check function.
You can learn how to create your own Bluetooth app that can talk with your Arduino project on Udemy. It will teach you how to create the app from scratch even if you don’t have prior Android programming knowledge.
Now, I want to put my Arduino based RFID reader into a semi-permanent electronic enclosure, but before that, I have a problem that I need to solve.
I have several HC05 Bluetooth modules laying around on my workbench to be used in various Arduino projects. All these modules have been paired with my Android phone which consequently creates a problem. All these modules have the same device names shown on my phone i.e. HC05 with the difference is only with the MAC Address.
Because of this, connecting to an HC05 module becomes a trial and error process.
After doing some research, I finally figured out how to change the default device name of an HC05 which I will explain below.
But before that, some disclaimers:
I am using a clone Arduino board and an HC05 module of unknown Chinese manufacturers. Since the quality may vary between manufacturers, the tutorial below may or may not work for you.
To change the default device name, you need to access the AT Command mode for HC05 and for that we just need a few components:
- HC05 module which name you want to change
- 5 jumper cables
- Arduino UNO or Mega ADK
Uploading Arduino Code
Before start connecting HC05 to the board, we should upload the code that will give access to AT command mode first. Just copy-paste the code below to Arduino IDE
Once the code is successfully uploaded, disconnect the board from your computer.
Locating the KEY Pin
This is the tricky part. You need to connect the KEY pin on the HC05 module into the Arduino board, however, this pin is not located on one of HC05 terminal legs. The KEY pin is the topmost metal surface on the right side of HC05 (see picture)
I am using my jumper cable to connect the KEY pin to the Arduino, like in this picture :
Connecting All the Components
Once you’ve located the KEY pin, we can start connecting HC05 to the Arduino board like in the diagram below.
Note : This connection is the one that works for me. If this doesn’t work for you, you might want to try connect VCC to 5V instead of Vin (see the disclaimer above).
Accessing AT Command Mode
Follow these steps to get to the AT Command mode :
- Disconnect +5V from HC05
- Connect Arduino to your computer
- Reconnect +5V to HC05
- The LED on HC05 should be blinking slowly now. If it is not blinking, it is blinking fast or if it is turned off, you should check the wiring and connection to KEY pin (i.e. make sure the jumper cable touches the metal surface)
- Next, open the serial monitor on Android IDE. On the bottom part of the serial monitor, select “Both NL & CR” and set the baud rate to 9600.
- To check if everything is connected properly, type “AT” (without the quote) on the input line, and the response should be “OK”, otherwise recheck the wiring.
Renaming HC05 Module
And finally, to change the default device name, type the following command to the serial monitor :
AT+NAME=<new device name>
If everything is correct, then the response should be “OK”.
Now, when I scan and pair my HC05 devices, some of the names have changed and I can find the device I want easily.