Go Down

Topic: Getting user's data from an RFID tag using Circuito's library (Read 117 times) previous topic - next topic


Currently, I am using Circuito to do a project: https://www.circuito.io/app?components=512,9375,9376,11021,761981,761981

First, go to the link above and click on the "CODE" tab, then you should see RFID.h and RFID.cpp. You can download the whole .zip using the button at the bottom too.

I have an issue on C++ in that I am not sure how to retrieve user data from the RFID tag, using Circuito's given RFID .h and .cpp file. The main code provided only gives me how to read an RFID tag's serial, but not user data. I tried reading through the RFID.cpp file, but C++ is not my main strength and I am not quite sure how can I do this. Like which method must I use and how should I pass parameters, etc?

I used https://github.com/miguelbalboa/rfid/blob/master/examples/rfid_write_personal_data/rfid_write_personal_data.ino to write data into RFID tag, writing something like "Product 0001" on "First Name".

Can somebody tell me how to read the user data using Circuito's library? I only want to be able to read back the "Product 0001".


Thank you for your reply. I have already checked and used https://github.com/miguelbalboa/rfid/blob/master/examples/rfid_read_personal_data/rfid_read_personal_data.ino before posting this topic.

The thing is this. For example, in rfid_read_personal_data.ino, it uses MFRC522.h, while the one provided by Circuito uses its own RFID.h. And I am wiring in Circuito's way, which does not use SPI pins. The code from Github uses SPI pins so I need to use Circuito's implementation in this case.

Let's put it this way:

I see the following methods in RFID.cpp:

Code: [Select]
/ *
  * MFRC522Read -> read
  * Reading block data
  * Input parameters: blockAddr - block address; recvData - read a block of data
  * MI_OK Return value: the successful return MI_OK
  * /
unsigned char RFID::read(unsigned char blockAddr, unsigned char *recvData)
    unsigned char status;
    unsigned int unLen;

    recvData[0] = PICC_READ;
    recvData[1] = blockAddr;
    calculateCRC(recvData,2, &recvData[2]);
    status = MFRC522ToCard(PCD_TRANSCEIVE, recvData, 4, recvData, &unLen);

    if ((status != MI_OK) || (unLen != 0x90))
        status = MI_ERR;
    return status;

I am assuming this method is used for retrieving data from an RFID tag. I am used to Javascript's ways of retrieving data via return statement, but with C++'s pointer, I am not sure what to do. Could you please provide me a code snippet in how can I receive data from this method?


My guess is that in place of "mfrc522.MIFARE_Read(block, buffer1, &len);" you would use "rfid.read(block, buffer1);"
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

Go Up