Right now I have a big Arduino project, where I have build a shifted LED matrix (see below), which I wanted to controll via bluetooth with my Android-Smartphone. It’s awesome how basic it is to with a bluetooth-module like the HC-05. Just set it up like in this schematic, and pay attention how to connect the RX and TX!

Arduino HC-05 schematic

Just upload the following code to the Arduino (Don’t forget to diconnect the RX/TX wires if your are using Pin 0/1!).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <SoftwareSerial.h>

SoftwareSerial bluetoothSerial(2, 3); // RX, TX

void setup() {
  Serial.begin(9600);
  // MAYBE THE BAUD RATE DIFFERS!
  bluetoothSerial.begin(9600);
}

void loop() {
  if(bluetoothSerial.available() > 0){
    char rc = bluetoothSerial.read();
    Serial.print(rc);
  }
  if(Serial.available() > 0){
    char rc = Serial.read();
    bluetoothSerial.write(rc);
  }
}

Next try to connect your phone to the bluetooth-module (maybe called HC-05, JDY-30 or something else, depending on the module you’re using). Most time the pairing code is 1234 or 0000. There is a blinking LED on the bluetooth-module, which stops blinking if there is a connection. After successfully connecting to the module, you can download any Serial-terminal app from the PlayStore and send commands. In your Serial monitor you can receive these commands. You can also test what the Arduino receives if the connection is unexpectedly interrupted.

Comments and Feedback

Feel free to tweet your comments and feedback to me @jboka_
It’s always nice to get feedback and there is always room to improve and learn from others!

Arduino HC-05 gif