SoftwareSerial connecting to BT Module problem

Hi,

I try to get a cheap dx.com BT module to work but with very little success. It is a JY-MCU v1.05 module. I try to get some kind of connection to it but fail.

What I have done:

  • I have paired BT module with my laptop (running w8). It worked fine.

  • I started with the simplest possible example. Send a character to the BT module using SoftwareSerial and try to watch it in the Serial Monitor. But I don’t get anything. When I debug the problem it seems like the SoftwareSerial write function doesn’t send anything. It returns 0 indicating fail and the TX pin is constantly high.

I used this code in my debugging with a led connected to PIN 11. But the led stays high all the time.

/* Include the software serial port library */
#include <SoftwareSerial.h>

#define ARDUINO_RX_TO_BT_TX 10
#define ARDUINO_TX_TO_BT_RX 11

/* Initialize the software serial port */
SoftwareSerial BluetoothSerial(ARDUINO_RX_TO_BT_TX, ARDUINO_TX_TO_BT_RX);

void setup()
{
/* Set the baud rate for the software serial port */
BluetoothSerial.begin(9600);
delay(300);
}

void loop()
{
BluetoothSerial.write(0b10101010);
delay(2);
}

I use a arduino UNO R3 board.

Any help would be most appreciated!

Best,
Garpen

I’m guessing that’s either an HC-05 or HC-06 board on a JY-MCU baseboard.

Is it a 4-pin or 6-pin version of the board?

It is a 4 pin board.

garpen:
It is a 4 pin board.

So it paired as "linvor" then. It's an HC-06 module.

It took me a bit of fiddling to get mine working, but it's been rock-solid since it started working.

The manual is here: http://www.mcu-turkey.com/wp-content/uploads/2013/01/HC-Serial-Bluetooth-Products-201104.pdf

One thing to note though - these modules are actually 3.3V, not 5V. The baseboard includes a 3.3V regulator, but the serial communications is at 3.3V. Receiving by the Arduino should be OK at that voltage but no guarantees - it's kind of borderline. Boosting the signal through a 74HCT08 AND gate with two inputs tied together is no bad idea (or any similar HCT logic gate that can pass the signal uninverted), or some other level shifting technique. Also, dropping the Arduino's transmitted 5V level down to 3.3V with a voltage divider (1K + 2K) would ensure that you don't kill the module.

I would write a small sketch that passes whatever you send on the Serial connection through verbatim to your SoftwareSerial connection, and echos back through Serial anything that arrives on SoftwareSerial.

Then, with the module UNPAIRED (LED flashing), send it the AT command (just AT with no line ending in the serial monitor) - it should respond with OK.

You say:

and the TX pin is constantly high

. You may be able to tell that, but many can't

For a test I would slow down the baud rate to 300 baud, and send about 20 characters ever 3 seconds. Put an led on that pin, and you should be able to see if anything is being sent out. Or you may have a scope to make it easier to see.

Thanks a lot for the information!

You said that it stops blinking when it is paired. Then, that step has failed too, since it didn't stop blinking although I installed the device in windows and got two COM ports. But there seem to be many odd issues since I don't get the SoftwareSerial to do ANYTHING, not even blink a led connected to the TX wire.

What pins are you using?

You may try this serial test
http://www.instructables.com/id/Test-arduino-to-arduino-serial-using-softwareSeri/#intro

Tanks for the tip Jackwp! It was indeed only my eyes that were unable to see. I switched the LED around so it is on on low. So at least that part is working :slight_smile: and it is the BT module I should concentrate on.

I got it to work :). But there are some strange issues when using the module with windows 8. First, it installs two comports, for me com7 and com8. I only got com7 to work. Second, not all software using a serial port can connect to it. I've tried with Matlab and with the Arduino IDE with no success. However Tera Term and the SerialPort class in c# (visual studio express 2012) seem to work properly.

I've read some post that one of the ports are for send and one for receive. However for me it is possible to both send and receive with com7 using tera term.

Hope this can be of some help for other people using the JY-MCU BT module.

Using the Arduino IDE with bluetooth typically requires using a special rxtxSerial.dll file - google for it.

Thanks! It worked perfect! Now I can use the Serial Monitor :slight_smile:

Although I'm still a bit puzzled about the other com port that I haven't got working.

garpen:
Thanks! It worked perfect! Now I can use the Serial Monitor :slight_smile:

Although I'm still a bit puzzled about the other com port that I haven't got working.

Well, with Windows who can tell...? Maybe it thought just one COM port would get lonely by itself so it magicked up another one to keep it company. I have seen it do similar things with Wifi - enable a Wifi device and a second Microsoft Virtual WiFi connection appears alongside it to keep it from being lonely.

search for BT Magic reprap. It’s a sketch that auto configs any jymcu module. don’t have a direct link on hand or i’d post it :wink: