Hi, everyone, i am a newbie to bluetooth bee. i have connected the bluetooth bee standalone (seeedstudio.com/depot/Grove- … p-774.html), the problem is how to write the code?
the below code is the sample from this website (seeedstudio.com/wiki/Bluetoo … Standalone), this website was using grove LED instead of using the grove temperature sensor.
#include <NewSoftSerial.h> //Software Serial Port
#define RxD 2
#define TxD 3
#define DEBUG_ENABLED 1
NewSoftSerial blueToothSerial(RxD,TxD);
void setup()
{
pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
pinMode(5,OUTPUT);
setupBlueToothConnection();
}
void loop()
{
unsigned char control;
unsigned char temp;
while(temp!=‘4’) {
temp=blueToothSerial.read();
}
Serial.println(“You are connected”);
blueToothSerial.print(“You are connected”); //You can write you BT communication logic here
while(1) {
temp=blueToothSerial.read();
switch(temp) {
case ‘O’:{while(temp!=‘N’) {temp=blueToothSerial.read();} digitalWrite(5,HIGH);break;}
case ‘S’:{while(temp!=‘H’) {temp=blueToothSerial.read();} digitalWrite(5,LOW);break;}
default:break;
}
}
}
void setupBlueToothConnection()
{
blueToothSerial.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400
delay(1000);
sendBlueToothCommand("\r\n+STWMOD=0\r\n");
sendBlueToothCommand("\r\n+STNA=SeeedBluetooth-st\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())
{
a = blueToothSerial.read();
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();
break;
}
if('K' == b)
{
break;
}
}
}
}
while( (a = blueToothSerial.read()) != -1)
{
//Wait until all other response chars are received
}
}
void sendBlueToothCommand(char command[])
{
blueToothSerial.print(command);
CheckOK();
}
so, how do i change the code and let bluetooth bee run with the grove temperature sensor?
that’s all for my questions, thank you very much for spending time to view my message, and please kindly reply me over here if anyone know this solution, thanks!