Aurasphere Aurasphere - 2 years ago 174
Java Question

Arduino HC-05 Bluetooth module disconnects when sending data

I'm new to Arduino. I'm trying to build a program to control a breadboard through Arduino using the bluetooth module HC-05. At the moment I don't have anything on the breadboard and I'm just trying to test the connection. This is what I've done so far:

I put the module on the breadboard and I've paired it with the computer. When it's paired, the red led starts blinking slowly. I've connected the bluetooth Rx to Arduino Tx and Arduino Rx to bluetooth Tx following this tutorial:

I've also implemented both Java and Arduino programs following that tutorial. Here they are:


public class Arduino extends PApplet{

public void connect(){
String[] serials = Serial.list();
Serial port = new Serial(this, Serial.list()[0], 9600);


void setup() {

void loop() {
int a =;

The Java part should send the letter H to Arduino and Arduino should detect that and print it on the Serial monitor. But what actually happens is that I send data, and the led on the HC-05 starts blinking faster (which means the connection is lost). Why does that happen? I'm pretty confused. For the communication I'm using the port COM6 and COM7. It depends on how it connects. To see what port to use I just run the Java program: if the port is not correct, it will just get stuck and send nothing.

Any help is appreciated. Thanks!

Answer Source

In the end, I've solved this problem by removing this line of code:


It would never work with it because I was getting rid of the connection. I don't know what I was thinking at the time I did that. That was very silly of me.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download