0
0
AutocadHow-ToBeginner · 3 min read

How to Use Bluetooth Module HC05 with Arduino: Simple Guide

To use the HC05 Bluetooth module with an Arduino, connect the module's TX and RX pins to Arduino's RX and TX pins (crossed), power it with 5V and GND, and use Serial commands to send and receive data wirelessly. You can control the module via the Arduino's serial interface using Serial.begin() and Serial.read() or Serial.write() functions.
📐

Syntax

To communicate with the HC05 module, use Arduino's Serial functions. The basic syntax includes:

  • Serial.begin(baudRate); - starts serial communication at the specified baud rate (usually 9600 for HC05).
  • Serial.read(); - reads incoming data from the HC05.
  • Serial.write(data); or Serial.print(data); - sends data to the HC05.

Remember to cross-connect the HC05's TX to Arduino RX and HC05 RX to Arduino TX pins.

arduino
void setup() {
  Serial.begin(9600); // Start serial communication at 9600 baud
}

void loop() {
  if (Serial.available()) {
    char data = Serial.read(); // Read data from HC05
    Serial.print("Received: ");
    Serial.println(data); // Print received data
  }
}
💻

Example

This example reads data sent from a paired Bluetooth device to the HC05 and echoes it back. It demonstrates basic wireless serial communication.

arduino
void setup() {
  Serial.begin(9600); // Initialize serial communication
  Serial.println("HC05 Bluetooth Module Ready");
}

void loop() {
  if (Serial.available()) {
    char incomingChar = Serial.read();
    Serial.print("Echo: ");
    Serial.println(incomingChar);
  }
}
Output
HC05 Bluetooth Module Ready Echo: A Echo: B Echo: C
⚠️

Common Pitfalls

  • Incorrect wiring: Not crossing TX and RX pins will prevent communication.
  • Power issues: HC05 requires 5V and GND; insufficient power causes malfunction.
  • Baud rate mismatch: Ensure Arduino and HC05 use the same baud rate (usually 9600).
  • Using Serial pins for other purposes: On some Arduino boards, pins 0 and 1 are used for USB communication; using SoftwareSerial on other pins can help.
arduino
/* Wrong wiring example (TX to TX, RX to RX) - will not work */
// HC05 TX -> Arduino TX
// HC05 RX -> Arduino RX

/* Correct wiring example (crossed) */
// HC05 TX -> Arduino RX
// HC05 RX -> Arduino TX
📊

Quick Reference

HC05 PinArduino PinDescription
VCC5VPower supply for HC05
GNDGNDGround connection
TXDArduino RX (Pin 0 or SoftwareSerial RX)Transmit data from HC05 to Arduino
RXDArduino TX (Pin 1 or SoftwareSerial TX)Receive data from Arduino to HC05
STATEOptionalIndicates connection status

Key Takeaways

Connect HC05 TX to Arduino RX and HC05 RX to Arduino TX for proper communication.
Use Serial.begin(9600) to match the HC05 default baud rate.
Power the HC05 with 5V and GND to ensure stable operation.
Check wiring and baud rate if communication fails.
Use SoftwareSerial library if you want to keep Arduino's main serial port free.