ArduinoGeneral

Sending to DF Bluetooth module

userHead kthxbai 2011-02-10 07:55:55 6255 Views3 Replies
Hi,

I'm using a Romeo V1.0 board with a DF Bluetooth module (It doesn't have a version on it, so I'm assuming 1.0).
I managed to get reading from the bluetooth to work, by opening COM4. However I'm unable to get writing to the board to work. I see that 2 COM boards have been created as a result of the bluetooth driver (COM4 and COM5 in my case).
Am I supposed to read and write to COM4, or open both and using COM4 for reading and COM5 for writing? I tried both, but my program hangs and doesn't open the com5 port. Writing to the COM4 port that is also used for reading resets the board.

I'm using a simple C# program that basically does this:
[code]

writePort = new SerialPort("COM5");
writePort.Open();
writePort.Write("Test");
[/code]

Some more details on this would be appreciated.

2011-02-11 00:21:08 Thanks for the quick replies!

Lauren:
I'm using 115200 baud rate at both sides.
I have the v1.0 version Romeo, so there is no jumper to switch.

Bluetooth module color is black, so apparently v3

My code now prints the number of characters that the PC sent to it, when a button is pressed.
[code]
void setup() {
  Serial.begin(115200);
  Serial.println("Print number of character from input.");
  pinMode(buttonPin, INPUT);   
}

void loop(){
  buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH) {   
    Serial.println("Button pressed. #bytes received:");

    int numBytes = Serial.available();
    Serial.println(numBytes);
    while (digitalRead(buttonPin));
  }
}
[/code]

Now I tested various situations:

- Communicating through USB in SerialMonitor from the arduino SDK: Works as expected.
- Communicating through USB in my C# program: Works as expected.
- Communicating with Bluetooth in SerialMonitor: SerialMonitor wont start, and COM4 is suddenly removed from the list in the Arduino editor. Maybe this is normal behaviour though (?).
- Communcating with Bluetooth in my C# program: Works from MCU to PC. It will print that 0 characters have been received, but when I sent data from PC to MCU, it resets the device, and I will see the text from setup() again.

Note that I removed the USB connector when testing with bluetooth, to be sure no USB communication is messing things up.
The fact that everything works ok with USB indicates to me that the code itself is fine.

I prefer not to use bluesoleil, otherwise I have to use (and buy) that program for each PC. It should really be possible to work without being forced to buy another program.

kind regards,
kthxbai
userHeadPic kthxbai
2011-02-10 17:53:02 BTW, what is the color of your Bluetooth module? Blue or black? If it is black, I believe it is version 3.  And the default baud rate is 9600 bps.

And also, try the IVT BlueSoleil  software (http://www.bluesoleil.com/) .  It will manage the bluetooth port as one serial port which you can read and write data as normal serial port.

userHeadPic R2D2C3PO
2011-02-10 16:46:01 Hello, ;)

1) The baud rate of the DF Bluetooth Module and that of most Bluetooth module is 115200. So you should write baud rate in your code to run your wireless module.

2) Only one com port is available and the other one is virtual.

3) If you are using an old version Romeo, there is a jumper marked "APC_JP" in the center of the board. When using the Wireless Module you should connect the jumper, and disconnect it when uploading your codes.

4) You could try to receive serial message from the romeo first. Because I believe it is easier to debug and easier to prove your C# program is free of bugs.

Try the arduino code below:

[code]void setup()
{
  Serial.begin(115200);
}

void loop()
{
  Serial.println("Bluetooth!"); 
  delay(100);
}[/code]

userHeadPic Lauren