XBee and Arduino synchronization

I’ve a ATmega368, currently working on top of a Arduino Uno, which its final purpose will be to process some sensor information and send it through XBee (configured as a router) to the coordinator.

So, basically I’ve a arduino, which its Tx pin is connected to the pin 3 on XBee. All information I’m writing through the Serial.println() method is received perfectly on the coordinator in API ZigBee Receive Packet frames (0x90).

Now, considering that the API 0x90 packet is capable to hold 6 bytes of data, I was expecting that if I limited the output on the Arduino also to 6 bytes I would get only 1 frame with the full 6 bytes. But what it happens is that normally I get the full message sent from the arduino, broken into the several frames.

Is it a clock synchronization problem? Will it help using the CTS/RTS pins?

I think is mostly due to the packetization timeliness (set by RO) of data while waiting on the buffer. But considering I’m only sending data every 5 seconds or so, the packatization period always timeouts.

1 Like

If your arduino is delaying between character writes longer than the RO parameter then the XBee will just send everything in the buffer. The default is 3 character time which means you should send all of your data in a single Serial.println command. A RO of 0 means the first character will be sent seperately no matter how fast you print to the XBee.

If you have can’t change the timing you could also switch to API mode. This would give you total control over what gets sent in each packet.

1 Like

First of all… thank you for the answer.

Yes, I’ll probably be using API mode, even because, I’ve tried to change the RO to 100, and what happens is that every time I’m sending the 6 bytes string 99% of the time the first byte is dispatched alone the remaining 5 bytes go in the next transmission.

Thus, what I really think is happening is, since I’m sending the 6 bytes (in one go) only every 5 seconds, even the max value of RO (which is 255) is not enough and timeouts before the next time I try to send the 6 bytes string. Basically, the next time it will have anything in the buffer its going to be transmitted, i.e., the first byte. The following 5 bytes (after the first one) are within the timeout value so, it will be transmitted in one go.

I’ve also tried to remove the period of 5 seconds of delay and set RO to 6, and all the 6 bytes are transmitted in one go.

In other words, and after reading the XBee spec manual again, the RO ends-up by doing exactly what it suppose to do…