5% off all items, 10% off clearance with code FESTIVE

Free Shipping for orders over ₹999

support@thinkrobotics.com | +91 8065427666

How to Connect Arduino to Bluetooth Module: Step-by-Step Guide

How to Connect Arduino to Bluetooth Module: Step-by-Step Guide

Adding Bluetooth connectivity to your Arduino projects opens up wireless control possibilities, from smartphone-operated robots to remote sensor monitoring. Learning how to connect Arduino to Bluetooth module is simpler than it looks, requiring just a few connections and basic code.

This complete guide walks through connecting the popular HC-05 and HC-06 Bluetooth modules to Arduino, covers wiring, programming, testing, and troubleshooting to get your wireless projects working reliably.

Understanding Arduino Bluetooth Modules

Before connecting hardware, understanding what Bluetooth modules do and which to choose helps ensure project success.

What Bluetooth Modules Do

Bluetooth modules create wireless serial communication between Arduino and other devices like smartphones, tablets, or computers. They replace physical USB cables or wired serial connections with wireless links operating over 10 to 100 meter ranges depending on module and environment.

From Arduino's perspective, Bluetooth modules work like wireless serial ports. You send data to the module using serial communication, and it transmits wirelessly. Received data comes through serial interface just like wired connections.

HC-05 vs HC-06 Modules

HC-05 modules operate in both master and slave modes. Master mode initiates connections to other Bluetooth devices. Slave mode waits for connections from phones or computers. This versatility makes HC-05 suitable for robot-to-robot communication or connecting to Bluetooth devices beyond just phones. HC-05 costs $5 to $10.

HC-06 modules work only in slave mode, accepting connections from master devices like smartphones. For most Arduino projects controlled via phone apps, HC-06's slave-only mode suffices. HC-06 typically costs $3 to $8, slightly less than HC-05.

Both modules support Bluetooth 2.0 with Serial Port Profile (SPP), enabling simple serial data transmission. Configuration happens through AT commands sent over serial connection.

Voltage Considerations

Most Bluetooth modules operate at 3.3V logic levels while Arduino Uno uses 5V logic. Direct connection of Arduino 5V TX pin to Bluetooth RX pin can damage the module over time. Voltage dividers or level shifters protect the module.

Some Bluetooth module breakout boards include built-in voltage regulation and level shifting, accepting 5V power and handling voltage conversion automatically. Check your specific module specifications.

Think Robotics provides Bluetooth modules with clear voltage specifications and wiring guidance, ensuring safe connections for educational projects.

Required Components

Gather these components before starting:

  • Arduino Uno or compatible board
  • HC-05 or HC-06 Bluetooth module
  • Jumper wires (male-to-female or male-to-male depending on module)
  • Breadboard (optional but helpful)
  • Resistors for voltage divider: 1kΩ and 2kΩ (if module lacks level shifting)
  • Smartphone or computer with Bluetooth capability
  • Bluetooth terminal app (Serial Bluetooth Terminal for Android, Bluetooth Terminal for iOS)

Wiring Arduino to Bluetooth Module

Proper wiring ensures reliable communication and prevents component damage.

Basic Wiring Diagram

The simplest connection uses Arduino's hardware serial pins (TX and RX), though this interferes with USB programming. Software serial on different pins provides more flexibility.

Using Software Serial (Recommended):

HC-05/HC-06 Module → Arduino Uno

  • VCC → 5V (if module has voltage regulator) or 3.3V
  • GND → GND
  • TXD → Digital Pin 10 (Arduino RX)
  • RXD → Digital Pin 11 (Arduino TX) through voltage divider

Voltage Divider for RXD Protection:

If your module lacks level shifting, protect the Bluetooth RX pin with a simple voltage divider:

  • Arduino Pin 11 → 1kΩ resistor → Bluetooth RXD
  • Bluetooth RXD → 2kΩ resistor → GND

This divider reduces Arduino's 5V output to approximately 3.3V safe for the Bluetooth module.

Step-by-Step Wiring Process

Step 1: Connect Bluetooth module VCC to Arduino 5V pin. If your module specifies 3.3V only, connect to Arduino 3.3V pin instead.

Step 2: Connect Bluetooth module GND to Arduino GND.

Step 3: Connect Bluetooth TXD (transmit) to Arduino digital pin 10. This becomes the receive pin for software serial.

Step 4: Connect Arduino digital pin 11 through the voltage divider to Bluetooth RXD (receive). Or, if your module has built-in level shifting, connect directly.

Step 5: Double-check all connections before applying power. Incorrect wiring can damage components.

Some HC-05 modules include a small button or KEY pin for entering AT command mode. You typically don't need this for basic operation.

Think Robotics provides pre-wired Bluetooth modules and connection guides simplifying the wiring process for beginners.

