Hello,…
today i recieved a DFRobot IO Expansions Shield V5 and a Seeeduino Bluetooth Bee Standalone. My Problem is that i cant get it work together. When i plug the Xbee on the IO shield and run this code, my arduino can not be found as Bluetooth. When i plug the Bee on my Mega Sensor Shield on the COM2-Socket for XBees and set the Tx/Tx-Pin in the Code then it works.
Whats wrong?
Thanks
Peter
/*
BluetoothBee Demo Code - Delay Based Implementaion
2011 Copyright (c) Seeed Technology Inc. All right reserved.
Author: Visweswara R
This demo code is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
For more details about the product please check http://www.seeedstudio.com/depot/
*/
/* Upload this sketch into Seeeduino and press reset*/
#include <NewSoftSerial.h> //Software Serial Port
#define RxD 0
#define TxD 1
NewSoftSerial blueToothSerial(RxD,TxD);
void setup()
{
//Serial.begin(38400); //Serial port for debugging, Comment this line if not required
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"); //For debugging, Comment this line if not required
blueToothSerial.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400
delay(1000);
sendBlueToothCommand("\r\n+STWMOD=0\r\n");
sendBlueToothCommand("\r\n+STNA=Arduino\r\n");
sendBlueToothCommand("\r\n+STAUTO=0\r\n");
sendBlueToothCommand("\r\n+STOAUT=1\r\n");
sendBlueToothCommand("\r\n+STPIN=987654\r\n");
delay(2000); // This delay is required.
blueToothSerial.print("\r\n+INQ=1\r\n");
delay(2000); // This delay is required.
Serial.print("Setup complete");
}
void sendBlueToothCommand(char command[])
{
char a;
blueToothSerial.print(command);
Serial.print(command); //For debugging, Comment this line if not required
delay(3000);
while(blueToothSerial.available()) //For debugging, Comment this line if not required
{ //For debugging, Comment this line if not required
Serial.print(char(blueToothSerial.read())); //For debugging, Comment this line if not required
} //For debugging, Comment this line if not required
}