SOLVED: Seeedstudio BT Shield

Hi everyone.I was frustrated because of seedstudio BT is not connecting to my android Phone(samsung vibrant running ICS 4.0.4).after doing lot of change in code i had finaly made a simple code to work with seedstudio BT also u can connect your android phone and send commands to arduino board.

make sure that your jumper connection is as shown in picture it is default arduino serial com port.
Tx of sheild is connected to RX of arduino(Pin 0)
Rx of sheild is connected to TX of arduino(Pin 1)
Baudrate is 38400bps so no need to change baudrate of sheild its default baudrate of sheild.

char val; // variable to receive data from the serial port
int ledpin = 8; // LED connected to pin 48 (on-board LED) 
#include <NewSoftSerial.h>   //Software Serial Port

 
#define DEBUG_ENABLED  1



void setup() { 
  pinMode(ledpin, OUTPUT);  // pin 48 (on-board LED) as OUTPUT
  Serial.begin(38400);       // start serial communication at 9600bps
  
  setupBlueToothConnection();
 } 


void loop() { 
  if( Serial.available() )       // if data is available to read
  {
    val = Serial.read();         // read it and store it in 'val'
  }
  if( val == 'H' )               // if 'H' was received
  {
    digitalWrite(ledpin, HIGH);  // turn ON the LED
  } else { 
    digitalWrite(ledpin, LOW);   // otherwise turn it OFF
  }
  delay(100);                    // wait 100ms for next reading

 } 
 
 
 void setupBlueToothConnection()
{
  Serial.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400
  Serial.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
  Serial.print("\r\n+STNA=SeeedBTSlave\r\n"); //set the bluetooth name as "SeeedBTSlave"
  Serial.print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me
  Serial.print("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here
  delay(2000); // This delay is required.
  Serial.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.
  Serial.flush();
}

This is a simple led toggle program make sure that to upload this program to your arduino board you need a older version of arduino softwae 0022 .you can write any other program like to control servo here we can write PWM Generation program in this sketch.you can send commands from mobile using Bluetooth SPP software.
I had found that seedstudio BT is not going to inquiry mode automatically that means every time it restart MCU need to send the commands to set it to inquirable mode and also set to slave mode.To work with BT sheild need to write this lines in to code
{
Serial.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400
Serial.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
Serial.print("\r\n+STNA=SeeedBTSlave\r\n"); //set the bluetooth name as "SeeedBTSlave"
Serial.print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me
Serial.print("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here
delay(2000); // This delay is required.
Serial.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.
Serial.flush();
}
.

sam.txt (1.48 KB)

Hi again.i had successfully implemented firmata protocol to run with seedstudio BT.now Arduino commander is successfully work with this code.
but you need to change the baud rate of seedstudio BT shield to 9600. only use arduino-0022 to successfully upload this code.


Imgur

Sam1.txt (21 KB)

Do you mind posting your entire sketch?

interesting...
i've had THE EXACT SAME problem about a month ago, also we were talking about it here:

bottom line there was about this:

As said before is probably due to some android's bt broadcomm module bug that does not allow to find Class of device code 0x00

and some semi working workarrounds.

as a result, i bought a new bluetooth module LM-400 and got it up and running in no time (after i figured out that the AT commands from the manual are outdated -> new firmware was on it).

did anyone else have any luck with the method sam_92 suggested a few posts up, so i know if i should take the shield i was already upset about for not working from the box again and give it another try?

Here i am uploading sketch file .look at download section below.login in to arduino forum to able to see uploaded files below.code is too big i am not able to write in post.I am using arduino UNO .make sure you are using older version of arduino like 0022 it won't compile in newer version 1.0 and later on.

For changing the baud rate you need to use USB to 232 breakout board. http://www.wide.hk/products.php?product=CP2102-USB-to-232-Breakout-Board you can use SScom32e software to configure the baud rate.
this sketch will definately work with seedstudio BT modem just make sure that you have configure the baud rate at 9600bps .i had done lot of work to get it work with this sheild. :slight_smile:
Hope you guys soon you will going to enjoy arduino commander it's awesome :slight_smile:
If you are facing any problem to changing the baud rate let me know i will post method to change baud rate of this sheild.

sketch_aug30a.pde (21.4 KB)

Sam1.txt (21 KB)

I am using a Shield, and this is still not working for me. Here is the code I am using:

#include <SoftwareSerial.h> //Software Serial Port
#define RxD 0
#define TxD 3

#define DEBUG_ENABLED 1

SoftwareSerial 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.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();
blueToothSerial.print(recvChar);
}
}
}

void setupBlueToothConnection()
{
blueToothSerial.begin(9600); //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();
}

Any ideas? I am using Samsung Galaxy SII to try to connect, but I am unable to discover. Also the shield is blinking just green, two times per cycle.

This has to be a simple solution.For discover the sheild in your mobile phone red light on sheild must be blinking.First of all try this solution- Push reset switch loacted on arduino board.after pushing reset switch MCU will send the commands to set it to discover mode.

also make sure that you have chenged the baud rate of sheild at hardware level.otherwise u cannot see correct message which you had sent it from pc.if 9600bps does't work then try out with default sheild baud rate which is 38400bps.
Also check jumper connection on sheild .

