Sending Serial Data over Xbees

Hello, I am using two xbee arduino Unos and have a problem reading the serial data on the receiver arduino.


Transmitter code:
char buf[data.length()];
data.toCharArray(buf,data.length());
Serial.println(buf);

So the output in the serial monitor for the transmitter is:
5 L/hour
3 L/hour
etc.


Receiver Code:
while (Serial.available()>0)
{
Serial.write(Serial.read());
delay(500);
}

My problem is that on the serial monitor output, the output does not come out one line at a time BUT rather it comes out one letter/number a time in a sluggish/slomo way.

My problem is that on the serial monitor output, the output does not come out one line at a time BUT rather it comes out one letter/number a time in a sluggish/slomo way.

Let me guess. About a half a second between characters. Maybe this is the culprit:

delay(500);

The problem is that it is sending a letter/number of the line each time as opposed to sending the entire line at once. I think it is because of the serial available loop. It is printing the serial numbers of each line one at a time as opposed to a whole line at once. I need to somehow gather the serial numbers of one line in an array and write it.

The problem is that it is sending a letter/number of the line each time as opposed to sending the entire line at once.

No, it isn't. The XBee sends data pretty quickly. You are twiddling your thumbs for half a second after reading each character.

Look, it's a trivial test. Remove the useless delay() and see if that solves your problem.

It isn't, once i remove it, the lines all appear on the same line.

It isn't, once i remove it, the lines all appear on the same line.

I recognize all the words. That's where my understanding ends. Please try again to explain your problem. Posting ALL of your code might help.

Alright I fixed the problem. Did not put a delay on the transmitter code.

Thank you Paul, I appreciate your help!