HC-06 bluetooth do not communicate with Arduino.

I just bought a bluetooth module (hc-06) . I’ve connected it to arduino micro and no communication ]:slight_smile: . RX->TX and TX-RX. Vcc to 5V and GND to GND. The bluetooth is mounted on another board with voltage regulator, an LED and some rezistor ready to be connected to arduino (I guess). I can connect with an android smartphone to it, but nothing.
When I connect, the led stop flashing but arduino do nothing at my inputs.
The module has 4 pins (vcc,gnd,rx,tx), in datasheet say that when is not connected to a device is in AT mode.
The code I use is:
void setup(){
pinMode(13,OUTPUT);
Serial.begin(9600);
}
void loop(){
if(Serial.available()){
Serial.read();
digitalWrite(13,HIGH);
delay(1000);
}
}

And do nothing.
I’ve also tried to enter in programming mode with AT command. I’ve used SoftwareSerial library to define another pins for RX and TX, then send commands from SerialMonitor to Arduino -->bluetooth and vice versa. Not “ok” at serial monitor.

Also I tried to connect the TX pin of the bluetooth to my pc microphone jack, and common GND. Is silence till I press a key on android, then begin a sound like a PWM for one second then stops. I’am a beginner but serial data of only one char should be transmitted under a second. (1/9600)*8 sec. Why keep beep so long? maybe the bluetooth is faulty.

Things I tried:
-use SoftwareSerial library and define pin 2 and 3 for RX TX (2,3 interrupters on micro)
-change the baudrate
-change android software (SENA BTerm, Bluetooth SPP etc)
-invert RX with TX, hope that this hasn’t destroy anything. :cold_sweat:

