Bluetooth Shield + Arduino Uno not discoverable!

So I had Bluetooth connected to my computer, it worked like a dream. Then I started getting errors such as serial port seeedstudioBT already in use. That happened for a while, after which the bluetooth shield is never discoverable, my usb serial port says it is inquirable but the LED on the shield keeps blinking green twice per second when it is supposed to blink red and green alternatively. I’m not doing anything special, basically just setting BT up, and I don’t know what to do. What’s worse is that I only just bought this about a week ago. Any help will be appreciated.

Please post code so we can help you… or try this code this is what works for me you can add your code after the line that says…blueToothSerial.print(recvChar);
}

#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);
  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 YOUR CODE HERE
}  
void setupBlueToothConnection()
{
  blueToothSerial.begin(115200); //Set BluetoothBee BaudRate to (115200) the default baud rate is 38400 
  blueToothSerial.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
  blueToothSerial.print("\r\n+STNA=SeedBT\r\n"); //set the bluetooth name as "SeedBT"
  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();
}



if this code doesnt work when uploaded to arduino with bt/module then there may be other issues. Post back success or failure and will try to help further

This is the exact code I’ve been using, even then I tested it with your version and it didn’t help. :frowning:
It still blinks green twice in one second. I’m all out of ideas. Any guesses as to why this is an issue?

Which pins are u using for the BTmodule it comes preset to 6/7 I think. Just stay away from pins 0/1 on arduino as they are used for hardware serial communication… If that isn’t the issue check the wiki page@http://www.seeedstudio.com/wiki/Bluetooth_Shield. And make sure the jumper is set correct for tx&rx. Of course it could be if nothing else a faulty board… If I can help u any other way just let me know…best of luck to you.

Yes,that 's good enough, maybe don’t forget to turn PIO[1] pin of bluetooth shield to A1. NC would cause fault.

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

yeah,we can connect our PC to BT shield.And if your computer don’t have BT,you can use Bluetooth USB Dongle to plug into your PC,that’s very convenient.

I have the same issue, I just copied the code above, uploaded it on my arduino, but I still have the green light blinking twice every sec. HELP PLZ

I am having the same issue. I soldered all pieces onto the board and set my jumpers to rx-6 and tx-7
The green light flashes twice about once a second and I can’t see the bluetooth device on my PC or my android phone. I can of course see my phone from my PC and vice versa.

I have tried running Master and Slave code, and also running the code another user posted to get it working.
I also tried using pins 3 and 4 and changing the code to reflect this.
Tried to upload the code without the shield on the arduino, unplugging the board, putting the shield on, plugging the board back in, it still won’t enterr discoverable mode.

I pulled out my multimeter and checked all my joints and made sure there were no bridges or bad joints and everything checked out fine.
Tried to use jumper wires from the arduino to the shield instead of stacking it on the arduino, no go.

Not sure what else to do.

if you have set the configuration , you need plug the jumper of BT_TX into digital 6 and plug the jumper of BT_RX into digital 7,pls pay attention to this.

Same problem here. Jumpers are plugged as you said, but the best I’ve obtained is the green led blinking twice, then little pause and then bliking again…

If you are still having trouble getting Bluetooth to work then try a different version of arduino ide. I am currently using the 1.0.5 version for linux and windows… Both are able to upload the code and Bluetooth are working flawlessly…

Hi,

I have exactly the same issue. BT shield was working without a glitch for a while and it suddenly just stopped. No matter what sketch I uploaded I always saw the green light blinking twice.

Did anyone managed to solve the problem?

If problem is still occuring, you could try to remove the arduino ide from the pc, and reinstall the latest version. Of course you should make a backup of your sketchbook folder to someplace you will be able to find it. This is the only other way i have been able to get it to work properly again. Once the green blinky occurs, that is. The whole process for me occured as follows :— bluetooth shield attached to arduino upload code red/green blinky- connection occurs… 3 uploads later just green blinky :frowning: Make sure all other bluetooth devices are off… reupload —normally work but in slight chance that it doesnt give the green/red blinky then remove arduino ide ---- reinstall arduino ide reupload code — red/green blinky :slight_smile: This is the process that I have used and have had success with… By no means does this mean that it will work for everyone, but it is worth a shot if you are still having problems getting the bluetooth shield to function… if this does not fix the problem then You can pm me by email at [email protected] for further assistance…