Programming Arduino for Bluetooth Communication

With hardware connected, Arduino code establishes serial communication with the Bluetooth module.

Basic Software Serial Setup

cpp
#include <SoftwareSerial.h>

// Define software serial pins
// Pin 10 = RX (connect to Bluetooth TX)
// Pin 11 = TX (connect to Bluetooth RX)
SoftwareSerial BTSerial(10, 11);

void setup() {
  // Start hardware serial for debugging
  Serial.begin(9600);
  
  // Start software serial for Bluetooth
  BTSerial.begin(9600);
  
  Serial.println("Bluetooth Ready");
}

void loop() {
  // Forward data from Bluetooth to Serial Monitor
  if (BTSerial.available()) {
    char c = BTSerial.read();
    Serial.write(c);
  }
  
  // Forward data from Serial Monitor to Bluetooth
  if (Serial.available()) {
    char c = Serial.read();
    BTSerial.write(c);
  }
}

This basic code creates a bridge between USB serial (Serial Monitor) and Bluetooth serial. Characters typed in Serial Monitor send via Bluetooth, and received Bluetooth data appears in Serial Monitor.

Controlling an LED via Bluetooth

Here's practical code controlling Arduino's built-in LED:

cpp
#include <SoftwareSerial.h>

SoftwareSerial BTSerial(10, 11);

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(9600);
  BTSerial.begin(9600);
  Serial.println("LED Control Ready");
}

void loop() {
  if (BTSerial.available()) {
    char command = BTSerial.read();
    
    if (command == '1') {
      digitalWrite(LED_BUILTIN, HIGH);
      BTSerial.println("LED ON");
    }
    else if (command == '0') {
      digitalWrite(LED_BUILTIN, LOW);
      BTSerial.println("LED OFF");
    }
  }
}

Send '1' via Bluetooth to turn the LED on, '0' to turn it off. The module sends confirmation messages back.

Sending Sensor Data via Bluetooth

Transmitting sensor readings wirelessly:

cpp
#include <SoftwareSerial.h>

SoftwareSerial BTSerial(10, 11);

void setup() {
  BTSerial.begin(9600);
  pinMode(A0, INPUT);
}

void loop() {
  int sensorValue = analogRead(A0);
  
  BTSerial.print("Sensor: ");
  BTSerial.println(sensorValue);
  
  delay(1000); // Send reading every second
}

This code reads analog pin A0 and transmits values via Bluetooth every second.

Pairing and Testing the Connection

With code uploaded, test the Bluetooth connection.

Pairing the Module

Step 1: Power your Arduino. The Bluetooth module LED should blink rapidly, indicating it's discoverable and ready to pair.

Step 2: On your smartphone, enable Bluetooth and scan for devices. The module appears as "HC-05" or "HC-06" (or similar name).

Step 3: Select the device to pair. The default pairing PIN is usually "1234" or "0000". Check your module documentation if these don't work.

Step 4: Once paired, the module LED typically changes from rapid blinking to slow blinking or steady on, depending on the module.

Using Bluetooth Terminal Apps

For Android: Install "Serial Bluetooth Terminal" from Google Play Store. Open the app, connect to your paired HC-05/HC-06 device, and you can send and receive text data.

For iOS: Install "Bluetooth Terminal" or similar app. iOS Bluetooth support for SPP profiles varies, so check app compatibility.

Testing Communication

With the basic bridge code uploaded, open both Arduino Serial Monitor and your Bluetooth terminal app:

Test 1: Type text in Serial Monitor. It should appear in the Bluetooth terminal app.

Test 2: Type text in the Bluetooth terminal app. It should appear in Serial Monitor.

If both directions work, your connection succeeds.

For the LED control code, send '1' from the terminal app to turn the LED on, '0' to turn it off. You should see the LED respond and receive confirmation messages.

Common Connection Problems and Solutions

Troubleshooting helps resolve typical issues.

No Communication or Garbage Characters

Problem: Serial Monitor shows random characters or nothing appears.