So the question is:
Is my module faulty or I missed something…or both. =(

Florianu: Is my module faulty or I missed something...or both. =(

Not likely the former, possibly the latter. If the LED stops flashing, you have paired with Android. Is the USB cable disconnected?

Here is some basic background. Get rid of those buzzers and wires, and get the essentials right first.

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

First thing I tried was that tutorial and yes, the usb cable was disconnected. I used an external power supply on arduino vcc pin. Work with serial monitor, not work with android monitor at any baudrate I test it.

If you can use the serial monitor then send at commands to set the baud rate like AT+BAUD4 this changes it to 9600 and that way you're sure what is the baud rate

Actually, it was wrong of me to query the USB cable. You can use it if you are working with Android

I assume the programme works fine with serial monitor when HC-06 is disconnected.

I understand the LED is steady, you can make the connection. This only proves the Android<>Bluetooth communication is good, not Arduino<>bluetooth.

You have wiring Rx>Tx and Tx>Rx. (Check it again)

What I don’t know is if you have stuffed something up by sending an AT command. Clearly, the steady LED means there is no password problem and, if you check all speeds, I guess there isn’t much else to go wrong there.

The power supply is the last obvious villain. Disconnect bluetooth and check the code is OK with serial monitor. Then connect bluetooth with power from USB cable. Turn on serial monitor, just to make sure there is no stumble at the Arduino end.

Make sure Android confirms the connection.

If I connect bluetooth to rx and tx at arduino, then I plug the usb cable and start the SerialMonitor on the pc, the data from bluetooth is send directly to pc.without any code needed on arduino? just like arduino will play as a convertor from serial to usb I've tried this thing with all baudrate I could find in serial monitor list and nothing again. Also I connected the bluetooth to Arduino Leonardo this time. Same story with no glory.

No. I only meant that Arduino can send data to Android via bluetooth and to Monitor via USB cable at the same time. It's just a confidence booster.

I assume you don't have another Android that you can beg, borrow ,or steal.

I had problems with my HC-06 working with my phone but not my tablet, but I'm not keen to blame the HC-06 as I don't think mine would pair, while I understand yours does. My tablet was fine with an HC-05

You're not alone. Literally the same problem. Well, originally, it was working just fine and handling little LEDs and buzzers, etc. Sample project. Then without changing any code or wiring it soon would not accept commands... That was a week ago. Took a break with some LCDs and servos and such, cane back and now I'm where you are. My HC-06 is not connecting with my Android or rarely if it does will not accept commands. It may be a cheap module, but I'm still wondering. Wiring and the Arduino code is all the samples provided by the guy who wrote the android-Bluetooth app for the Arduino, TechBitar (?).

Looking over the forum, it seems that Bluetooth Modules are rather finicky and do not seem to be having a 100% success rate. My Android and Arduino were talking but now they won't even nod in the hallway or say that their answering machine hasn't been working lately...

NolanH: Looking over the forum, it seems that Bluetooth Modules are rather finicky and do not seem to be having a 100% success rate.

I'm not convinced of that in this context. I have had problems with my HC-06 refusing to talk to my tablet but I feel that, if it works, it will keep on working.

I have no explanation for the problem I had with the HC-06. It is noteworthy that the tablet was OK with my HC-05, and was also fine with a bluetooth keyboard. I'm still blaming the tablet, which was clunky, and now deceased.

I'm getting the impression that a few people have had problems with HC-06 and none have with HC-05. I bet nobody has an explanation for that either but, since they are both dirt cheap, I would recommend the HC-05, as it is more versatile anyway.

Strange things is happening here, why when I send a byte from Android on TX pin appear a signal with a duration over one second. Is a signal so why Serial.available() is still zero on arduino. Even if the baudrate is wrong, some corrupted data should trigger Serial.available() and why the bluetooth module seems that sends a string not a char? I made at least 30 attempts so far and no results. Maybe my bluetooth can't put the tx pin LOW when is needed , I will start with some rezistors to ground just to be sure.

Check ther solder connections on the backboard, and make sure there are no bridges

FIXED!!!!!!!!! The problem was the code :sweat_smile: !!! REPLACE: Serial with Serial1 !!! IF YOU HAVE ARDUINO MICRO OR LEONARDO OR ANYTHING ELSE THAT DON"T HAVE A CHIP FOR SERIAL-USB CONVERTOR, THAT CHIP IS VIRTUAL AND YOU NEED TO USE FOR RX AND TX PIN THE "Serial1" CLASS not "Serial". I've found this when I search in Arduino Leonardo documentation, It say: "-Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data using the ATmega32U4 hardware serial capability. Note that on the Leonardo, the Serial class refers to USB (CDC) communication; for TTL serial on pins 0 and 1, use the Serial1 class." The working code is: //this code will print to serial monitor what you send to bluetooth void setup(){ Serial1.begin(9600);//default baundrate from my bluetooth hc-06 Serial.begin(9600);//if you want to send data to pc } void loop(){ if(Serial1.available()){ Serial.write(Serial1.read()); } }

And thanks to all for help!

hello there, The above code u mentioned is not working. It says that " serial1 is undeclared" what to do please help.......

try adding this line to your code:

pinMode(0, INPUT_PULLUP);

that worked for me...

Hello Florianu, i am facing exactly the same problem as yours while communicating with arduino mega/uno. I checked their datasheet which showed that these two allow serial communication at pin 0 and 1 in class serial itself!! what to do now?? Please help.

please am Eric I have problem with project, if I connect Bluetooth hc06 to the arduino, the serial monitor will not work again, also if I send command from the nexus 6 android smart phone I just have this ⸮⸮⸮⸮⸮⸮⸮⸮⸮ format on the serial monitor RX -TX =0, TX-RX=1.

that is the code.

int R1 = 13; char data = 0; void setup() { Serial.begin(9600); pinMode(R1, OUTPUT);

}

void loop() {

if (Serial.available()) { data = Serial.read(); Serial.print(data); } if(data == '0'){ digitalWrite(R1, 0); } if(data == '1'){ digitalWrite(R1, 1); } }

You appear to be using Bluetooth and serial monitor both on hardware serial 0,1, which is not such a good idea. What Arduino are you using? The gibberish may actually be down to some other problem. 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