Introduction to ESP32 Bluetooth
ESP32 is a low cost and power conserving microcontroller board that has both Bluetooth classic and Bluetooth low energy. Like Arduino in ESP32 we don’t need any external Bluetooth sensor such as HC-05.
ESP32 has a built-in Bluetooth module that can be configured in both modes (BLE and Classic).
Here is a detailed description on both these ESP32 Bluetooth modes:
Now we have some knowledge related to ESP32 Bluetooth. Let’s configure ESP32 Bluetooth and change its name later.
Configure ESP32 Bluetooth
To configure ESP32 Bluetooth we have to include the Bluetooth serial library. Using this library ESP32 Bluetooth can be turned ON.
Open Arduino IDE upload given code in ESP32 board:
This code started by including the Bluetooth serial library file. After that Bluetooth connection is established with the name of ESP32 BT.
BluetoothSerial SerialBT;
void setup() {
SerialBT.begin("ESP32 BT");
}
void loop() {
}
As Bluetooth connection is established now we will connect ESP32 Bluetooth with any of the devices such as PC or smartphone.
Connecting ESP32 Bluetooth with PC
As ESP32 Bluetooth is configured follow the steps to connect ESP32 Bluetooth with PC.
Step 1: Open Bluetooth and other devices settings in Windows:
Step 2: Click Add a Bluetooth or other device:
Step 3: Select Bluetooth device:
Step 4: Click ESP32 BT. Here you will see any name of ESP32 which you defined inside the Arduino code.
Step 5: Once the ESP32 Bluetooth is successfully connected below a message will appear:
We have successfully connected our PC with ESP32 Bluetooth.
Changing ESP32 Bluetooth Name
Now to change ESP32 Bluetooth we will use the same code as described earlier. Now replace any other name in the SerialBT.begin() command.
Here we have changed the ESP32 name from ESP32 BT to Espressif ESP32.
Upload given code to assign a new name to ESP32 Bluetooth.
BluetoothSerial SerialBT;
void setup() {
SerialBT.begin("Espressif ESP32 ");
}
void loop() {
}
Now by following the same steps mentioned earlier connect ESP32 with PC. Here we can see the updated name of ESP32 Bluetooth on the list.
We have successfully changed the ESP32 Bluetooth name.
Conclusion
ESP32 comes with Bluetooth support and sometimes we are working with multiple ESPs Bluetooth inside a single project so different Bluetooth names must be given to each board so they can be identified easily. This article covers all steps needed to change ESP32 Bluetooth.