RFIDuino Hello World 2

Description

One problem with the code in RFIDuino_helloworld1 is a lack of verification. RFID can be sensitive to outside magnetic waves, so sometimes a tag can be misread. We found this less than .1% of all reads have an error, but even that can cause problems.
There is also the case when an RFID reader will read a tag swipe when no tag is present. These 'ghost reads' can be lead to development headaches and unreliable systems.

One way to fix this problem is to verify a tag by reading it multiple times. The RFIDuino can read a tag multiple times very quickly, so we can easily read the tag 2 times in a row, and compare the values. If we read the same ID twice in a row, we can be confident that we read the tag correctly. This also removes 'ghost reads'.

Instructions

  1. Connect your RFIDuino as shown.
    RFIDuino_bb1000.png
  2. Load RFIDuino_helloworld2 onto your board. You can find this sketch under:
    File>Examples>RFIDuino>RFIDuino_helloworld2
  3. Once loaded, leave your board connected to your computer for power
  4. Swipe any of your RFID tag across the antenna board.
  5. If everything is working properly, the buzzer will activate and the green light will flash

Code Overview

RFIDuino_helloworld2 verifies the tag read through the following process

  • Read a tag
  • Store the tag ID in a temporary buffer
  • Read the tag again
  • Compare the current tag read to the previous tag read residing in the buffer
When we run the decodeTag function, we supply a 5-byte array, tag_data to the function. The function will read the RFID tag's ID, one byte at a time, and put those bytes into the array.
Once we have read and stored the tag's ID into the tag_data array, we will use the transferToBuffer() function to move the contents of the array to the tag_data_buffer array.
Now we will proceed to read the tag a second time. Again the tag data is stored in the tag_data array. Now that we have two sets of data, we will use the function compareTagData() to compare the current tag_data array to the tag_data_buffer array. If the two match, the code activates the buzzer and LED. If not, the code resets its internal counters and keeps reading for a tag.

EXTRA CREDIT: Modify the program so that swiping the tag once will turn the buzzer/led on, and swiping it a second time will turn them off.
Download Solution Files

RFIDuino Functions used in this example

Next: Hello World 3 - Tag ID Output

Feedback Form