I'm trying to connect an ESP32 (as Bluetooth master) to an Arduino Uno that has an HC-05 Bluetooth module attached. My goal is to send serial data between the ESP32 and the Uno.
Setup:
- Arduino Uno connected to HC-05 using SoftwareSerial (pins 13 = RX, 12 = TX).
- HC-05 is in slave mode (
AT+ROLE=0). - Baud rate reported by
AT+UART?is9600.
`
Arduino Uno code:
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(13, 12); // RX, TX
void setup() {
Serial.begin(9600);
BTSerial.begin(9600);
Serial.println("Arduino ready");
}
void loop() {
if (BTSerial.available()) {
char data = BTSerial.read();
Serial.print("Received from ESP32: ");
Serial.println(data);
}
if (Serial.available()) {
char data = Serial.read();
BTSerial.print(data);
}
}
I used the example sketches from the BluetoothSerial library, "SerialToSerialBTM (ESP32 acting as master)".
I also tried the discover/connect example.
Both examples can see the HC-05 in the scan, but:
When I try to connect, the connection either fails immediately or disconnects after 1–2 seconds.
I never get stable communication, and no data shows up in the Serial Monitor.
What I tried:
- Confirmed HC-05 is in slave mode (AT+ROLE=0).
- Verified baud rate with AT+UART? → 9600 and used this in Uno + ESP32 code.
- Tested multiple baud rates (9600, 38400).
- Used both SerialBT.connect("98:D3:xx:xx:xx:xx") with the HC-05 MAC address and device name.
Sometimes the HC-05 LED shows a brief connection, but it never stays stable.
Question:
Why can't the ESP32 maintain a stable Bluetooth connection with the HC-05?
Do I need to change the HC-05 role or baud rate to make this work?
Is there a recommended example or configuration for reliable serial communication between ESP32 (master) and HC-05 (slave)?