Table of Contents
Introduction
Imagine controlling devices or logging sensor data wirelessly through your smartphone. By connecting an Arduino Uno to an Android device via Bluetooth, you can unlock exciting IoT possibilities! In this article, we’ll guide you through 7 simple steps, complete with troubleshooting tips, to make the process effortless. Let’s dive in!
Get started with building your first robot in our detailed guide on Building a Robot with Arduino.
Tools and Components Required
To start, gather the following components:
- Arduino Uno (or similar board)
- HC-05 Bluetooth module
- Android smartphone
- Jumper wires (Male-to-Male and Male-to-Female)
- Breadboard (optional for prototyping)
- LED
- 1kΩ and 2kΩ resistors (for voltage divider)
Learn about different types of resistors in our article Resistor Basics: A Beginner’s Guide to Types, Functions, and Applications?
Step 1: Wiring and Setup
Follow these steps to connect the HC-05 Bluetooth module to your Arduino Uno:
- Connect the Bluetooth Module:
- VCC pin of HC-05 to the 5V pin of Arduino.
- GND pin of HC-05 to the GND pin of Arduino.
- TX pin of HC-05 to a voltage divider circuit (comprising 1kΩ and 2kΩ resistors), then to the RX pin of Arduino.
- RX pin of HC-05 directly to the TX pin of Arduino.
- Add an LED for Testing:
- Connect one leg of the LED to a 1kΩ resistor, and the other leg to Arduino pin 13.
- Connect the resistor’s free end to the GND.
Step 2: Configuring the HC-05 Module
For proper communication, configure the HC-05 module using AT commands:
- Upload an empty sketch to Arduino.
- Power the HC-05 module and enter AT mode (indicated by a slow blinking LED).
- Open the Serial Monitor in the Arduino IDE.
- Type commands like
AT+NAME=MyDevice
to rename the module orAT+BAUD4
to set baud rate to 9600.
Troubleshooting Tip: Ensure the module is in AT mode by pressing and holding the button on the HC-05 while powering it on.
Step 3: Writing the Arduino Code
Upload the following code to enable Bluetooth communication and LED control:
include
SoftwareSerial BTSerial(10, 11); // RX, TX
void setup() {
Serial.begin(9600);
BTSerial.begin(9600);
pinMode(13, OUTPUT);
Serial.println(“Bluetooth Ready!”);
}
void loop() {
if (BTSerial.available()) {
char data = BTSerial.read();
Serial.println(data);
if (data == ‘1’) {
digitalWrite(13, HIGH); // Turn LED ON
} else if (data == ‘0’) {
digitalWrite(13, LOW); // Turn LED OFF
}
}
}
Step 4: Pairing Android with Arduino
On your Android device:
- Enable Bluetooth and search for devices.
- Select your HC-05 module and pair it using the default PIN (1234).
- Use a terminal app like “Bluetooth Terminal” to test the connection by sending commands such as
1
(to turn the LED ON) or0
(to turn it OFF).
Step 5: Sending and Receiving Data
Test the interactive example:
- Open the terminal app on your Android device.
- Send
1
to turn the LED ON or0
to turn it OFF. - Observe the LED behavior on the Arduino setup.
Step 6: Troubleshooting Common Issues
Here are solutions to frequent problems:
- Bluetooth Module Not Detected: Check wiring and ensure the module is powered.
- Incorrect Data Transmission: Verify baud rates match on Arduino and HC-05.
- LED Not Responding: Double-check the wiring and ensure the LED is connected to the correct pin.
Step 7: Applications and Use Cases
Here are practical applications for Arduino and Android Bluetooth communication:
- Home automation projects.
- Remote-controlled robots.
- Real-time sensor data visualization.
Table required: Comparison of popular Bluetooth modules.
Module | Voltage | Range | Ease of Use |
---|---|---|---|
HC-05 | 3.6-6V | ∼10m | Easy |
HC-06 | 3.6-6V | ∼10m | Moderate |
HM-10 | 3.3-6V | ∼50m | Advanced |
Circuit Diagram:
Conclusion
With these simple steps, you can effortlessly establish a Bluetooth connection between your Arduino Uno and Android device. Whether for home automation or robotics, the possibilities are endless. Get started and share your projects with us!
Looking for a suitable battery for your project? Check out our LR41 Battery Equivalent Guide.
FAQs
What is the range of HC-05?
Approximately 10 meters in an open environment.
Can I use HM-10 instead of HC-05?
Yes, but it requires different configurations.
Is this method secure?
Add custom pairing codes for enhanced security.
What Android apps are recommended?
Bluetooth Terminal and Serial Bluetooth.
Can I send real-time sensor data?
Absolutely, integrate sensors with Arduino for live data streaming.