Solution: Check baud rates match everywhere. Both Serial.begin() and BTSerial.begin() should use 9600 (or whatever your module's default is). Some modules use 38400 or other rates. Serial Monitor baud rate must also match.

Module Won't Pair

Problem: Bluetooth module doesn't appear in device scans.

Solution: Verify power connections. The module LED should blink. Check VCC voltage is correct (5V or 3.3V as required). Some modules need correct power sequencing or have enable pins.

One-Way Communication Works

Problem: Can send TO Arduino but not receive FROM Arduino, or vice versa.

Solution: Verify TX/RX connections aren't swapped. Bluetooth TX connects to Arduino RX (pin 10 in software serial), Bluetooth RX connects to Arduino TX (pin 11). Check voltage divider is correct if used.

Module Damaged by Overvoltage

Problem: Module worked initially but now fails.

Solution: If 5V signals were applied directly to 3.3V RXD pin without protection, the module may be damaged. Replace the module and use proper voltage divider or level shifter.

Intermittent Disconnections

Problem: Connection works but drops randomly.

Solution: Check power supply provides adequate current. Ensure wiring connections are secure. Reduce distance between Arduino and phone. Remove sources of electromagnetic interference.

Think Robotics provides technical support and troubleshooting guidance helping you resolve connection issues quickly.

Advanced Bluetooth Features

Once basic communication works, explore advanced capabilities.

Changing Module Settings via AT Commands

HC-05 and HC-06 modules accept AT commands for configuration including changing name, PIN, baud rate, or other settings.

Enter AT command mode by connecting module before powering on (for HC-05, hold KEY pin HIGH during power-up). Send commands like:

  • AT (test communication)
  • AT+NAME=MyRobot (change device name)
  • AT+PSWD=5678 (change PIN)
  • AT+UART=115200,0,0 (change baud rate)

Building Bluetooth-Controlled Robots

Apply Bluetooth communication to robot control:

Direction Control: Send commands 'F' (forward), 'B' (backward), 'L' (left), 'R' (right), 'S' (stop).

Speed Control: Send numeric values adjusting motor speed.

Sensor Monitoring: Stream distance sensor, temperature, or other readings to smartphone displays.

Creating Custom Smartphone Apps

For advanced projects, create custom Android apps using MIT App Inventor or Android Studio that send specific commands and display formatted sensor data.

Security Considerations

Bluetooth connections have security implications.

Change Default PIN

Default PINs like "1234" provide minimal security. Change to unique PINs via AT commands to prevent unauthorized connections.

Limit Range

Bluetooth range typically reaches 10-30 meters. For security-sensitive applications, this limits who can connect. Indoor obstacles reduce range further.

Implement Command Authentication

For critical applications, implement password or authentication in Arduino code, requiring correct codes before executing commands.

Conclusion

Connecting Arduino to Bluetooth module enables wireless control and communication for countless projects. The process requires just a few wires connecting VCC, GND, TX, and RX pins, with voltage protection for 3.3V modules. Software serial library provides simple programming interface for sending and receiving data.

HC-05 and HC-06 modules offer affordable, reliable Bluetooth connectivity costing just $3 to $10. Whether building smartphone-controlled robots, wireless sensors, or remote monitoring systems, Bluetooth adds valuable functionality without complex setup.

Start with basic communication testing before adding project-specific features. Once the connection works reliably, expand into LED control, motor control, sensor monitoring, or custom applications. The wireless freedom Bluetooth provides opens new possibilities for interactive, portable Arduino projects.

Post a comment

Frequently Asked Questions Frequently Asked Questions

Frequently Asked Questions

How do I connect HC-05 Bluetooth module to Arduino Uno?

Connect HC-05 VCC to Arduino 5V, GND to GND, TXD to Arduino digital pin 10, and RXD to pin 11 through a voltage divider (1kΩ from pin 11 to RXD, 2kΩ from RXD to GND). Use SoftwareSerial library in code with SoftwareSerial BTSerial(10, 11) and BTSerial.begin(9600) for communication. Pair with smartphone using default PIN "1234".

Do I need voltage divider for Arduino Bluetooth connection?

Yes, if your Bluetooth module operates at 3.3V logic and lacks built-in level shifting. Arduino Uno outputs 5V on TX pin which can damage 3.3V Bluetooth RX input. Use voltage divider (1kΩ and 2kΩ resistors) or level shifter to reduce voltage to safe 3.3V. Some modules include voltage regulation and don't need external dividers.

What is the default baud rate for HC-05 Bluetooth module?

HC-05 modules typically default to 9600 or 38400 baud rate. Check your specific module documentation. Set Arduino software serial to match using BTSerial.begin(9600) or BTSerial.begin(38400). Mismatched baud rates cause garbled communication. You can change module baud rate using AT commands if needed.

Can I use Arduino hardware serial pins for Bluetooth?

Yes, but it interferes with USB programming since hardware serial (pins 0 and 1) connects to USB. You must disconnect Bluetooth RX from pin 0 before uploading code. Software serial on other pins (like 10 and 11) avoids this conflict and is recommended for most projects.

How do I control Arduino with smartphone via Bluetooth?

Connect Bluetooth module to Arduino, upload code reading serial data from the module, pair smartphone with module, install Bluetooth terminal app on phone, and send character commands the Arduino code recognizes. For example, send '1' to turn LED on, '0' to turn off. Build command processing into Arduino code for your specific application.