Whisper:
Yes, the receiving XBee will receive discrete packets if you can ensure that the trasmitting XBee modules are sending discrete packets. Of course, the simplest way to ensure this is by using API mode throughout your application. However if this is not an option there are some parameters you may tune.
You could adjust the RO “Packetization Timeout” parameter of your AT nodes such that it is at least as large as your packet size. This will ensure that RO “characeter times” are waited for before the XBee will transmit an RF packet.
Another suggestion I would have is that you may wish to add a checksum to your data packet. You could change your message format to be:
INNNNSS where I is the identifier, NNNN is the numeric value of your sensor reading (in ASCII), and SS is the checksum, in ASCII-encoded hexadecimal, of the entire packet. This way, if you did receive two packets on top of one another you would be able to reject the data because the checksum would be bad.
How would you calculate the checksum? Assume we have the packet:
A0123
If we took the ASCII values of A, 0, 1, 2, and 3 we would get:
65 + 48 + 49 + 50 + 51 = 263
Next we take 263 mod 255:
263 % 255 = 8
Now we convert 8 to hex and then to ASCII:
8 = 0x8 = “08”
Thus, our packet would become:
A012308
Now you could read in 7 bytes for every sensor read.
Assume you received the following:
A012308BB22220B
Reading in the two packets you would get:
A is 0123 (08 checksum good)
B is 2222 (0B checksum good)
…and know the samples for A and B are good. Again, here is how B’s checksum would be calculated:
66 + 50 + 50 + 50 + 50 = 266
266 % 255 = 11
11 -> hex = 0xb -> ASCII = “0B”
Assume you received:
AB22012308220B
Depending on how you implemented your parsing, you may still see two packets:
A (rejected because the next number is not an integer)
B is 2201 (checksum 23 is bad, sample rejected)
Why would it be rejected? How could you know two packets overlapped one another? Because:
66 + 50 + 50 + 48 + 49 = 263
263 % 255 = 8
8 -> hex = 0x8 -> ASCII = 08
08 != 23 therefore the sample is bad and it will be rejected.
There are, of course, more robust techniques you could use for data validation and packetization but I figured I would illustrate one just in case you might find it useful.
Best regards,
Jordan