RFIDuino Advanced ID Number Reference

XBee and Serial Communication

Serial.print() and Serial.println() are used in many of our examples to transmit and display RFID tag IDs. This makes the output is human readable. However this isn't always the best way to transmit data from one computer to another.

Using the Serial.write() function you can send data at the byte level. This will reduce the total amount of data you are sending, and make it easier for an Arduino/computer at the other end to interpret. It may be a good idea to star your transmission with one or two header bytes (usually 255 / 0xff) so that the receiving end can verify that it is receiving an ID packet

Sending data might look like this on the Arduino.

Serial.write(0xff);
Serial.write(0xff);
Serial.write(tagData[0]);
Serial.write(tagData[1]);
Serial.write(tagData[2]);
Serial.write(tagData[3]);
Serial.write(tagData[4]);

A receiving arduino can use the Serial.read() to read and parse the character stream.

Version Byte and Conversion

The first of the 5 bytes is referred to as the version number or the customer ID, and is sometimes ignored. This leaves you with a unique ID of 4 bytes which will fit into a long variable.

For example, say that the RFIDuino library returns the numbers
12, 34, 200, 53, 125
First, remove the first byte, leaving
34, 200, 53, 125
If we display the numbers as hex we would have
0x22, 0xC8, 0x35, 0x7D
Using the bitwise operator << we can shift / combine the numbers (see example below)
0x22C8357D
Which in decimal would display as
0583546237
Convention always displays this decimal number as having 10 digits, so if your ID does not have 10 digits, you will add a leading '0' so that the number is 10 digits long.

This is just one way to display/store the data.

Storing id as a long variable
long idNumber = (tagData[1] << 24) + (tagData[2] << 16) + (tagData[3] << 8) + tagData[4];	

Protocol References

Getting Started