I’ve been trying to set up the Arduino Bluetooth shield, but I haven’t been having much luck. I believe I have the pins set up correctly, and I’ve uploaded the Slave program to the Arduino, but I can’t get Windows 7 to pair with it, and only the green LED is blinking, not the red one. Here is the code I’m using:
#include <SoftwareSerial.h> //Software Serial Port
#define RxD 7
#define TxD 6
#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(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+STPIN=0000\r\n");//Set SLAVE pincode"0000"
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();
}
I’ve attached a photo of the Arduino as it is set up now. Any help would be much appreciated.
Interestingly I have been using the same setup as you and having the problem with the green light not intermittently. Seems as if the Bluetooth shield is only occasionally getting commands?
Everything seems to be talking fine, but occasionally no dice!
I also am having intermittent problems. My setup has the BT shield set up as slave, and it is pairing with BT on my PC. Sometimes, the pairing works just fine, I see the light’s flashing red/green, and then green when connected. Other times, the light only flashes green, does not do the red/green flashing indicating it is inquiring and trying to connect to PC. Not sure why it sometimes works, and other times doesn’t. Generally, I have to delete the BT device from my computer and re-add it to get them to connect again. Anyone have any ideas?
Most of the funkiness I’ve been dealing with on the shield has come from either A. Trying to upload programs without wanting to unplug the shield and plug it back in B. Not being able to reconnect to the shield after getting a successful connection and losing it.
I think I can fix B by spending some time working on the included code, but for A, are there any Seeed engineers or experienced users who know whether there is a correct way to upload a new program without going through the hassle of unplugging the Arduino, unplugging the BT shield, plugging in the Arduino, uploading the program, unplugging the Arduino, plugging in the shield, and plugging the Arduino/shield back in??
i’m having difficulty getting the red/green pairing lights to appear. in my attempts to communicate with the board i only receive odd symbols in return, but this is after getting slave is inquiring successfully.
a sketch, photos, and tutorial would be nice. it feels like i’ve tried every type of jumper combination and every type of code available, but i can’t get proper communication or red/green lights.
For those that are having problems getting BTShield to work properly This is what I have done to get it to function as wanted…
#include <SoftwareSerial.h> //Software Serial Port
#define RxD 6
#define TxD 7
#define DEBUG_ENABLED 1
SoftwareSerial blueToothSerial(RxD,TxD);
int led = 13;
void setup()
{
Serial.begin(9600);
pinMode(led, OUTPUT); // led onboard arduino uno pin 13
pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
setupBlueToothConnection();
}
void loop()
{
char recvChar;
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);
}
// ADD Code HERE:
if (recvChar == '0' ) // if input from serial is = 0
{
digitalWrite(led, LOW); // turn off led on arduino uno pin 13
delay(45);
}
if (recvChar == '1') // if input from serial is = 1
{
digitalWrite(led, HIGH); // turn on led on arduino uno pin 13
delay(45);
}
}
void setupBlueToothConnection()
{
blueToothSerial.begin(38400); //Set BluetoothBee BaudRate to 38400 ..default baud rate 38400 (btShield plays nicely at default baud rate)
blueToothSerial.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
blueToothSerial.print("\r\n+STNA=SeeedBT\r\n"); //set the bluetooth name as "SeeedBT"
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
blueToothSerial.print("\r\n+STPIN=0000\r\n");//set pin to 0000
blueToothSerial.print("\r\n+RTPIN=0000\r\n");// ask to input pin
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();
}
All I did was attach BT shield to arduino then upload code unplug arduino wait 5 seconds replug the arduino and wait for red and green led to blink alternatively…Normally takes 3-5 secs to initiate… Once leds are blinking then you should b able to connect with other device to seeedBT… for (windows 7) i found that once you upload code unplug arduino and replug arduino back in that if you open the serial monitor in arduino ide windows will pop up a alert box saying (A bluetooth device is trying to connect click here to allow) once you click the alert it will ask for pincode, which is 0000 . Once entered all should be well in BT land and you should be able to enter 0 or 1 in serial monitor and watch led onboard arduino turn on/off…enjoy
Maybe because of the pin of PIO0. When pulling PIO0 high will disconnect current working Bluetooth device,but unfortunately, we don’t solder this pin on bluetooth, so we can’t cut the connection between two devices. And this cause some problems, maybe we need plug it out of Arduino first,and then plug it on Arduino next, it would work again
We have paid attention to this question, so we will fine down this in next version.