How do I change the name of my bluetooth module?

Have you noticed how interesting it is when we buy a device with Bluetooth and the signal is named with the name of the brand or device?

I speak of this, as I have always been curious to understand how it works and to name the module with the name of my own project.

It's simple, but it makes a difference in two points: identifying the module when pairing and customizing your prototype with the device name.

I imagine you have this problem or, at the very least, be curious to learn how to implement this functionality in your prototype module.

Although it is quite simple, I want to teach you how to do yours and not have any more problems.

To understand this configuration, you will learn the following points in this reading:

  • How to connect the Bluetooth module on Arduino;
  • What they are and how to use the AT commands in the configuration of the Bluetooth Module;
  • How to test if the communication between the Bluetooth module and the Arduino is working;
  • How to configure the speed;
  • How to change the name of the bluetooth device;
  • How to configure the password to access our bluetoooth module.

Wow! How much information I am willing to give you. Rest assured that everything is organized and I will deliver everything as simply as possible.

The Bluetooth Module with Arduino

I want to start by telling you about the importance of knowing the Bluetooth module and its connection process with the Arduino. When buying, you will find modules HC-05 and HC-06.

These are two modules widely used by the Arduino community. The main difference between these modules is that the HC-05 module can function as a master or slave.

Thus, the slave mode allows it to have a communication initiated by another device and the master mode allows the Bluetooth module to initiate communication with any other Bluetooth device.

Finally, the HC-06 Bluetooth module works only as a slave mode.

Now, I want to introduce you to the basic structure that you can use to communicate your Bluetooth module with your Arduino.

There are actually two ways, but I'll explain why that way is useful for your projects.

I chose to present you with this model in the Figure below, as we will use the TX and RX pins for serial communication. Therefore, they will be busy and we will not be able to share the same pins with Bluetooth communication.

To avoid this problem, we will use the SoftwareSerial library, to simulate other serial pins on ports 10 and 11 of the Arduino, as shown in the following Figure.

From the assembly diagram above, we will see how to configure our own device.

The configuration process using AT Commands

The term AT comes from the word ATtention. These commands are instructions used to operate the Bluetooth module. In this command structure, any and all instructions must begin with the prefix AT, such as AT + COMMAND.

Therefore, it will be through these commands that we will configure our Bluetooth Module. To know which commands to use, it is important that you access the datasheet of your Bluetooth module.

There you will find all the instructions available for configuring the module.

Now, I will start the configuration of the HC-06 module and provide the links to access the Bluetooth manuals HC-05 and HC-06.

Now, to configure the Bluetooth module, we need a code to send the AT commands.

The code to send the AT commands for the Bluetooth module

The code below is used to send the AT instructions via the Arduino serial and send them to the Bluetooth module.

#include <SoftwareSerial.h>


SoftwareSerial mySerial(10, 11); // RX, TX
String command = ""; // Stores response of bluetooth device
// which simply allows \n between each
// response.

void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(115200);
Serial.println("Type AT commands!");
// SoftwareSerial "com port" data...
Read more »