Question About Debugging a Serial RX Issue

Howdy. I've been getting familiar with Arduino lately, and I've run into an issue that I can't seem to figure out. I have a brand-new Arduino Uno and an HS-06 (serial bluetooth module.) I've seen plenty of reports of people using these successfully, but mine seems to have some sort of incompatibility with the Arduino's serial RX.

I can transmit from the HS-06 and receive it on my Android tablet just fine. Any message I send to the HS-06 though never gets picked up by the Arduino. I've been chasing my tail trying to isolate the issue, and the results don't make any sense to me. Here's what I've tried:

  • I've made sure to disconnect the USB connection from the Arduino and run off battery during my tests.
  • I've looped the HS-06's TX pin into its RX pin, and the result is a successful loop back to the tablet (so the TX pin is in fact working.)
  • I've connected the HS-06 to pins other than 0 and 1 and successfully received serial using some of the software serial libraries (SoftwareSerial, AltSoftSerial.) I don't believe this is a permanent solution though, due to some other shields I need to eventually add into the mix that need those pins.
  • I've checked the physical wiring more times than I can count to make sure I'm hooking the correct pins on the HS-06 up to pins 0 and 1 on the Arduino.
  • I've trimmed down the code to the absolute simplest test I could come up with:
const int ledPin = 13;

void setup() {
  Serial.begin(9600);
  
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);
}

void loop() {
  if (Serial.available() > 0) {
    digitalWrite(ledPin, HIGH);
    Serial.read();
  }
}

and the LED never lights up (it never receives anything on Serial RX.)

  • If I reconnect the USB and send serial into the Arduino using the Serial Monitor, the LED gets triggered correctly.
  • I've tried a couple different Android Bluetooth test apps.

So I'm out of ideas at this point. I've verified that the TX from the HS-06 is operational, but I can't figure out why it's not being picked up by the RX pin on the Arduino. Any thoughts on where to go from here? Thanks!

Tahnok:
I've trimmed down the code to the absolute simplest test I could come up with:

Not quite.

These notes might be useful
http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf
http://homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino

Note that it is OK to have the USB connected to PC while using Bluetooth with Android. Check the popwer connections

Nick_Pyner:

Tahnok:
I've trimmed down the code to the absolute simplest test I could come up with:

Not quite.

These notes might be useful
http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf
http://homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino

Note that it is OK to have the USB connected to PC while using Bluetooth with Android. Check the popwer connections

Hey Nick. Thanks for the links. I've read through them in-depth, run the exact code provided, and it still seems to be failing on serial RX. Again, it works great when sending a message from the Serial Monitor via USB, but receiving on the HS-06 is still not working. TX from the HS-06 gets picked up correctly on the Android tablet (the initial message is displayed every time I reset the Arduino.)

I thought I had read somewhere that having USB connected can interfere with serial RX, so I figured I'd play it safe and just disconnect it. But that makes things easier to just leave it connected if that's not the case.

OK. The first thing to confirm is that you get two way traffic using the USB cable - no bluetooth involved. If you get two-way comms with just the USB cable, the clearly there is nothing wrong with Arduino, or your code. The reason why I said "not quite" is to get the LEDs out of the game.

If you then get only only one-way traffic with bluetooth and

checked the physical wiring more times than I can count to make sure I'm hooking the correct pins on the HS-06 up to pins 0 and 1 on the Arduino.

then you might conclude there is a power supply problem, so now is the time when I don't want to hear that you carefully pulled the USB cable out and connected a 9v battery instead. If that is the case, I have no idea why it would work in one direction and not the other, but I would look to a better power source, even if it's only a 1A USB charger.

You might check the solder connections on the bluetooth's header. Somebody had a bridge between pins, but I can't remember if it caused your problem.

You are correct in that you cannot use Bluetooth and USB serial monitor on a PC at the same time, but you can have serial monitor on PC and Bluetooth on Android!