I solved the problem! The board is labeled backwards; tx and rx need to be reversed in the code to get the board to run!

#define RxD 0

Why are you trying to use the hardware serial pin for software serial?

sam_92:
Here i am uploading sketch file .look at download section below.login in to arduino forum to able to see uploaded files below.code is too big i am not able to write in post.I am using arduino UNO .make sure you are using older version of arduino like 0022 it won't compile in newer version 1.0 and later on.

For changing the baud rate you need to use USB to 232 breakout board. http://www.wide.hk/products.php?product=CP2102-USB-to-232-Breakout-Board you can use SScom32e software to configure the baud rate.
this sketch will definately work with seedstudio BT modem just make sure that you have configure the baud rate at 9600bps .i had done lot of work to get it work with this sheild. :slight_smile:
Hope you guys soon you will going to enjoy arduino commander it's awesome :slight_smile:
If you are facing any problem to changing the baud rate let me know i will post method to change baud rate of this sheild.

I would very much appreciate a post to describe how to change the baud rate of the shield. I cannot figure out how to use the configuration commands.

OK, it's been a while but I have an update. I've got the Arduino Uno R3 with a Seeeduino BT shield able to scan for BT devices; which is what I wanted to start with.

/*  */
#include <SoftwareSerial.h>   //Software Serial Port

#define RxD 5
#define TxD 6
 
#define DEBUG_ENABLED  1

char recvChar;
String recvBuf;
String recvAddr;
String recvInq;

SoftwareSerial blueToothSerial(RxD,TxD);
 
void setup() 
{ 
  Serial.begin(9600);
  pinMode(RxD, INPUT);
  pinMode(TxD, OUTPUT);
  setupBlueToothConnection();
  //wait 1 sec and flush the serial buffer
  delay(1000);
  Serial.flush();
  blueToothSerial.flush();
  Serial.println(" ");
  Serial.println("restarted....");
  Serial.println("Starting BTScan....");

} 

void loop()
{
  btScan();
}

void setupBlueToothConnection()
{
  blueToothSerial.begin(38400); //Set Bluetooth to 38400
  blueToothSerial.print("\r\n+STWMOD=1\r\n");//set bluetooth to master mode
  blueToothSerial.print("\r\n+STNA=PeddleComp\r\n");//set bluetooth name as "PeddleComp"
  blueToothSerial.print("\r\n+STAUTO=0\r\n");// no Auto-connection
  delay(2000); // This delay is required.
  blueToothSerial.flush();
  blueToothSerial.print("\r\n+INQ=1\r\n");//make the master inquire
  delay(2000); // This delay is required.
}
    
void btScan()  //scan for devices
{
  if (blueToothSerial.available())
  {
    recvChar = blueToothSerial.read();
    recvBuf += recvChar;
    if (((recvChar > 47) && (recvChar < 58)) || ((recvChar > 64) && (recvChar < 71)))  // get numbers and A-F only
    {
      recvAddr += recvChar;
      if(recvAddr.length()==12)
      {
        Serial.println(recvAddr);
        recvAddr = "";
        blueToothSerial.flush();
      }
    }
  }
}

If anyone knows a better way to trap the numbers and A-F only; please let me know. BASIC was my first language and that was on a 4K Trash-80 Model I.

If anyone knows a better way to trap the numbers and A-F only; please let me know.

    if ((recvChar >= '0' && recvChar <= '9') || (recvChar >= 'A' && recvChar <= 'F"))  // no comment needed

That's not really a better way; just a little more verbose.
Maybe I'll just write a hex trapping function.

I sent an email to the Arduino Commander people. Got the email from Google Play. They said that UNO R3 does not yet work for the Arduino Commander :confused: They have to get the board and work the bugs out :frowning:

Hopefully there's not that many bugs in there. I haven't been able to get any of the "Google Play" Bluetooth SPP apps to work.
Only what I've listed above about the Arduino being able to detect other Bluetooth devices. But I'm still working on it.

I have similar problem using the bluetooth shield, some phone are not able to see the Arduino while other can...
The code to initialize the BT connection it's just the same as you are using and I keep the baud rate to 38400...

This is an example with video that explain how it works using a Samsung 9003, while if I try to search Arduino and the related BT shiel using a Samsung Next I cannot find the device:-(

This is the link showing how it works on Samsung 9003, what is wrong? Any suggestion?

This is the BT setup source I use
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=E-Scooter\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();

Also I've the same problem, My phone is samsung galaxy ace with android 2.3.3

I am having the exact same problem. Using GS3 to connect to UNO R3 with Seeeduino Bluetooth shield. I tried the code listed at the begining of this thread and I was able to pair with the device but it will not connect in ArduinoCommander. Please keep us posted as to what you hear back from the ArduinoCommander people. Thanks.

total newb here.

i've tried several sketches for the BT shield and i can get "bluetooth inquirable", but i'm not getting the blinking red/green lights. i only get the standard green blinking light.

i've tried different pin locations and different sketches, but have yet to get the red/green blinking lights.

i'm using an uno r3 with the seeedstudio BT shield. any help would be appreciated as i'm about to go crazy.

I've the same problem. Jumpers and TX/RX pin are connected in the correct way but only the green led is blinking...