SOLVED! big data , small memory?

SOLVED! Hallo, it's my first project . I'v built an rfid reader for opening a gate for gim entrance. it has some master tags and regular visitor tags with limited entries that I countdown in each entry. I used Arduino uno and it worked perfect for 7 tags and for 50 tags, but for 60 tags or more it gave me a "low memory" message and didnt work proper.

  1. is it normal?
  2. what is the best way to deal with it?
    Arduino Mega?
    SD card?
    It has to be individual , I cant place any pc near it...
    YAHNKS alot for your advices!!!
    Rafi

Use program memory, not RAM

If you like we can see your code and see if it is possible do something to reduce the amound of variables

is it normal?

Yes.
It comes of not planning what you want to do.

Adding more cards should not change the amount of SRAM you use at all if you do it right.

first thankyou all for your answers.
how can I use program memory?

here is my code:

#include <SPI.h>
#include <MFRC522.h>

#define RST_PIN         9          
#define SS_PIN          10         

MFRC522 mfrc522(SS_PIN, RST_PIN);   

String read_rfid;

int lock = 7; // relay output.

#define ARRAYSIZE 50
String ID_num[ARRAYSIZE] = { "bcc0f1c3", "821a7d39", "4924887c", "b976499", "d2bb3345", "82959144", "1280b939", "b2a42544", "c2b93044", "92787344", 
                            "79417d", "32d77e44", "f2283545", "499927c", "894ee87c", "122a4945", "59e9a07c", "127e8e44", "c915687c", "92f17d44",
                           "426d9244", "1265dd39", "22d4144", "29d79d7c", "e22a7644", "2748944", "629b9144", "d9ea9b7c", "19194f7c", "29f15a7c", 
                            "62113044", "69b26b7c", "e926b57c", "522c3e44", "29f04e7c", "e94a807c", "79f2797c", "32767644", "69f9c37c", "d2b67a39",
                            "f2b53244", "62ea3645", "32b63644", "f95687c", "22833d45", "c26c7644", "12bb8039", "f2c62c45", "f9147f4d", "2261fa39" };  //my known cards


int Counters[ARRAYSIZE] ;
int flag = 1 ; //for initialize the counters only once in the loop function

/*
* Initialize.
*/
void setup() {
   Serial.begin(9600);         
   while (!Serial);            
   SPI.begin();                
   mfrc522.PCD_Init(); 
   pinMode(lock, OUTPUT);        
}

void dump_byte_array(byte *buffer, byte bufferSize) {
   read_rfid="";
   for (byte i = 0; i < bufferSize; i++) {
       read_rfid=read_rfid + String(buffer[i], HEX);
   }
 }


//_______________________________________________________________________________________
//this function gets the card counter, countown 1 entry from it, open the gate and return the updated counter.
// in case of a master  tag ,( x == -1 ) , it will just open the gate.

int Open_Door_RFID ( int x )  { 
 
 if ( x > 0 )        //    regular user
   {
    x-- ;
    
    digitalWrite (lock , HIGH); // opening the gate
    delay (500);
    digitalWrite (lock , LOW);
    Serial.println(x);
  //  delay (7000);
   }

 else if ( x == -1 )           //   master user
   {
    digitalWrite (lock , HIGH); // opening the gate
    delay (500);
    digitalWrite (lock , LOW); 
   }  
 return x;
 }


//_______________________________________________________________________________________

void loop() {

//first we initialize the counters array
   if (flag == 1) {      //for initializing only once
     int k;
     for ( k = 0 ; k < 10 ; k++ ){     //  the first 10 tags are master
       Counters[k]=-1;  
     }
     for ( k = 10 ; k < ARRAYSIZE ; k++ ){     //  the othr tags has 30 entries
       Counters[k]=30;  
     }
   }
flag = 0;       
   
     // Look for new cards
   if ( ! mfrc522.PICC_IsNewCardPresent())
       return;

   // Select one of the cards
   if ( ! mfrc522.PICC_ReadCardSerial())
       return;

   dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);
   Serial.println(read_rfid);

   for (int i =0; i< ARRAYSIZE; i++){      //  compare the readen card to the list
         if (read_rfid == ID_num[i] ) {
         Counters[i]=Open_Door_RFID(Counters[i]) ;
         }
    }

     }

I think that the first thing to do is to remove all Strings and sobstitute than by arrays. After you can use smallest data type (like byte or char) if the number is always less than 128

thank you Silente! I'm not sure that I fully understand what you meen ' but I tryied Byte datatype and it didnt work for me

First when you read a card you do not want to keep it as a string. Each card has 8 characters and each of those characters represents just four bits. That is a total of 4 * 8 = 32 bits. That will fit into a long int.

All the comparisons are a lot faster and simpler comparing long ints than comparing strings. Store those ints in program memory.

Next time post your code correctly. Use the copy for forum in the IDE and paste that into your reply.

srafis:
here is my code:

OK, let's cut to the chase.

Please go and read the instructions, then go back and modify your post using the "More --> Modify" option to the bottom right of the post, to mark up the code (but it always needs to be the complete code) as such so we can examine it conveniently and accurately. Please do not post a ".ino" file as an attachment - that would mean that you are expecting people to actually load it to their IDE to look at it and that is extra unnecessary labour. In fact, attachments do not always show properly on different operating systems.

If you do not mark it up as code, whatever code you do post has as you see, become garbled and is certainly anything but easy to read.

Note: Also mark up any data in the same way. This includes error output that you get from the IDE.

And - before you post any code, use "Auto Format" in the Tools menu of the IDE to properly present the code.

Try and avoid unnecessary white space (blank lines). You should only use these to separate functional blocks of code.

Big thanks for your answers! I'm new to all of this , so please forgive me, I'll modify my post.
Thanks again!

Thanks friends!!! I solved it like that:

const uint32_t ID_num[ARRAYSIZE] PROGMEM = {
    Oxbcc0f1c3, Ox821a7d39, Ox4924887c,

it works now for 100 tags with no problem, didnt try on more than a 100.
Have a great day!!!

You didn’t solve the problem, you just halved the number of bytes used by the SRAM. Your problem is still waiting for you.