Simple bluetooth communication doesn't work

Hi all,

I'm trying to make a communication between my laptop with my arduino in bluetooth but i can't make it work, need yur help ... :confused: :confused:.

The components i'm using are :

  • An Arduino UNO
  • A bluetooth compoment connected to my Arduino (ZS-040)
  • A bluetooth dondle on my laptop

Below the code i'm using :

#include <SoftwareSerial.h>

SoftwareSerial BTSerial(10, 11); // RX | TX

void setup() {
  Serial.begin(9600);
  Serial.println("Enter AT commands:");
 
  // HC-06 default serial speed is 9600
  BTSerial.begin(9600);
}

void loop() {
  if (BTSerial.available()) {
    Serial.write(BTSerial.read());
  }
 
  if (Serial.available()) {
    BTSerial.write(Serial.read());
  }

}

When i connect my arduino board to my bluetooth module like i should do (VCC <=> VCC, GND <=> GND, RX <=> 10, TX <=> 11 then AT commands dont work...

If i switch RX and TX (RX <=> 11, TX <=> 10) then AT commands works ('OK' answer to 'AT' request but I cannot pair with the bluetooth module from my laptop. Please find in attachment a capture of the board connection i do.

Due to this very "weird" behavior i first thought that my bluetooth module or my arduino board were flawed so i have bought new ones but i still have the same problem !!

In attachment also a capture of the two bluetooth components i have.

Do you have an idea of what happens here, i'm lost :confused: ....

Thanks,
Space.

Yes you have to connect hc06's tx pin to rx pin on arduino (in this case pin 11) and the same to rx pin. And when you are in at mode, you cannot connect to other device using bt connection

I dont understand, from the SoftwareSerial documentation the RX is the first argument and TX the second : SoftwareSerial(rxPin, txPin, inverse_logic) ==> https://www.arduino.cc/en/Reference/SoftwareSerialConstructor.

So if i declare the following constructor :

SoftwareSerial BTSerial(10, 11); // RX | TX

I should then connect the RX pin to the 10 arduino pin no?


About the AT mode thing i will check that.

Thanks.

I followed the tutorial at http://tronixlabs.com.au/news/tutorial-using-hc06-bluetooth-to-serial-wireless-uart-adaptors-with-arduino/

I was using a smartphone, but the concept should be the same.

Space23:
Due to this very "weird" behavior i first thought that my bluetooth module or my arduino board were flawed so i have bought new ones but i still have the same problem !!

There is nothing weird about it and you probably haven't broken anything. A receiver receives from a transmitter, hence their names, and you connect accordingly.

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