1

I'm sending serial data from an arduino to an android device.

Here is the code I have for the arduino sketch:

void setup(){
Serial.begin(9600);
  delay(10000);

Serial.println(4);
delay(2000);
Serial.println(7);
delay(2000);
Serial.println(7);
delay(2000);
Serial.println(5);

}

void loop()                   
{

  }

And what the data that prints on my Android device begins: [53, 13, 10, 0, 0...] with the rest of the numbers being zero. Now the size of the array I'm sending this data to is 1024 so I know why it keeps printing zeros, but what is going on with the first couple of numbers?

2 Answers 2

1
Serial.println(5);

Will indeed produce the sequence of bytes

[53, 13, 10,

Because the ascii code for '5' is 53, while println appends a carriage return (13) and newline(10).

It would appear you have missing your beginning. Be aware that your data will not necessarily be received in chunks of meaningful size, but instead my dribble in bit by bit in smaller packets which break up a message, or larger ones which combine messages, or both.

Sign up to request clarification or add additional context in comments.

1 Comment

Wow. That was an easy answer. Dang.
1

The value "53" is the ascii value for the character "5", followed by a carriage-return (13) and line feed (10).

That matches your last println() statement.

Why the previous data is not visible is hard to say without the receiving end. Please provide the android code.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.