Hi,
Any ideas why a bluetooth bee will successfully become inquirable but then fail (go nin-inquirable) when attempting to pair a laptop or an android device with it?
Solved. See comment below:
B
Hi,
Any ideas why a bluetooth bee will successfully become inquirable but then fail (go nin-inquirable) when attempting to pair a laptop or an android device with it?
Solved. See comment below:
B
It turns out the problem is a little more complex than first noted. The BT Bee can (and is) made “inquirable” and can be paired with a laptop / android device, though it is having issues pairing with a mac laptop; it did pair successfully a few times during testing to the macbook I use but has not been able to be paired consistently - anyhow.
The Sony tablet I use does pair successfully but the data is very, very slow to come across. Because of a defect in the Seeeduino Stalker 3’s design you can’t use software serial - this was a new revelation and one that has made the work just a little more annoying and limiting since it means using hardware serial.
The connection is slow - as in very slow. Data taking many seconds to be received in most cases. The bigger problem is what happens when the paired device is disconnected - the BT bee isn’t switching back to ‘inquirable’ mode.
The pairing actually works - it’s what happens after you un-pair - the BR bee remains ‘paired’ and won’t reset to inquirable.
The question becomes, how do I test for a paired connection at the arduino level and if no active pairing is found the reset to inquirable?
B
A solution, and code for anyone dragging themselves through the muck trying to get a seeeduino stalker 3 (or 2.3) to run with a bluetooth bee.
A couple of things. One, it’s still a little slow. Two, there’s probably a solution to that, I just haven’t found it yet.
The sketch below will connect you, and disconnect you based on sending a simple command and then the bluetooth bee witll return to “inquirable” mode. You’re welcome.
Note: you CAN NOT use software serial on the Seeeduino Stalker 3 - there’s an acknowledged defect in the board. This solution will work (and does work) I’ve got it running on 5 data loggers: two with Stalker 2.3’s and 3 with Stalker 3’s.
So, ready?
First: Solder two lead: One from pin PIO0 to Digital pin 9 and one from PIO1 to Analog pin A1. (see photo)
Second: load this sketch to your base shield and reset it.
#define BTDisc 9
int A1State;
char inChar = 0;
void setup(){
//the setup and initialization
Serial.begin(38400);
pinMode(BTDisc, OUTPUT);
setupBlueToothConnection();
}
void loop()
{
//you know, for looping over things.
if (Serial.available()) {
inChar = Serial.read();
if(inChar == 'd'){
//make inquirable
disconnectBT();
}
if(inChar == 'r'){
//reset bluetooth
setupBlueToothConnection();
}
if(inChar == 'f'){
//flush bluetooth
Serial.flush();
}
}
}
void setupBlueToothConnection()
{
Serial.print("\r\n+STWMOD=0\r\n");
Serial.print("\r\n+STNA=BlueStalker\r\n");
Serial.print("\r\n+STAUTO=0\r\n");
Serial.print("\r\n+STOAUT=1\r\n");
Serial.print("\r\n+STPIN=0000\r\n");
delay(2000); // This delay is required.
Serial.print("\r\n+INQ=1\r\n");
delay(2000); // This delay is required.
Serial.flush();
}
void disconnectBT()
{
A1State = analogRead(A1);
if((A1State >= 258))
{
Serial.println(F("Disconnect issued while BT Device is connected - Disconnecting"));
//Set D9 high then low.
delay(500); //Allow current buffer flush to complete. Using black magic to decide on half a second here.
digitalWrite(BTDisc, HIGH);
delay(500);
digitalWrite(BTDisc, LOW);
Serial.print("\r\n+INQ=1\r\n");
//setupBlueToothConnection();
}
if((A1State <= 258))
{
Serial.println(F("Disconnect issued while BT Device is disconnected - Ignoring"));
//Should never happen. Do nothing I guess?
}
}
Third: open the serial monitor to make sure it’s all working.
You should see this:
+STWMOD=0
+STNA=BlueStalker
+STAUTO=0
+STOAUT=1
+STPIN=0000
+INQ=1
And the lights on the Bluetooth bee will alternate red/yellow (or whatever the colours you have) and the BT Bee is ready to be paired.
Fourth: pair it with an Android phone or tablet. (Apple mobile devices won’t work - that’s the way the Apple falls)
Now that you’re “connected” issue a few harmless commands from the list then when you get bored enter “d” and the BT Bee will disconnect and will return to an “inquirable” state.
NOTE: You NEED the jumpers for the disconnect to work. You can’t get the state of the BT Bee without A1 and you can’t reset the BT Bee without Pin 9 - you can pick whichever pins you want as long as they’re available - but you’ll need them.
You can thank later.
B