How to send data from Android to Bluetooth Shield ?

Hi,
I just received a Bluetooth shield this morning and I tested the communication between it and Arduino Mega. I followed the instruction from wiki but I could not send data from my Galaxy S to Bluetooth Shield. This is really strange because my galaxy S can receive any data sent from Bluetooth Shield.
Can anyone help me ?
Thanks

I think your software (in Arduino) excepted a control character like 0x0A or 0x0D or both.
Please show us your source code!

I use only the code from wiki

#include <NewSoftSerial.h> //Software Serial Port
#define RxD 6
#define TxD 7

#define DEBUG_ENABLED 1

NewSoftSerial blueToothSerial(RxD,TxD);

void setup()
{
Serial.begin(9600);
pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
setupBlueToothConnection();

}

void loop()
{
char recvChar;
while(1){
if(blueToothSerial.available()){//check if there’s any data sent from the remote bluetooth shield
recvChar = blueToothSerial.read();
Serial.println(recvChar);
}
if(Serial.available()){//check if there’s any data sent from the local serial terminal, you can add the other applications here
recvChar = Serial.read();
blueToothSerial.println(recvChar);
}
}
}

void setupBlueToothConnection()
{
blueToothSerial.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400
blueToothSerial.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
blueToothSerial.print("\r\n+STNA=SeeedBTSlave\r\n"); //set the bluetooth name as “SeeedBTSlave”
blueToothSerial.print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me
blueToothSerial.print("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here
delay(2000); // This delay is required.
blueToothSerial.print("\r\n+INQ=1\r\n"); //make the slave bluetooth inquirable
Serial.println(“The slave bluetooth is inquirable!”);
delay(2000); // This delay is required.
blueToothSerial.flush();
}
Thanks

Hm ok.
Jumper for connection to Pin 6 & 7 correct (factory default?!)?

Yes, 6 and 7.
Edit: I use an app on market named Bluetooth SPP for sending and receiving data from my galaxy S

Looks ok.
Can you send data from a pc?

Hello,
I tried but fail all the time. It seems that my bluetooth shield can only data to another device.

Up.
Can anyone help me ?

As the Rx of Software serial library is not supported on Mega 2560, you can not use that directly for Bluetooth Shield.
But there’s still a way that you can make that:

  1. Use the hardware serial port (saying Tx3, Rx3)of Mega directly to communicate with Bluetooth Shield.
  2. Connect the Rx and Tx of BT Shield to Tx3 and Rx3.
  3. Remove and change the Software serial code to Serial3.
    Try the following code:

[code]/*
BluetoothShield Demo Code Slave.pde. This sketch could be used with
Master.pde to establish connection between two Arduino. It can also
be used for one slave bluetooth connected by the device(PC/Smart Phone)
with bluetooth function.
2011 Copyright © Seeed Technology Inc. All right reserved.

Author: Steve Chang

This demo code is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

For more details about the product please check http://www.seeedstudio.com/depot/

*/

/* Upload this sketch into Seeeduino and press reset*/

//#include <SoftwareSerial.h> //Software Serial Port
//#define RxD 6
//#define TxD 7

#define DEBUG_ENABLED 1

//SoftwareSerial blueToothSerial(RxD,TxD);

void setup()
{
Serial.begin(9600);
Serial3.begin(38400);
//pinMode(RxD, INPUT);
//pinMode(TxD, OUTPUT);
setupBlueToothConnection();

}

void loop()
{
char recvChar;
while(1){
if(Serial3.available()){//check if there’s any data sent from the remote bluetooth shield
recvChar = Serial3.read();
Serial.print(recvChar);
}
if(Serial.available()){//check if there’s any data sent from the local serial terminal, you can add the other applications here
recvChar = Serial.read();
Serial3.print(recvChar);
}
}
}

void setupBlueToothConnection()
{
Serial3.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400
Serial3.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
Serial3.print("\r\n+STNA=SeeedBTSlave\r\n"); //set the bluetooth name as “SeeedBTSlave”
Serial3.print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me
Serial3.print("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here
delay(2000); // This delay is required.
Serial3.print("\r\n+INQ=1\r\n"); //make the slave bluetooth inquirable
Serial.println(“The slave bluetooth is inquirable!”);
delay(2000); // This delay is required.
Serial3.flush();[/code]