Stalker 3 and 2.3 + BT Bee - solution

wireless communication and related Bees.

Moderators: lily.li, violet, jessie

Post Reply
byronjbignell
Pre-kindergarten
Pre-kindergarten
Posts: 20
Joined: Sat Apr 27, 2013 9:48 pm

Stalker 3 and 2.3 + BT Bee - solution

Post by byronjbignell » Mon Mar 02, 2015 9:55 am

So here's 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 will 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)
Screen Shot 2015-03-01 at 5.57.07 PM.png
Second: load this sketch to your base shield and reset it and DISCONNECT the UartSBee...

Code: Select all

#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:

Code: Select all

    +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

Post Reply