Thanks a lot strigoi !!

After searching the net for more than 2 hours your code plus explanation did the trick :slight_smile: I now am able to connect my Smartphone (Sony Xperia Z) to the Arduino UNO R3 using the Seeedstudio BT Shield.

I am having another question now about it though,… now the problem with the double blinking of LED D1 (green) I have AFTER disconnecting an APP on my Smartphone. Let me describe it in steps:

  • Disconnect the Arduino UNO from the power supply (in my case the connection with the PC)
  • Upload the code (the one down here from strigoi) to the Arduino UNO R3
  • After the upload process, LED D1 on the BT Shield makes a double blink 2 times. After that LED D1 and D2 (red) start to blink alternately.
  • On the Smartphone open the APP with which you want to connect the shield. In my case I used: Bluetooth SPP Pro. Scan for new devices -> the SeeedBT shield will pop up. Connect to it using the standard code 0000.
  • Now only D1 will blink every second 1 time. Also when you connect a LED to port A1 it will now be ON.
  • In the “Byte Stream Mode” of the APP I now can send a 0 or a 1 to the shield which will put OFF or ON LED 13 on the Arduino UNO.
    === Up till here everything works perfectly!
  • Next thing I do is closing the APP on my Smartphone --> LED connected to A1 goes OFF, which it should because there is no connection anymore between the Shield and another device. BUT now D1 (green) on the Shield makes the double blink again every second, and there is NO chance anymore to reconnect to the shield again --> It is not visible anymore on my Smartphone.

How can I solve this that after the Shield gets disconnected it can be reconnected at another moment in time? I would expect the behavior as follows: when disconnecting the APP from the Shield, LEDs D1 and D2 would start alternating again.

Many thanks in advance!

Pieter

I’m sorry to say that is normal behavior. I personally haven’t tried but it could be possible to add in a reset factor after disconnection from Bluetooth. I will give it a try and find out but won’t be till the weekend as I have been busy at work.
If u have any more questions just let me know.

Hi strigoi8183,

What exactly do you mean with a “reset factor after disconnection”? Is there a possibility that the Arduino UNO can check it the BT Shield is still connected to a device? And IF it can do this, HOW can we reset the BT Shield that the red-green LEDs flash again? Is this done by calling the setupBlueToothConnection() function again?

Thanks for helping me with this topic. Without being able te reconnect it has no use for me to use the shield. Actually the goal is that the BT-Shield connects automatically to a paired Smartphone when it sees the Smartphone.

Pieter

Sorry about the slow reply I have just started a third job so my time has been pretty much used up lately. The answer you might be looking for might possibly be unreachable by current programming of bluetooth shield. You might try this link https://github.com/don/BluetoothSerial I believe his code would help you as it has on connection on disconnection and a few other functions that are pretty nice. Hope this helps…

And as far as reconnection just call setupBlueToothConnection() to enter connect mode… after you reset from disconnect

This code gives a template for handling communication (defined as starting and ending with “\r\n”) from the Bluetooth Shield or User (over Bluetooth). Also …

When Android is connecting the Arduino will receive the communication “+BTSTATE:3” (meaning connecting) from the Bluetooth Shield.
When Android is connected the Arduino will receive the communication “+BTSTATE:4” (meaning connected) from the Bluetooth Shield.
When Android disconnects the Arduino will receive the communication “+BTSTATE:1” (meaning ready) from the Bluetooth Shield.
Making the Bluetooth Shield inquirable after receiving the communication “+BTSTATE:1” (meaning ready) will allow new Android connections.

[code]#include <SoftwareSerial.h> // Software Serial Port

// Bluetooth read and write.
#define PIN_BLUETOOTH_RxD 6
#define PIN_BLUETOOTH_TxD 7
SoftwareSerial go_bluetooth_serial(PIN_BLUETOOTH_RxD,PIN_BLUETOOTH_TxD);
// Bluetooth state.
#define BT_UNKNOWN -1
#define BT_INITIALIZING 0
#define BT_READY 1
#define BT_INQUIRING 2
#define BT_CONNECTING 3
#define BT_CONNECTED 4
int gi_bluetooth_state;

// Communication properties.
#define MAX_COMMUNICATION_LENGTH 100

