looping EEPROM taking quite a bit of time to read banned RFID tags

My plan was to store rfid tags in the EEPROM that are to be banned. I would have to use 3 or 4 address as tag id's are 8 characters. While that makes it more complex, that's not my main issue. It's taking around 5 to 7 seconds to loop through all 1024 addresses. Doesn't seem like a lot but if you are waiting for a gate to open, that's long enough to wonder if your key worked and keep swiping it. so i'm not sure where to go from here. Is there a better place to store the data? using variables takes app memory and is volatile. is there a better logical way I can look for the data?

thanks

Well I have to use 8 address per rfid tag ID. so it's down to about 1 second, might work but its still kind of a complicated process.

Hi,
Can you post a copy of your code please?

Thanks.. Tom.. :slight_smile:

Hey tom, thanks for your response.

But I don't really have code at the moment. An example of an RFID ID would be "AE 79 4F A3". the way I see it in code (i'm still trying to wrap my head around working with bytes so i convert it to string, memory intensive i know) is "17412179163"

so basically, I need to store "17412179163" somewhere, along with other like numbers, and loop through the list of numbers to see if my "current number" is in the list.

in the future I can simply write them to a web server which will store them in a database and simply report yes or no if its in the list or not. but for the moment i need to have a stand alone setup.

thanks again

That is 4 bytes per tag. 1k bytes give up to 250 tags. You would linearly scan through the tags in the eeprom until you get a hit or hit the end marker (say 0xFFFFFFFF) so the time taken would depend on how many tags were registered in the eeprom.

I have some code now. I don't think its actually taking this long, I think its printing to serial that is taking the time.

int FindFirstAvailableEEPROMSetOf8(){
  for (int i = 0; EEPROM.length(); i = i + 8){
    if(EEPROM.read(i)== 255){
      return(i);
    }else if(i > EEPROM.length()){
      return(32767);
    }
  }

so, i guess my question becomes, Is there a better way to do this?

Hi,
Its is best if you post the entire code, we have no idea how you have setup serial or any library parameters.

Thanks.. Tom.. :slight_smile:

I can't paste the whole sketch as its too big and i don't know if pastebin is allowed. But everything else is all related to rfid card reading and not really the question here.

#include <SPI.h>//include the SPI bus library
#include <MFRC522.h>//include the RFID reader library
#include <EEPROM.h>

those are my includes.

void loop() {
int address = FindFirstAvailableEEPROMSetOf8();
Serial.println(address);
}

int FindFirstAvailableEEPROMSetOf8(){
  for (int i = 0; EEPROM.length(); i = i + 8){
    if(EEPROM.read(i)== 255){
      return(i);
    }else if(i > EEPROM.length()){
      return(32767);
    }
  }

That is where i'm looking for available sets of 8 blocks of memory.

  String txt; //This is where we store block 2, the password
  String uid; //This is where we read the tag id from the red card
  String compare = "17412179163";//currently using tag's id, for testing.

  //get card uid to see if its in eeprom aka banned
  Serial.println("Scanned PICC's UID to see if its banned:");
  for (int i = 0; i < mfrc522.uid.size; i++) {
    uid = uid + (byte)mfrc522.uid.uidByte[i];
  }

That bit is how i'm getting the UID. it comes in a decimal form. I think part of the ascii code. eventually I will learn how to deal with just the byte data not what is output to casting to string.

Shouldn't you be searching through a list of of tag IDs to find ones that are acceptable, rather than ones that are banned?

Would my RFID card let me in your gate?
I can't imagine you have already put me on the banned list as you don't know my ID.

Surely, if you can only ban (1024/8) cards, then the rest of the world population of cards must be deemed to be valid.

Hi,
Attach your code as an .ino file.

Tom... :slight_smile:

Correct. I can only ban 128 cards at a time. but once that card gets used, its deactivated and then removed from the banned list. so itl only be an issue if 128 people don't turn in their card.

This isn't the best way of doing it. but without more storage, i'm not sure if there is a best way.

attached sketch

ppcc_gate.ino (13.7 KB)

Maybe skip the eeprom and use a FRAM chip.

For $10 it’s 32k of storage that’s faster, bigger and better longevity than onboard eeprom.

I also had the idea to use a SD card, and create a new file named with each card ID that contains validity, and date / time stamps of use.

I like those ideas. Side queation. With the fram, im assuming its a shield, what do you do if two Shields are trying to use the same pins?

wiki fram

It uses the I2C bus; you can buy them on a break-out board; see Adafruit I2C Non-Volatile FRAM Breakout - 256Kbit / 32KByte : ID 1895 : $9.95 : Adafruit Industries, Unique & fun DIY electronics and kits. Two address lines by the looks of it, so you can connect 4; just solder it all together.

If you have other I2C devices connected, just check the addresses.

So its 32k vs the 1k i have with eeprom?

It looks like it hooks up without any difference in my pin usage. But I'm afraid I don't understand what 12C means

wiki I2C

There is something called google :smiley:

I read some about it on the page for the product that was late. What it described I understand to be basically a communication protocol.

It's not only a protocol; it's a bus system.

Compare it with a new street and somebody builds a new house (connect something to the bus). Next somebody else also builds a house. Houses have house numbers, those are the addresses on the bus.

And next there is the protocol that says how to deliver a parcel (data) to a specific house address or fetch a parcel from a specific house. address.

Yeah that's how the company described it on their website. I couldn't seem to find a code example. Not at least everything I could open on my phone.

Found this somehow on their page: GitHub - adafruit/Adafruit_FRAM_I2C: Arduino library driver for Adafruit's I2C-Based FRAM Breakouts

It's the library and contains an example.