How to Send Data from Android to Arduino via Bluetooth Module HC-05

How to Send Data from Android to Arduino via Bluetooth Module HC-05

Bluetooth communication between Android devices and Arduino using the HC-05 module can enable a wide range of smart home, IoT, and other electronic applications. In this comprehensive guide, we will explain the hardware and software setup necessary to achieve seamless communication between your Android app and Arduino via Bluetooth.

Hardware Setup

To get started, you need to connect the HC-05 Bluetooth module to your Arduino and Android devices properly. Here are the necessary wiring connections:

Arduino to HC-05 Connections

HC-05 TX pin to Arduino RX pin (Note: This is TX-RX, not Rx-Tx) HC-05 RX pin to Arduino TX pin (Note: This is RX-TX, not Tx-Rx) HC-05 VCC pin to Arduino 5V pin HC-05 GND pin to Arduino GND pin

Ensure these connections are made accurately to avoid any communication issues.

Software Setup

Here is a step-by-step guide to programming both the Android app and the Arduino:

Android App Setup (Optional)

If you prefer an Android app for communication, there are several available in the Google Play Store. One such app is Arduino Rc. Follow these steps to set up your Android app:

Download and install the Arduino Rc app from the Google Play Store. Open the app and make sure it is paired with the HC-05 module using the Bluetooth settings on your Android device. In the app, go to the Terminal feature to send data and perform actions on the Arduino.

Arduino IDE Programming

Start by setting up your Arduino with the necessary serial communication code:

Arduino Code for Receiving Data:

(9600);String incomingData;void loop() {  if (Serial.available()  0) {    char inChar  ();    incomingData   inChar;  }  if (incomingData.endsWith('!')) {  // Stop byte    (incomingData);    incomingData  "";  }}

Make sure the baud rate on your Arduino is set to 9600, which is the default for the HC-05.

Bluetooth Serial Monitor App for Android

If you prefer using a different Android app, you can use the Bluetooth Serial Terminal app available in the Google Play Store. Follow these steps:

Download and install the Bluetooth Serial Terminal app from the Google Play Store. Set the baud rate to 9600. Connect to the HC-05 module on your Android device. Type data into the terminal and send it. The data should be received on the Arduino.

Conclusion

By following the steps outlined above, you can successfully set up communication between your Android device and Arduino through the HC-05 Bluetooth module. This setup is widely used in IoT and electronic projects, enabling real-time data transmission and control.

If you found this guide helpful, stay tuned for more tutorials on Bluetooth communication and other related topics.