Bluetooth Bee: PIO1 - where art thou?

Hello everyone.

I am trying to build a temperature logger which sends its logged data via bluetooth to an android device if its connected. the problem for me right now is - how can i determine whether a device is connected or not? I am using http://www.seeedstudio.com/wiki/Bluetooth_Bee on http://www.seeedstudio.com/wiki/Seeeduino_Stalker_v2.2.


#include <stdlib.h> 
#include <SD.h>
#include <Wire.h>
#include "DS3231.h"
#include <SoftwareSerial.h>

#define RxD 0
#define TxD 1

DS3231 RTC; //Create the DS3231 object
SoftwareSerial blueToothSerial(RxD,TxD);

// On the Ethernet Shield, CS is pin 4. Note that even if it's not
// used as the CS pin, the hardware CS pin (10 on most Arduino boards,
// 53 on the Mega) must be left as an output or the SD library
// functions will not work.
const int chipSelect = 10;

void setup()
{
  Wire.begin();
  RTC.begin();

  pinMode(RxD, INPUT);
  pinMode(TxD, OUTPUT);
  setupBlueToothConnection();

  // make sure that the default chip select pin is set to
  // output, even if you don't use it:
  pinMode(10, OUTPUT);
  
  SD.begin(chipSelect);
}

void loop()
{
  RTC.convertTemperature();
  DateTime currentTime = RTC.now(); //get the current date-time
  // make a string for assembling the data to log:
  String dataString = "";
  
  dataString += readTimestamp(currentTime);
  dataString += ';';
  float temp = RTC.getTemperature();
  char b[25];
  dtostrf(temp, 1, 2, b);
  dataString += b;

  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  File dataFile = SD.open("datalog.csv", FILE_WRITE);
 
  
  // if the file is available, write to it:
  if (dataFile) {
    dataFile.println(dataString);
    dataFile.close();
  }   
  delay(10000);
}

String readTimestamp(DateTime thisTime) {
  // concatenate a string with all the parts of the date and time:
  String result = String(thisTime.date());
  result +="/";
  result +=String(thisTime.month());
  result +="/";
  result +=String(thisTime.year());
  result +=" ";
  result +=String(thisTime.hour());
  result +=":";
  result +=String(thisTime.minute());
  result +=":";
  result +=String(thisTime.second());
  return result; 
}

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=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())
    {
      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();
         //Serial.println(b);
         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();   
}


connection to android device works fine. writing data to sd card works fine. but i want to send the data of the sd card to connected android device IF (and only if) there is a connected device. i read in the wiki of bt bee

 Status instruction port PIO1: low-disconnected, high-connected; 

can i check whether pio1 is high or low? if i can… which pin is it to check? For me (im not an electrician…) in http://www.seeedstudio.com/wiki/images/f/fb/Stalker_v2.2_schematic.pdf it looks like pio1 (which here should be bee_rssi?) of the bee socket is not connected to any pin of the board?

so if anyone can help me to find out whether a device IS connected to my bluetooth bee… do it pls! :slight_smile:

thanks in advance.

apbs

it’s in pin 6 of the Bee socket:
PIO1.jpg
And you need wire this pin to one of Stalker I/O Port to read.

Thanks
Albert