Teensy 3.1 trouble with Bluetooth and Android

Status
Not open for further replies.

vcxzzxcv

New member
I am using a Teensy microcontroller (https://www.pjrc.com/teensy/teensy31.html) to connect to an Android application to get Bluetooth.

I have used this Android application with other embedded bluetooth devices successfully, however now I am running into the following error I see in LogCat:

04-02 20:06:29.713: E/BTLD(5499):
######################################################################
04-02 20:06:29.713: E/BTLD(5499): #
04-02 20:06:29.713: E/BTLD(5499): # WARNING : BTU HCI(id=0) command timeout. opcode=0x405
04-02 20:06:29.713: E/BTLD(5499): #
04-02 20:06:29.713: E/BTLD(5499): ######################################################################

I have zero idea where this error is coming from. I also see the following error occasionally:

04-02 20:25:19.242: E/bt-btif(914): DISCOVERY_COMP_EVT slot id:11, failed to find channle, status:1, scn:0

The worst part is, with my current hardware setup, half the time it will work, the other half it wont. And I have no clue why. For reference, I am using this bluetooth module: https://www.sparkfun.com/products/12577 And I have the pins connected:

Vcc <---> Vcc
GND <---> GND
TX (BT) <---> RX1 (Teensy)
RX (BT) <---> TX1 (Teensy)

The lack of consistency is killing me. Sometimes just pushing the reset button on the Teensy fixes it.

I am working off of this tutorial: http://stafava.blogspot.ca/2012/12/connect-teensy-to-bluetooth-module.html Here is the Ardunio Microcontroller code running on the Teensy:

HardwareSerial bt = HardwareSerial();

#define Seria1_PORT_SPEED 115200

void setup()
{
bt.begin(Seria1_PORT_SPEED);
bt.println();
Wire.begin();


}

void loop()
{

////////////////// Bluetooth stuff /////////////////////////
if (bt.available() >= 2) {
if (bt.read() == '#') {// Start of new control message
int command = bt.read(); // Commands
if (command == 'f') {// request one output _f_rame
//output_single_on = true; //unused?
} else if (command == 's') { // _s_ynch request
// Read ID
byte id[2];
id[0] = readChar();
id[1] = readChar();

// Reply with synch message
bt.print("#SYNCH");
bt.write(id, 2);
bt.println();
}
}
}

sendDataToAndroid();
}





void sendDataToAndroid() { //arrays defined as float array[3] = ...

bt.write((byte*) array1, 12);
bt.write((byte*) array2, 12);
bt.write((byte*) array3, 12);

}

char readChar()
{
while (bt.available() < 1) { } // Block
return bt.read();
}

And here is the relevant Android code taken from this tutorial: https://github.com/ptrbrtz/razor-9dof-ahrs/tree/master/Arduino/Razor_AHRS

http://pastebin.com/vdBbuNe3

Thank you for any help. I would love to have consistent bluetooth with Teensy.
 
Status
Not open for further replies.
Back
Top