I am working on making an Arduino based arcade. I want each user of the arcade to have an RFID card that stores the amount of credits (basically money) they have. I know that RFID tags have 1028 bytes of storage on them, but I don't know how to write an integer value to them.

The amount of credits each user has would be stored on the RFID, as well as their PIN.

The PIN would be 4 digits, with each digit an integer from 0-9, as is the standard with PINs. It would be stored as a single integer, between 0000 and 9999.

The credit would ALSO be stored on each card. This would be between 0 and 99 (Most that can be loaded at a time). This, too, would be treated as a single integer, for ease of use.

Both integers would be of the Arduino type int.

I am using the MFRC522 library with an RC522 reader/writer. I have an Arduino Uno, but can easily switch to an Arduino Nano.

Can someone tell me how to: A. Write an integer value (stored as a variable in the sketch or accessed from the RFID memory) to an RFID card? B. Access that information and retrieve it as an integer I could operate on (+,-,÷,×, etc)?

Thanks in advance!


You can read data with :

status = mfrc522.MIFARE_Read(blockNum, readBlockData, &bufferLen);  

and write data by:

status = mfrc522.MIFARE_Write(blockNum, blockData, 16);

However, there's a lot more to it, so check examples of the RFID library, or this external articles:

https://www.electronicshub.org/write-data-to-rfid-card-using-rc522-rfid/ https://playground.arduino.cc/Learning/MFRC522/

When you read the data in a memory block, you can get the bytes out you need and convert them to an int, or the other way around for writing.

  • So blockNum would be replaced with the block number of the target, and blockData would stay the same?
    – RMCodes
    Jun 24 at 14:56
  • I'm not 100% sure what you mean ... blockNum is an integer (value) number of the target, and block data is the buffer containing the content of that block (of the target), which is typically a 8 bit array (typically unsigned byte*) Jun 24 at 23:38
  • I wasn't sure what in the above code was placeholders and what was meant to stay the same when I make the sketch
    – RMCodes
    Jun 27 at 19:30
  • 1
    blockNum is an input parameter (meaning it doesn't change). readBlockData is changed (with the data that is read), as well as bufferLen which contains the number of bytes read (and to not overflow the read buffer). blockData (for writing) does not change the buffer (but changes the actual RFID tag content). Jun 28 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.