How to Send Data from Arduino to Android Using Bluetooth
To send data from
Arduino to an Android device using Bluetooth, connect a Bluetooth module (like HC-05) to Arduino's serial pins and use Serial.write() or Serial.print() to send data. On Android, use a Bluetooth app or custom app to receive and display the data.Syntax
To send data via Bluetooth from Arduino, use the Serial.print() or Serial.write() functions after setting up the serial communication with the Bluetooth module.
Serial.begin(baudRate);initializes serial communication at the specified speed.Serial.print(data);sends readable text data.Serial.write(data);sends raw bytes.
The Bluetooth module connects to Arduino's TX and RX pins and acts as a wireless serial bridge.
arduino
void setup() { Serial.begin(9600); // Start serial at 9600 baud } void loop() { Serial.print("Hello Android\n"); // Send text data delay(1000); // Wait 1 second }
Example
This example sends the text "Hello Android" every second from Arduino to an Android device via Bluetooth. Connect an HC-05 Bluetooth module to Arduino pins 0 (RX) and 1 (TX), power it, and pair it with your Android phone. Use a Bluetooth terminal app on Android to receive the message.
arduino
void setup() { Serial.begin(9600); // Initialize serial communication with Bluetooth module } void loop() { Serial.println("Hello Android"); // Send data with newline delay(1000); // Wait 1 second }
Output
Hello Android
Hello Android
Hello Android
... (repeats every second)
Common Pitfalls
Common mistakes when sending data from Arduino to Android via Bluetooth include:
- Not matching baud rates between Arduino and Bluetooth module.
- Connecting Bluetooth module to wrong Arduino pins or using pins reserved for USB programming.
- Forgetting to pair the Bluetooth module with the Android device before communication.
- Using
Serial.print()without newline when the Android app expects line breaks.
Always test with a simple Bluetooth terminal app on Android first.
arduino
/* Wrong: Using pins 0 and 1 while uploading code can cause issues */ // Avoid using pins 0 (RX) and 1 (TX) if uploading code frequently /* Right: Use SoftwareSerial on other pins */ #include <SoftwareSerial.h> SoftwareSerial BTSerial(10, 11); // RX, TX void setup() { BTSerial.begin(9600); } void loop() { BTSerial.println("Hello Android"); delay(1000); }
Quick Reference
| Step | Description |
|---|---|
| Connect HC-05 module | Connect TX to Arduino RX, RX to Arduino TX, and power the module |
| Set baud rate | Use Serial.begin(9600) to match HC-05 default speed |
| Send data | Use Serial.print() or Serial.println() to send text |
| Pair device | Pair HC-05 with Android via Bluetooth settings |
| Receive data | Use Bluetooth terminal app on Android to read data |
Key Takeaways
Connect a Bluetooth module like HC-05 to Arduino serial pins and set matching baud rates.
Use Serial.print() or Serial.println() to send readable data from Arduino.
Pair the Bluetooth module with your Android device before trying to receive data.
Avoid using Arduino pins 0 and 1 for Bluetooth if you upload code often; use SoftwareSerial instead.
Test communication first with a Bluetooth terminal app on Android.