Using the Bluetooth module on the ArduinoBT

Woohoo - its working :smiley:

bigengineer - your set control escape line that you gave didn't work. I changed it to:

Serial.println("SET CONTROL ESCAPE 43 00 0");

and the thing burst into life.

Sending the command INQUIRY 5 NAME returned the following:

READY.
INQUIRY 5
INQUIRY 00:0b:0d:4d:fb:f8 020104
INQUIRY 00:10:60:10:76:06 020340
INQUIRY 00:05:c9:fa:71:16 520204
INQUIRY 00:1a:75:f4:44:aaNAME 00:0b:0d:4d:fb:f8 "MWLAPTOP"
NAME 00:10:60:10:76:06 "BTAP-7606"
NAME 00:05:c9:fa:71:16 "banana LG"
NAME 00:1a:75:f4:44:aa "K550i"
NAME 00:18:13:08:c9:98 "What? "

it can be seen that there are some transmission errors somewhere in the data transfer. I wonder if the AVR can keep up with the serial data from the WT-11 when it is writing to the EEProm.

The code I used was:

#include <EEPROM.h>

int ledPin = 13;                // LED connected to digital pin 13
int resetPin = 7;                  // BT module uses pin 7 for reset
char inByte = 0;                // incoming serial byte
int  infoSize = 0 ;
void setup()                    // run once, when the sketch starts
{
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
  pinMode(resetPin, OUTPUT);  
  Serial.begin(115200);        // start serial at 115200 kbs
  
  Serial.println("SET CONTROL ESCAPE 43 00 0"); 
}

void loop()
{
  // if we get a valid byte, read analog ins:
  if (Serial.available() > 0) {    
    inByte = getbyte();  // get incoming byte
    if (inByte == '&' ) { // look for a &
        Serial.print("Got an &  ");
      infoSize = getInfo();
        Serial.println("Done");
    }
    else if (inByte == '@' ) { // look for a 0
      digitalWrite(ledPin, LOW); // set led LOW
      Serial.print("Get string:  ");  
      for(int i=0;i<infoSize;i++) 
      {
        Serial.print(EEPROM.read(i));
      }
      Serial.println();
      Serial.print("Cleared string  size: ");
      Serial.println(infoSize);
    }        
  }
}

int getInfo()
{
  int j=0;
  digitalWrite(ledPin, HIGH); // set led HIGH
  delay(2000);  
  Serial.print("+++");
  delay(2000);

  Serial.println("INQUIRY 5 NAME");
  for (int i=0; i <= 10; i++){
    delay(1000);
    while (Serial.available() > 0 && j <512) {    
      inByte = getbyte();  // get incoming byte    
      EEPROM.write(j, inByte); 
      j++;
    }
    delay(1000);
  }  
  delay(2000);
  Serial.print("+++");
  delay(2000);
  digitalWrite(ledPin, LOW); // set led low
  return j;
}

char getbyte()
{
  while (Serial.available() == 0) { //look for aviable data
    // do nothing, wait for incoming data
  }
  return Serial.read(); //return data if aviable
}

There is still some work to do - finding the cause of the transmission errors and I guess some external SRAM is required as it looks like the string data back from the WT-11 could easily exceed the EEProm and ram in the AVR.

Regards,

Mike