Hello all,
I’m trying to get a Bluetooth Bee working with the example as set out on the wiki page.
However, while the program appears to be doing its job, the red and green LEDs do not light up (the green LED double blinks per second), and I am unable to connect from my Macbook or Huawei U8300.
In fact, I’ve needed to comment out the “CheckOK” routine, as it was impeding program flow.
At the moment, I don’t possess a UartSBee, but thats next on my list if I can’t get an answer from anyone. In the meantime, I’ll paste my code for one and all to look at:
/* Upload this sketch into Seeeduino and press reset*/
#include <NewSoftSerial.h> //Software Serial Port
#define RxD 8
#define TxD 7
#define DEBUG_ENABLED 1
NewSoftSerial blueToothSerial(RxD,TxD);
void setup()
{
Serial.begin(9600);
pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
setupBlueToothConnection();
}
void loop()
{
if(blueToothSerial.read() == 'a')
{
blueToothSerial.println("You are connected to Bluetooth Bee");
//You can write you BT communication logic here
}
}
void setupBlueToothConnection()
{
Serial.print("Setting up Bluetooth link");
blueToothSerial.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400
delay(1000);
sendBlueToothCommand("\r\n+STWMOD=0\r\n");
sendBlueToothCommand("\r\n+STNA=modem\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.
blueToothSerial.print("\r\n");
blueToothSerial.print("+INQ=1");
blueToothSerial.print("\r\n");
delay(2000); // This delay is required.
Serial.print("Setup complete");
}
/*
//Checks if the response "OK" is received.
void CheckOK()
{
char a,b;
while(1)
{
if(int len = blueToothSerial.available())
{
a = blueToothSerial.read();
if('O' == a)
{
b = blueToothSerial.read();
if('K' == b)
{
break;
}
}
}
}
while( (a = blueToothSerial.read()) != -1)
{
//Wait until all response chars are received
}
}
*/
//Send the command to Bluetooth Bee
void sendBlueToothCommand(char command[])
{
blueToothSerial.print(command);
//CheckOK();
}
Hopefully someone will have some insight.
Thanks!
Boris.