Nick_Pyner:
OK. The first thing to confirm is that you get two way traffic using the USB cable - no bluetooth involved. If you get two-way comms with just the USB cable, the clearly there is nothing wrong with Arduino, or your code. The reason why I said "not quite" is to get the LEDs out of the game.

If you then get only only one-way traffic with bluetooth and

checked the physical wiring more times than I can count to make sure I'm hooking the correct pins on the HS-06 up to pins 0 and 1 on the Arduino.

then you might conclude there is a power supply problem, so now is the time when I don't want to hear that you carefully pulled the USB cable out and connected a 9v battery instead. If that is the case, I have no idea why it would work in one direction and not the other, but I would look to a better power source, even if it's only a 1A USB charger.

You might check the solder connections on the bluetooth's header. Somebody had a bridge between pins, but I can't remember if it caused your problem.

You are correct in that you cannot use Bluetooth and USB serial monitor on a PC at the same time, but you can have serial monitor on PC and Bluetooth on Android!

Hey Nick. Sorry about the delay in response - I had to wait until I had some time to test again with a different power supply.

I've confirmed that I get two-way traffic over the USB cable using the Serial Monitor.

I just hooked up the Arduino to 12V, 1A, AC adapter, and nothing has changed. Still successfully transmitting from the Arduino, but receiving nothing.

I've checked the soldering on the bluetooth chip and it appears fine. If the issue were on the bluetooth chip itself then I would think the loopback would not to work either. If I connect TX and RX directly together on the bluetooth chip then it correctly loops messages back to the android.

Very simple echo code you might try. What ever is received on the arduino rx is echoed back out the arduino tx. Test first using the serial monitor, then with the serial monitor open and the HS-06 tx connected to the arduino rx (and grounds connected), see if anything appears in the serial monitor when the data is sent from the Android tablet.

//zoomkat 6-29-14 Simple serial echo test
//type type text in serial monitor and send

String readString;

void setup() {
  Serial.begin(9600);
  Serial.println("Simple serial echo test"); // so I can keep track of what is loaded
}

void loop() {

  while (Serial.available()) {
    char c = Serial.read();  //gets one byte from serial buffer
    readString += c; //makes the String readString
    delay(2);  //slow looping to allow buffer to fill with next character
  }

  if (readString.length() >0) {
    Serial.println(readString);  //so you can see the captured String 
    readString="";
  } 
}

Are you using the HC-06? If so, logic levels may not be completely compatible.
http://forum.arduino.cc/index.php?topic=97726.0

zoomkat:
Very simple echo code you might try. What ever is received on the arduino rx is echoed back out the arduino tx. Test first using the serial monitor, then with the serial monitor open and the HS-06 tx connected to the arduino rx (and grounds connected), see if anything appears in the serial monitor when the data is sent from the Android tablet.

//zoomkat 6-29-14 Simple serial echo test

//type type text in serial monitor and send

String readString;

void setup() {
  Serial.begin(9600);
  Serial.println("Simple serial echo test"); // so I can keep track of what is loaded
}

void loop() {

while (Serial.available()) {
    char c = Serial.read();  //gets one byte from serial buffer
    readString += c; //makes the String readString
    delay(2);  //slow looping to allow buffer to fill with next character
  }

if (readString.length() >0) {
    Serial.println(readString);  //so you can see the captured String
    readString="";
  }
}

Unfortunately, that code looks very similar to the stuff I've already tried. Nick_Pyner posted a link to some basic serial echo code earlier in the thread. I've confirmed the code I'm using is operating as expected using the serial monitor. It's only when using the HS-06 chip that the issues start up. Thanks though.

dlloyd:
Are you using the HC-06? If so, logic levels may not be completely compatible.
how to interface Arduino with Bluetooth module (HC-06). - Networking, Protocols, and Devices - Arduino Forum

It is in fact an HS-06. However, from what I read in that thread (and elsewhere) it sounds like the Arduino should be able to handle this scenario. The issue I'm having is on RX into the Arduino from the HS-06. TX from the Arduino to the HS-06, which is where it may be providing too much voltage, is actually working fine. Is there something else in that thread that I'm overlooking?

