It scans many times before the first card is touched to the scanner
Ahh, and each does a malloc, etc. good point.
Before you get to all that, here's a different one to try:
Arduino - RFID Tag Reader/Manager : 4 Steps - Instructables
Have you considered FRAM memory? It is nonvolatile and runs at memory speed. 8Kx8 should be under $5.00 and can be gotten in SPI, I2C, and parallel. You simply write a simple program to write the data into the FRAM, then change your code to use the FRAM. This will free up a lot of memory in your Arduino and for way less money then bigger Arduino.
just to explain why I need this code to work...
I have a door lock to my building which is a dorm for students... every tag has a number graved on it like 101, 102, ets.
First I scan the tags in order to get thear serials. After that I insert them in the sketch.
Every year I gave a new tags for new students... at the end of the year they live and some of them are returning the tags some don't... those who are not returned I delete the serial numbers from the Arduino program and add new one for new students then I upload updated sketch to the arduino door lock...
I try another sketch with Master Card to add and delete tags... but this does not working for me because I cant delete the tags that are not returned
In order to do that I need first to scan the Master Card to enter the Delete Mode then to scan the tag that I want to remove (but I don't have it because the student did not returned the tag).
So thats why this code is good for me.
I'd encourage you to give a try to the example that I provided a link to.
Two other possibilities - since it's constants, move your table to the Flash space (@er_name_not_found, is that feasible?), or move to a different Arduino with more SRAM. Wouldn't take a lot, as I doubt you're doubling your student count, just getting a few more than now.
It still needs c-strings or it will just take longer to crash.
Since the codes are being compiled in at update, they can be constants and placed in PROGMEM. I do like the idea of using an ESP32 or other more capable MCU, but it should be able to work with a Nano 328.
You are right... I upload the code to Arduino Mega 2560 and its working with 62 tags... This will be my easiest solution for now...
I'll push to see what is the maximum and I will report to you...
Thank you all for your time and effort I appreciate it
Be aware, you're only prolonging your agony by sticking with String, due to the nature of the software components you're using. Mega is a stopgap measure, not a solution.
Best of luck!
The UNO has the same processor at the Nano so it has the same memory.
I don't see an apparent cause for your problem in the example you are using but it does have some strange code and all the comments in the library seem to be in a strange font.
My current best guess would be a memory problem but I can't see. exactly where.
My recommendation is that you start with a different example. Preferably one where the card serial numbers are saved as 'uint32_t' rather than String objects. I would try installing an RFID library from Tools -> Manage Libraries... to see if any of the built-in examples are close to what you want.
Thank you so much you are so kind..
Just to let you all know I try with 147 tags and its still working... that's is dabble of what I need for now so it will be my solution
If it's really necessary to minimize your time on this, consider using the memory monitor code, and doing a software reset when the available memory drops to some threshold. Probably less than 10 lines of code to be added to your main loop, and the result will be worth it.
One more suggestion as u are new to coding in c/c++ i noticed you are using positive logic when comparing vars in if statements.
Try to switch to safer method:
const int flag=5;
int myVar=1;
//method 1
if(myVar==flag); // no problems
if(myVar=flag);// from compilers point of view no problems
//Method2
if(flag==myVar) //no problems
if(flag=myVar) // compiler error will kick in!
So u wont be able to compile the code and then get into surprises.
Method 2 is safer.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.