SparkFun RFID Qwiic Reader returns the same rfId tag value over and over after about 12 scans

I have the SparkFun RFID Qwiic Reader. I works well but after scanning about 12 cards I then just returns the same rfId Tag value over and over till I restart the device. I have tried just clearing out the tags still same result.

It sounds like you’re filling up its memory? Try clearing the read after writing it/them to serial

Does it read up to 20 at once correctly? SparkFun_Qwiic_RFID_Arduino_Library/examples/Example3_Get_All_Available_Tags/Example3_Get_All_Available_Tags.ino at master · sparkfun/SparkFun_Qwiic_RFID_Arduino_Library · GitHub

It still runs a loop of just returning last read after 20 scans and does not read a new card after the 20. Here is the modified example code I ran to get the results below.

int validScanCount = 0;
int32_t reqTime = 0;
String rfIdTag;
String lastRfIdTag = “”;
Qwiic_Rfid rfId(RFID_ADDR);

String allTags[MAX_RFID_STORAGE];
float allTimes[MAX_RFID_STORAGE];

void setup() {
Serial.begin(9600);
Wire.setSDA(4);
Wire.setSCL(5);
Wire.setClock(10000);
Wire.begin();
rfId.begin();
}

void loop() {
rfId.getAllTags(allTags);
rfId.getAllPrecTimes(allTimes);
reqTime = 0;
for (int i = 0; i < MAX_RFID_STORAGE; i++)
{
if (allTags[i].length() > 6 && allTimes[i] > reqTime)
{
rfIdTag = allTags[i];
reqTime = allTimes[i];
}
}
if (rfIdTag.length() > 6)
{
validScanCount++;
Serial.print(validScanCount);
Serial.print(“,”);
Serial.println(rfIdTag);
rfId.clearTags();
rfIdTag = “”;
}
delay(500);
}

Results
16:23:18.784 → 1,72017910819980
16:23:21.817 → 2,7201791602467
16:23:23.482 → 3,72017910819980
16:23:25.056 → 4,7201791602467
16:23:26.675 → 5,72017910819980
16:23:28.324 → 6,72020112388162
16:23:29.934 → 7,72017910819980
16:23:32.264 → 8,7201791602467
16:23:33.860 → 9,72020112388162
16:23:35.516 → 10,72017910819980
16:23:37.816 → 11,7201791602467
16:23:39.436 → 12,72017910819980
16:23:45.010 → 15,72017910819980
16:23:46.653 → 16,72020112388162
16:23:48.987 → 17,72017910819980
16:23:50.580 → 18,7201791602467
16:23:52.951 → 19,72017910819980
16:23:55.982 → 20,73102000232
16:23:56.861 → 21,73102000232
16:23:57.798 → 22,73102000232
16:23:58.723 → 23,73102000232
16:23:59.636 → 24,73102000232
16:24:00.563 → 25,73102000232
16:24:01.475 → 26,73102000232

Try this:

#include <Wire.h>
#include "SparkFun_Qwiic_Rfid.h"

#define RFID_ADDR 0x7D // Default I2C address of the RFID reader

Qwiic_Rfid myRfid(RFID_ADDR);

void setup() {
  Serial.begin(115200);
  Wire.begin();

  if (myRfid.begin() == false) {
    Serial.println("RFID reader did not acknowledge! Freezing!");
    while (1);
  }
  Serial.println("RFID reader acknowledged.");
}

void loop() {
  if (myRfid.available()) {
    String tag = myRfid.getTag();
    long time = myRfid.getTagTime();
    
    Serial.print("Tag: ");
    Serial.print(tag);
    Serial.print(" Time: ");
    Serial.print(time);
    Serial.println(" ms");

    // Clear the tag buffer after reading
    myRfid.removeTag();
  }
  delay(250); // Small delay to prevent constant polling
}

the class Qwiic_Rfid does not have a member named ‘available’, ‘getTagTime’, or ‘removeTag’.

Ah, apologies…that was mostly meant as an exmaple and not necessarily ready-to-run…but a template of how to do it (with whatever functions are defined in the SRC files; it looks like it is

void Qwiic_Rfid::clearTags()
{
    _readAllTagsTimes(MAX_TAG_STORAGE);
}

I call the clearTags() method in the original code.

I switch over to SparkFun RFID Reader Breakout. It works wonderfully now. I had the hardware serial pins available on the microcontroller. Thank you guys for having this tutorial made it really easy.

1 Like