Pages: [1]   Go Down
Author Topic: [SOLVED] Seeeduino Stalker v2.2 / Bluetooth Bee access problem  (Read 1567 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi there.
I'm quite new to the arduino programming. I am using a Seeeduino Stalker v2.2 with a Bluetooth Bee (WLS125E1P) module placed directly on the bee series socket on the stalker. the board is connected to pc via uartsbee (see attachment 1). I tried that wiki sample code (just some serial outputs modified) believing pins 1 and 2 should be the right ones (after trying unmodified sample code with pins 11/12 -> not working):

Code:
#include <SoftwareSerial.h>   //Software Serial Port
#define RxD 1
#define TxD 2
 
#define DEBUG_ENABLED  1
 
SoftwareSerial blueToothSerial(RxD,TxD);
 
void setup()
{
    Serial.begin(9600);
    pinMode(RxD, INPUT);
    pinMode(TxD, OUTPUT);
    setupBlueToothConnection();
 
}
 
void loop()
{
  //Typical Bluetoth command - response simulation:
 
  //Type 'a' from PC Bluetooth Serial Terminal
  //See Bluetooth Bee - Wiki for instructions
 
  if(blueToothSerial.read() == 'a')
  {
    blueToothSerial.println("You are connected");
    //You can write you BT communication logic here
  }
 
}
 
 
void setupBlueToothConnection()
{
    Serial.print("Setting up bluetooth bee..");
    blueToothSerial.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400
//    blueToothSerial.begin(115200); //Set BluetoothBee BaudRate
    delay(1000);
    sendBlueToothCommand("\r\n+STWMOD=0\r\n");
    sendBlueToothCommand("\r\n+STNA=AP_BB\r\n");
    sendBlueToothCommand("\r\n+STAUTO=0\r\n");
    sendBlueToothCommand("\r\n+STOAUT=1\r\n");
    sendBlueToothCommand("\r\n +STPIN=0000\r\n");
    delay(2000); // This delay is required.
    sendBlueToothCommand("\r\n+INQ=1\r\n");
    delay(2000); // This delay is required.
}
 
//Checks if the response "OK" is received
void CheckOK()
{
  char a,b;
  while(1)
  {
    if(blueToothSerial.available())
    {
      Serial.print("Available..");
      a = blueToothSerial.read();
      Serial.println(a);
    if('O' == a)
    {
      // Wait for next character K. available() is required in some cases, as K is not immediately available.
      while(blueToothSerial.available())
      {
         b = blueToothSerial.read();
         //Serial.println(b);
         break;
      }
      if('K' == b)
      {
        break;
      }
    }
   }
  
  }
  //Serial.print("Ok");
  while( (a = blueToothSerial.read()) != -1)
  {
    //Wait until all other response chars are received
  }
}
 
void sendBlueToothCommand(char command[])
{
    Serial.print(command);
    blueToothSerial.print(command);
    CheckOK();  
}

you can see the output in attachment 2 ("ending" with an infinite "Available..x" loop..). what am i doing wrong? wrong pins? if yes.. which are the right pins (and how can i determine the right pins next time)? can i use the bluetooth bee directly on that bee socket or have i to use a bees shield?

i hope someone can help me or at least give me some hints.

thanks in advance,
apbs


* 20121023_133825[1].jpg (160.41 KB, 640x480 - viewed 47 times.)

* output_p1_p2.PNG (11.9 KB, 274x651 - viewed 41 times.)
« Last Edit: October 26, 2012, 03:42:32 am by apbs » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 614
Posts: 49376
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I tried that wiki sample code (just some serial outputs modified) believing pins 1 and 2 should be the right ones (after trying unmodified sample code with pins 11/12 -> not working):
Did you mean pins 0 and 1?

If so, your code doesn't reflect that. And, you can't do SoftwareSerial on the hardware serial pins. Especially while still trying to do hardware serial on them.

A link to the shield you are using would be useful. If the manufacturer supplies sample code that says that the bluetooth device is connected to some pins, I think I'd accept the fact that the device IS connected to those pins.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks for the reply.

i am using this one: http://www.seeedstudio.com/wiki/Seeeduino_Stalker_v2.2 with the bluetooth bee: http://www.seeedstudio.com/wiki/Bluetooth_Bee. Regarding the schematics http://www.seeedstudio.com/wiki/images/f/fb/Stalker_v2.2_schematic.pdf .. would pin 0 (rxd) and pin 1 (txd) be right for the cummunication with the bluetooth bee?

but arent these pins used for the serial communication with my pc (connected to pc via http://www.seeedstudio.com/wiki/UartSBee_V4? so it occures to me like i cant use the bee socket when the board is connected to my pc? i am confused.. im sorry if these question sounds stupid - as i mentioned i am quite new to arduino.


apbs
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 614
Posts: 49376
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Regarding the schematics http://www.seeedstudio.com/wiki/images/f/fb/Stalker_v2.2_schematic.pdf .. would pin 0 (rxd) and pin 1 (txd) be right for the cummunication with the bluetooth bee?
Yes, they would.

Quote
but arent these pins used for the serial communication with my pc
Yes, they are.

You get to choose which device (PC or bluetooth) you want to talk to. Both is not an option. With that board, anyway. The XBee shields I have allow selecting which pins (0 and 1 or 2 and 3) to use. Not perfect, since those are the external interrupt pins, but better than the "screw you, we'll tell you which pins to use" shield you have.

Quote
i am confused.. im sorry if these question sounds stupid
Not at all. What's stupid is the lack of choice built into the shield.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks.
i deleted that "Serial.print.." statements, disconnected from pc, now using a battery and et voila - it works as intended.

=> solved smiley
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

apbs....can you please send me the modified code to setup the bluetooth bee...i have been trying to setup the bee to no avail....i am using io expansion shield v5  http://www.dfrobot.com/index.php?route=product/product&filter_name=v5&product_id=264#.UNoIPm_qljI
Logged

Pages: [1]   Go Up
Jump to: