I'm using bluetooth to communicate in binary with my Android phone. It's working fine, expect I always get some extra bytes!
My Java Android code is:
byte[] data = new byte [6];
data[0] = (byte) 0x01;
data[1] = (byte) 0x02;
data[2] = (byte) 0x03;
data[3] = (byte) 0x04;
data[4] = (byte) 0x05;
data[5] = (byte) 0x06;
mmOutputStream.write(data);
And my arduino is:
if(bluetooth.available()) {
char buffer[6];
bluetooth.readBytes(buffer,6);
Serial.write(buffer);
}
But my output is:
01 02 03 04 05 06 D4 3C 05 01 A2 07 16 01 5E
Any ideas why I am getting these extra bytes?! It seems to be completely random, sometimes I get them, sometimes I don't. It's driving me nuts! I'm using the SoftwareSerial library for the bluetooth, and the normal h/w one for the serial.write.