I want to receive simple data from arduino with bluetooth module attached. I am recieving data, everything works fine, but i cant read it well. Here is arduino code:
char incomingByte;
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println(2);
delay(1000);
}
Here is Android code for reading data from InputStream (BufferedInputStream):
mInStream = socket.getInputStream()
public void run() {
BufferedReader r = new BufferedReader(new InputStreamReader(mmInStream));
while (true) {
try {
int a = r.read();
Log.d(TAG, Integer.toString(a));
} catch (IOException e) {
break;
}
}
}
Here is problem: When Arduino sends number 1, Android should receive it through Buffered Input Reader as decimal value for 1 and it is equal to 49. But i get 2 additional lines in Log, always same values: 10 and 13. How to avoid reading/receiving this? Here is Logcat output for number 1 sent from Arduino:
TAG: 49
TAG: 13
TAG: 10
Whats wrong? Why does Android app receive last two lines?