Hi everybody, I’m trying to make work a bluetooth bee module on a bees shield with arduino UNO R3.
seeedstudio.com/depot/blueto … p-598.html
seeedstudio.com/depot/bees-shield-p-672.html
It’s seem not work to me.
I want to make a simple discovery of all nearby MAC address.
I put the jumper BEE_1 RX on PIN 5 and BEE_1 TX pin PIN 6
And the code that i use , is this:
#include <SoftwareSerial.h> //Software Serial Port
#define RxD 5
#define TxD 6
#define DEBUG_ENABLED 1
char recvChar;
String recvBuf;
String recvAddr;
String recvInq;
SoftwareSerial blueToothSerial(RxD,TxD);
void setup()
{
Serial.begin(9600);
pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
setupBlueToothConnection();
//wait 1 sec and flush the serial buffer
delay(1000);
Serial.flush();
blueToothSerial.flush();
Serial.println(" ");
Serial.println("restarted....");
Serial.println("Starting BTScan....");
}
void loop()
{
btScan();
}
void setupBlueToothConnection()
{
blueToothSerial.begin(38400); //Set Bluetooth to 38400
blueToothSerial.print("\r\n+STWMOD=1\r\n");//set bluetooth to master mode
blueToothSerial.print("\r\n+STNA=MyBTname\r\n");//set bluetooth name
blueToothSerial.print("\r\n+STAUTO=0\r\n");// no Auto-connection
delay(2000); // This delay is required.
blueToothSerial.flush();
blueToothSerial.print("\r\n+INQ=1\r\n");//make the master inquire
delay(2000); // This delay is required.
}
void btScan() //scan for devices
{
if (blueToothSerial.available())
{
recvChar = blueToothSerial.read();
recvBuf += recvChar;
if (((recvChar > 47) && (recvChar < 58)) || ((recvChar > 64) && (recvChar < 71))) // get numbers and A-F only
{
recvAddr += recvChar;
if(recvAddr.length()==12)
{
Serial.println(recvAddr);
recvAddr = "";
blueToothSerial.flush();
}
}
}
}
It’s seems correct, but the blueToothSerial does not seem turn available.
My question is:
If the code is correct, it is possible that the two components are not compatible?
What could be wrong?
Thanks in advance