Bluetooth Communication with HC-05

Bluetooth Communication with HC-05

Introduction

In this experiment, we will use the HC-05 Bluetooth module to establish wireless communication between an Arduino and another device, such as a smartphone or computer.

HC-05 Bluetooth Module

Components Needed

Circuit Setup

  1. Connect the VCC pin of the HC-05 module to the 5V pin of the Arduino.
  2. Connect the GND pin of the module to the GND pin of the Arduino.
  3. Connect the TXD pin of the HC-05 to the RX pin of the Arduino (pin 0).
  4. Connect the RXD pin of the HC-05 to the TX pin of the Arduino (pin 1).

Ensure proper wiring before powering the circuit.

HC-05 Circuit Setup

Code for Bluetooth Communication

Upload the following code to your Arduino to establish Bluetooth communication:


void setup() {
    Serial.begin(9600); // Start communication with HC-05
    Serial.println("HC-05 Bluetooth Test");
}
void loop() {
    if (Serial.available()) {
        char received = Serial.read(); // Read received data
        Serial.print("Received: ");
        Serial.println(received); // Echo back the received data
    }
}
            

Explanation

The HC-05 communicates with the Arduino using UART. The received data is printed to the Serial Monitor, and you can send data back to the connected device.

Troubleshooting