Arduino/XBee Max Communication Speed

I'm taking 3 analog inputs with the Arduino and using a XBee w/Shield to send the inputs to an XBee connected to my laptop. I've increased the Baud Rate to 115200 (which I believe is the max). However, I'm only able to receive the data on my laptop at 700Hz. I use Hyperterminal to read the serial input for 10 seconds and then count the number of data points I get. I thought that I can read the data at least 5,000 Hz. The math I used to get that is:
XBee Max Throughput/(size of data) = sampling rate.
250,000(bits/sec)/(16bits*3samples)=5,208 Hz

Am I doing something inefficient with my code/communication methodology, or is this something inherently limited by the XBee or Arduino? My code is shown as follows:

#include <XBee.h>
#include <SoftwareSerial.h>
XBee xbee = XBee();

#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif

  uint16_t  packet[]={0,0,0};
  uint16_t  sensorValue1; 
  uint16_t  sensorValue2;
  uint16_t  sensorValue3;

void setup() {
  Serial.begin(115200);
  xbee.setSerial(Serial);

  cbi(ADCSRA,ADPS2) ;
  cbi(ADCSRA,ADPS1) ;
  sbi(ADCSRA,ADPS0) ;
}

void loop() {

  sensorValue1= analogRead(A1);  
  sensorValue2= analogRead(A2);  
  sensorValue3= analogRead(A3); 
  
 Serial.print(sensorValue1);
 Serial.print(sensorValue2);
 Serial.print(sensorValue3);
}

Thanks for any help you can provide!

The math I used to get that is:
XBee Max Throughput/(size of data) = sampling rate.

250,000(bits/sec)/(16bits*3samples)=5,208 Hz

Where did the 250,000 come from? At 115200, with a start bit and a stop bit, you can send 11,520 bytes per second. If each value is 2 bytes, and there are 3 bytes per packet, that's 1920 packets per second assuming that NOTHING else gets sent. Which, of course, is not a valid assumption, since the XBees have to acknowledge packets. Since one XBee has to tell another that it got a packet, it has to know which XBee it got it from, so there is overhead involved, which cuts down on your packet rate (since the packets are larger than 6 bytes).

The assumption that there are 6 bytes per packet is also wrong, since you are sending the data as ASCII text, not binary data.

You have NO way of making sense of the data in the packets you are sending, because there are no delimiters between the values in the packet and no delimiters between the packets.

Finally, the XBees need time to acknowledge the packets. You are not allowing for that, by ramming data out as fast as possible. You'll actually get much better throughput if you give the XBees breathing room.

Thank you for the help. The 250,000 is the max throughput of the XBee using the datasheet.

I see the what you're saying with your calculations. Maybe a better way to send the packets would be like this?

  Serial.print(sensorValue1);
delay(1);
  Serial.print(sensorValue2);
delay(1);
  Serial.print(sensorValue3);

I also have some more questions to ask:

  1. How can I put the delimiters in the packets without having to use Serial.print in between each data packet, which would take up more time?

  2. How do you send binary data using Serial?

  3. Is there a way to send all of the values in a single Serial.print line?

I apologize for asking these questions that seem elementary, but I just want to make sure that I'm doing it the right way. Thanks for the help!

Maybe a better way to send the packets would be like this?

Absolutely not. A better way would be:

  Serial.print(sensorValue1);
  Serial.print(",");
  Serial.print(sensorValue2);
  Serial.print(",");
  Serial.println(sensorValue3);
  delay(10);
  1. How can I put the delimiters in the packets without having to use Serial.print in between each data packet, which would take up more time?

The time involves sending the character, not the time involved in getting the data into the transmit buffer.

  1. How do you send binary data using Serial?

Serial.write()

  1. Is there a way to send all of the values in a single Serial.print line?
char useless[60];
sprintf(useless, "%d,%d,%d\n", sensorValue1, sensorValue2, sensorValue3);
Serial.print(useless);

This WILL make your sketch larger and will NOT improve the throughput one iota.