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'.
Connect your RFIDuino as shown.
- Load RFIDuino_helloworld2 onto your board. You can find this sketch under:
- Once loaded, leave your board connected to your computer for power
- Swipe any of your RFID tag across the antenna board.
- If everything is working properly, the buzzer will activate and the green light will flash
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
decodeTagfunction, we supply a 5-byte array,
tag_datato 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_dataarray, we will use the
transferToBuffer()function to move the contents of the array to the
Now we will proceed to read the tag a second time. Again the tag data is stored in the
tag_dataarray. Now that we have two sets of data, we will use the function
compareTagData()to compare the current
tag_dataarray to the
tag_data_bufferarray. 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