Do you have a link to the HS-06 datasheet?

dlloyd:
Do you have a link to the HS-06 datasheet?

Mine is additionally mounted on a backer board - that datasheet is purely for the HS-06 chip. I don't have one for the board that the chip is mounted on.

The board my chip is mounted on it not the popular JY-MCU, but rather labeled as "LC Technology http://www.lctech-inc.com". This appears to be the chip on the manufacture's page:

http://www.lctech-inc.com/Hardware/Detail.aspx?id=684fb223-1a23-4b83-8dbd-4d58c2b3c0cb

If you're using the UART_TXD signal and its 3.3V logic, then it would require voltage level conversion to 5V as shown in Figure 8 Application circuit 2.

Note that the RX signal only uses a diode.

Tahnok:

dlloyd:
Do you have a link to the HS-06 datasheet?

http://www.rasmicro.com/Bluetooth/HC%20Serial%20Bluetooth%20Products%20201104.pdf

Mine is additionally mounted on a backer board - that datasheet is purely for the HS-06 chip. I don't have one for the board that the chip is mounted on.

The board my chip is mounted on it not the popular JY-MCU, but rather labeled as "LC Technology http://www.lctech-inc.com". This appears to be the chip on the manufacture's page:

http://www.lctech-inc.com/Hardware/Detail.aspx?id=684fb223-1a23-4b83-8dbd-4d58c2b3c0cb

It looks like you have a normal HC-06, and anything about an HS-06 has been written by somebody who can't write, possibly the same person who designed the backing board and he was no good at that either. It seems to me that you are doing everything right, and I submit that all this stuff about level conversion and compatibility is nonsense. The most you might consider is a divider on the Arduino Tx, merely as a precaution, and that is clearly not the problem anyway - it's Arduino Rx.

One has to wonder what those jumpers on the other side of the backboard are for, and particularly why this board has them when no others do. You might even find that Arduino can't receive because Bluetooth can't transmit until a jumper is jumped.

The device could be a dud. It's very rare but it has happened. I submit you would be best off cutting your losses and popping the $7-50 to get a proper HC-05 on JY-MCU. That way you get a free ticket to sing in the same chior as everybody else, which would be cheap at twice the price, and the device you have is still good for a one-way traffic project.

Alright, sorry about the delay, guys. I really appreciate the feedback - I just had to wait a bit to get some new parts and have a chance to hook everything up.

Anyway, you appear to have been spot-on, Nick. I just had a new "JY-MCU" HC-06 board arrive today. I hooked it up the same way, ran the same code, and the board instantly began communicating as expected. I now have full communication between my Arduino and my tablet. It's really frustrating that I still don't know why the original board didn't work, but at least now I can continue with the project.

On dlloyd's suggestion, I did go ahead and order some logic level converters as well (easier than trying to piece the circuit together myself - I don't have those components sitting around.) They haven't arrived yet in the mail though. I'll let you guys know if I find anything interesting with the old board, but at this point I'm operating under the assumption that it's a dud.

Thanks for the help!

Well, I have the same BT module, and exact the same problem.

I've been trying to troubleshoot it for 2 days now but also without solution.
I thought it probably was a hw-fault, but now i'm more declined into thinking it's a "hidden feature" :slight_smile:

If I manage to get some more answers, I'll post them here.

If you have the same module and the same problem, it could be that you might find the same solution in reply #12

What I've found on this wike page :
http://www.electrodragon.com/w/LC-05_Bluetooth_Serial_Module_Master/Slave_Integrated
Explanation of the blinking led.
Pin 34 high for AT commands (only receiving )
pin 34 low for communication.

None the wiser :slight_smile:

The above refers to the HC-05. This thread is about the HC-06. The pin 34 is on the actual buetooth module. I understand the "key" pin on the JY-MCU board connects to that.