Bluetooth Serial Communication

I'm trying to use an HC-06 Bluetooth module to replace the wired serial connection in one of my projects. So far I have been able to pair the module with my computer, but when I try to send AT commands the serial monitor just freezes. I'm pretty new to this stuff so if anyone can provide any help I would really appreciate it.

link to module - http://www.amazon.com/JBtek-Bluetooth-Converter-Serial-Communication/dp/B00L08GA4Q

Post your code. This is probably just a minor comedy of errors. I think you might be trying to send AT commands over bluetooth. The HC-06 is in AT mode initially but goes into comms mode as soon as you connect, which is very reasonable.

Have you proven everything by just using HC-06 out of the box?

You might find the following background notes useful

http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf http://homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino

There is method for sending AT commands at the end but note it is for Mega

Thank you so much for your reply. I will post the arduino code below, I did not write it, I found it online. I have not gotten the device to work yet. I hadn’t actually planed on changing any of the settings, I was just going to send “AT” and see if I got “OK” back. Also, I was reading through the links and it seems there’s another problem. The computer says that it’s paired, but the led on the HC-06 continues to flash. As I said I’m very new to this, so I’m sorry if any of this sounds stupid.

#include <SoftwareSerial.h>
SoftwareSerial mySerial(4, 2); // RX, TX

String command = ""; // Stores response of the HC-06 Bluetooth device


void setup() {
  // Open serial communications:
  Serial.begin(9600);
  Serial.println("Type AT commands!");
  
  // The HC-06 defaults to 9600 according to the datasheet.
  mySerial.begin(9600);
}

void loop() {
  // Read device output if available.
  if (mySerial.available()) {
    while(mySerial.available()) { // While there is more to be read, keep reading.
      command += (char)mySerial.read();
    }
    
    Serial.println(command);
    command = ""; // No repeats
  }
  
  // Read user input if available.
  if (Serial.available()){
    delay(10); // The delay is necessary to get this working!
    mySerial.write(Serial.read());
  }
}

jdk199: Thank you so much for your reply. I will post the arduino code below, I did not write it, I found it online.

That code should be fine. In the notes, the approach is different and you might find it better

I have not gotten the device to work yet. I hadn't actually planned on changing any of the settings,

Indeed. It took me a long time to find a good reason to change anything. Eventually I needed to get more speed for large file downloads. Since then, I have succeeded in reducing the file size, which was a much better idea.

The computer says that it's paired, but the led on the HC-06 continues to flash. As I said I'm very new to this, so I'm sorry if any of this sounds stupid.

If the LED is flashing, it isn't paired, and I would trust HC-06 more than PC - particularly if PC is running a bluetooth dongle. It doesn't sound stupid, it sounds familiar. It is likely that PC isn't actually saying it's paired, it is only saying that it can see HC-06, which isn't the same thing. I have never succeeded in getting my PC to work, but the laptop is fine, and so are the Androids.

It is very easy to run out of motivation on this matter. Maybe your PC has bluetooth built in but I guess the reason why so few do is because it isn't a very good idea.

Again thank you for the reply. I am using a Bluetooth dongle on my laptop. In PC setting it says it's paired, but it definitely is still flashing. Do you have any ideas on what might be going on?

No, I'm afraid not. All I can say is that I'm sure all the problems are at the PC end. You can verify this if you can beg, borrow, or steal an Android phone.

Wait. One last shot in the dark, which I don't think worked for me, is that you must appreciate the difference between pairing and connecting. Pairing actually means getting on the list for subsequent connection. Your devices can be paired for ever with no actual connection but the LED only stops flashing when the connection is made. So try running a terminal.....

I just went a got my android. I paired the devices, but the LED continued to flash. So I then tried to send some data with Tera Term, but the LED kept flashing.

Great, stick with the Android! And don't be tempted change terminals either.

The pairing is done in the settings section of Android. Clearly, you are OK with that, but you now have to make the connection under Terra term. You should then see the affirnation on the phone and the LED goes solid.

Note that Arduino is not involved in any of this, it is just there to provide the power.

What I have outlined above is standard procedure for Android devices. If you don't have any joy, I'm inclined to be suss about the bluetooth module. The only problem I have heard about them is solder bridges across the pins, so check that.

I followed your instructions, but the LED continued to flash. I'll try to do some research and see if I can find a website that discusses the problem.

I haven’t been able to find anything on the web about the problem, but I did discover something else. In control panel I right clicked on the device and selected “control”. Here it says the device is disconnected. I have attached a screenshot of what I’m taking about.

Stick with the Android. Did it have a pairing list? Did TerraTerm say it was connected?