[SOLVED] Bluetooth module serial communication problem

Hello,

i’ve got (for me) really strange problem.

I created standalone arduino which i am programming with FTDI cable. I added bluetooth module (JY-MCU) and LCD display, to see what’s happening. With bluetooth module i am communicating with smartphone and BlueTerm serial app.

I am sending random chars from smartphone (BlueTerm) to bluetooth module on arduino and displaying them on LCD screen. If i am supplying whole circuit with FTDI cable (the one i am using for programming chip), everithing works without errors. But if i disconnect FTDI cable and supplying whole circuit only with 5V (from stable power source), circuit stops working. I can connect BT and smartphone but when i try to send something, nothings happen.

In other way (from BT on arduino to smartphone) works in any case so the problem is only in direction from smartphone to arduino, while supplying without FTDI cable (only wiht +5V on the same input pin)

Below is my simple testing code and circuit of connection (without LCD module).

Btw, i remove BT module every time i am loading new sketch so module is safe. I also tried with another BT module but result is the same.

char val;

void setup() 
{
  Serial.begin(9600);  
  
  lcd.begin(16,2);
  lcd.clear();
}
void loop() {
  
  if(Serial.available()) {
    
    val = Serial.read();
  }
 
    lcd.setCursor(0,0);
    lcd.print(val);
}

luxy: with 5V (from stable power source),

What is this source? How much current is it able to supply? Where on the Arduino are you connecting it?

Source is the same because i am powering from the same FTDI cable (pluged into computer over USB), just that i connect only +5V and GND from FTDI cable (with 2 connection wires).

The only change you make is disconnecting the FTDI's TX and RX?

It can hardly be the code and the wiring looks kosher, so it sounds like inadequate power.

I don’t know which is most famous - JY-MCU as a power hog, or USB for its failure to deliver, and adding an LCD can just make a bad situation worse.

[quote author=James C4S link=topic=229902.msg1659871#msg1659871 date=1396305339] The only change you make is disconnecting the FTDI's TX and RX? [/quote]

Yes, exactly.

Nick_Pyner: It can hardly be the code and the wiring looks kosher, so it sounds like inadequate power.

I tried also with LM7805 and external adapter so i don't believe the problem is in power.

What's the normal state of TX, RX and RESET pins of FTDI cable, when not programming? Is possible that lines are too long?

I found solution for this problem, in case that anyone will have the same problems.

I add 10k pull-up resistor on line, which goes from arduino's RX to TX of bluetooth module. Now it works like it should. I still don't know what's the problem but i think that signal for logical "1" from BT module is too low for arduino.

JY-MCU transmits with 3.3v. Assuming your Arduino is 5v, it doesn't normally care about receiving a 3.3v signal but, if the wire is very long and there are some losses, maybe it isn't enough. Normally, the concern is the other way, with Arduino sending a 5v signal to the JY-MCU's 3.3v Rx.

Nick_Pyner: JY-MCU transmits with 3.3v. Assuming your Arduino is 5v, it doesn't normally care about receiving a 3.3v signal but, if the wire is very long and there are some losses, maybe it isn't enough. Normally, the concern is the other way, with Arduino sending a 5v signal to the JY-MCU's 3.3v Rx.

I putted voltage divider on other side (TX to BT RX) so that's not a problem. With 10k pull-up resistor on line from BT TX to Arduino RX, it works ok, without errors.

With 10k pull-up resistor on line from BT TX to Arduino RX, it works ok, without errors.

It might do for now but by pulling up that line you are in effect putting 5V on the BT module's output. As this is a 3v3 device this could damage it. Some devices are tollerent to this sort of thing but many are not.

I don't know why you would need to do this. It doesn't sound like a great idea, and it might be better to find out what the real problem is.

Grumpy_Mike: It might do for now but by pulling up that line you are in effect putting 5V on the BT module's output. As this is a 3v3 device this could damage it. Some devices are tollerent to this sort of thing but many are not.

Nick_Pyner: I don't know why you would need to do this. It doesn't sound like a great idea, and it might be better to find out what the real problem is.

I tried direct connection to RX line of Arduino but it didn't work. I tried with two different bluetooth modules and with 3 different boards (Uno, Nano and stand-alone Arduino) but result was the same. The only way i could make it work was to add pull-up on that line. In other way (Arduino TX to bluetooth RX) with voltage divider it works like it should.

I think the problem is that signal for logical "1" from 3,3V BT module is too low for Arduino to understand it but i don't know why or how to fix it. Btw, lines are just a few cm long, i tried on breadboard and PCB -> No luck.

What about using a level shift? There some very cheap ones available on ebay. Or you might build your own with a couple of npn transistors. Definitely the voltage divider is not a solution here because your voltage levels will get messed.

Have you noticed this http://electronics.stackexchange.com/questions/48510/logic-levels-between-5v-and-3-3v-devices perfectly fits your question?

Or you might build your own with a couple of npn transistors.

Why a couple? You only need one:-

Grumpy_Mike:
Why a couple? You only need one:-

I created my own 2 channel LLC, based on sparkfun LLC → https://www.sparkfun.com/products/12009

Now it works, without pull-up.

Grumpy_Mike, which type of transistor would fit in this scheme? I used BSS138 but it take me A LOT of time to solder them (they are sooo small). Can you recommend some kind of replacement in TO-92 housing or a little bigger SMD version?

which type of transistor would fit in this scheme?

Any general purpose NPN, there are lots to choose from.
BC108, BC185, 2n2222 the list is almost endless.

I will try with 2n3904..

Btw, this thing is not bidirectional, right? If i would like to do bidirectional version i would need to use FET (something like BSS138 just in TO-92 housing, for easier handling).

I found PCA9306. Dual bidirectional LLC which is cheap and big enough for easy soldering. That's exactly what i need :)

http://www.ti.com.cn/general/cn/docs/lit/getliterature.tsp?genericPartNumber=pca9306&fileType=pdf

That’s exactly what i need

No it is not, you do not need anything bidirectional and you do not need an I2C bus level translator.

Grumpy_Mike:
No it is not, you do not need anything bidirectional and you do not need an I2C bus level translator.

I am planning to use it for both sides (also from Arduino TX to bluetooth RX), to avoid voltage divider. I know i don’t have I2C but it will work anyway, right? I would like to use this because is small and cheap enough. With this device i don’t need 6 (or more) different components on the PCB.

Btw, do you know what would be BSS138 alternative in THT?