void setup() {
Serial.begin(9600);

// Initialize bluetooth read and write.
pinMode(PIN_BLUETOOTH_RxD, INPUT);
pinMode(PIN_BLUETOOTH_TxD, OUTPUT);
// Initialize bluetooth state.
gi_bluetooth_state = BT_UNKNOWN;
// Initialize bluetooth.
setup_bluetooth();
}

void loop() {
char lc_value;
char lc_peek;
if (go_bluetooth_serial.available()){
// Read from bluetooth.
lc_value = go_bluetooth_serial.read();
// Check for start of communication (defined as starting and ending with “\r\n”).
if (lc_value == ‘\r’) {
lc_peek = go_bluetooth_serial.peek();
if (lc_peek == ‘\n’) {
lc_value = go_bluetooth_serial.read();

    boolean lb_valid = false;
    
    // Parse communication.
    String ls_communication = String();
    for (int ti_index = 0; ti_index < MAX_COMMUNICATION_LENGTH; ti_index += 1) {
      lc_value = go_bluetooth_serial.read();

      if (lc_value == '\r') {
        lc_peek = go_bluetooth_serial.peek();
        if (lc_peek == '\n') {
          lb_valid = true;
          break;
        } else {
          ls_communication += String(lc_value);
        }
      } else {
        ls_communication += String(lc_value);
      }
    }
    
    // Check if valid communication.
    if (lb_valid) {          
      Serial.println(ls_communication); 
      // Handle communication.
      if (handle_communication(ls_communication) == false) {
        Serial.println("Communication not handled.");
      }
    }
  }
}

}
}

// Initialize bluetooth.
void setup_bluetooth() {
Serial.println(“Set baud rate to 38400.”);
go_bluetooth_serial.begin(38400);
Serial.println(“Set to work in slave mode.”);
go_bluetooth_serial.print("\r\n+STWMOD=0\r\n");
Serial.println(“Set name as SeeedBT.”);
go_bluetooth_serial.print("\r\n+STNA=SeeedBT\r\n");
Serial.println(“Permit paired device to connect.”);
go_bluetooth_serial.print("\r\n+STOAUT=1\r\n");
Serial.println(“Auto-connection turned off.”);
go_bluetooth_serial.print("\r\n+STAUTO=0\r\n");
Serial.println(“Set pin to 0000.”);
go_bluetooth_serial.print("\r\n+STPIN=0000\r\n");
Serial.println(“Request to input pin.”);
go_bluetooth_serial.print("\r\n+RTPIN=0000\r\n");
delay(2000); // This delay is required.
Serial.println(“Make inquirable.”);
go_bluetooth_serial.print("\r\n+INQ=1\r\n");
delay(2000); // This delay is required.
go_bluetooth_serial.flush();
}

// Write to bluetooth.
boolean write_bluetooth(String as_message) {
if (gi_bluetooth_state == BT_CONNECTED) {
go_bluetooth_serial.print(as_message);
go_bluetooth_serial.flush();
return true;
} else {
return false;
}
}

// Handle communication.
boolean handle_communication(String as_communication) {
boolean lb_handled = false;

// Handle communication regarding bluetooth state.
// “\r\n+BTSTATE:x\r\n”
// x = Status
// 0 = Initializing
// 1 = Ready
// 2 = Inquiring
// 3 = Connecting
// 4 = Connected
if (as_communication == String("+BTSTATE:0")) {
gi_bluetooth_state = BT_INITIALIZING;
lb_handled = true;
} else if (as_communication == String("+BTSTATE:1")) {
gi_bluetooth_state = BT_READY;
// Initialize bluetooth (to make inquirable).
setup_bluetooth();
lb_handled = true;
} else if (as_communication == String("+BTSTATE:2")) {
gi_bluetooth_state = BT_INQUIRING;
lb_handled = true;
} else if (as_communication == String("+BTSTATE:3")) {
gi_bluetooth_state = BT_CONNECTING;
lb_handled = true;
} else if (as_communication == String("+BTSTATE:4")) {
gi_bluetooth_state = BT_CONNECTED;
lb_handled = true;
} else {
// Handle other communication.
if (as_communication == String("+ECHO")) {
if (write_bluetooth("\r\n+ECHO\r\n")) {
lb_handled = true;
}
}
}

return lb_handled;
}[/code]Hope it helps!

  • The reason for the numerous edits is because I just received the Bluetooth Shield and the code has been a work in progress. :smiley:

:bulb: