Go Down

Topic: How to efficiently use array & manage data storage size (Read 123 times) previous topic - next topic

MikeOrlando02


I have been working on a project over the last year and taking baby-steps with making changes as it is working really great.

I have an access control system that needs to check access codes that are 24 charters.  Right now I load 25 codes into an array sized for the 24 chars + 1 EOL.  I would like to add more codes and I am concerned about using up my Uno's storage space.

Code: [Select]
char AccessID[25][25]


Originally, I had a global array and loaded it at setup; however I understand Globals take up more storage space.  Currently, I have it declared at runtime, when a code is received it declares and loads the array.  When I started to look back at my code it seems like a bad decision that this array is loaded every time a code is tried.  That being said, the input it probably a correct code it is likely only runs once.

What is the best way to go about this?  I believe eventually this will have to go to external storage/SD Card as when codes change they could just be updated on the external media and no one would have to re-write the uno's code.  Also, for storage reasons this would give me more space and I could read the external card for the right code and pull that in, instead of having the entire thing as an array.

Would really appreciate advice. Where to have the Array live and populated now and if my thought on eventually moving to SD Media is a sound idea.


Thanks all.

J-M-L

are the codes constant? and when someone types something you checked against the list of existing code to see if there is a match? or can code be declared dynamically?

Hello - Please do not PM me for help,  others will benefit as well if you post your question publicly on the forums.
Bonjour Pas de messages privés SVP, postez dans le forum directement pour que ça profite à tous

wildbill

How many codes do you think you'll have to accommodate? You could store a few more in RAM on your Uno, depending on what else is using it. You could store a lot more in progmem before you need to deal with an SD card. You could upgrade to hardware with more RAM: Mega, Teensy, Feather M4 etc.

Of course, the nice thing about the SD card is that you don't have to tweak the code to add new entries.

MikeOrlando02

are the codes constant? and when someone types something you checked against the list of existing code to see if there is a match? or can code be declared dynamically?


I want to make sure I am answering correctly.  The authorized code list is constant as far as the list is the list and currently that doesn't change until I add a code to the source code and upload it to the Uno.  All the authorized codes at the same length.  What is received could be a different length, depending what is entered.

Yes, when I code is entered it is just checked against the list of existing codes, that do not change until the Uno code is updated so nothing is done dynamically within the program.

Thanks for the assist.

MikeOrlando02

#4
Jun 16, 2019, 05:27 am Last Edit: Jun 16, 2019, 05:08 pm by MikeOrlando02
How many codes do you think you'll have to accommodate? You could store a few more in RAM on your Uno, depending on what else is using it. You could store a lot more in progmem before you need to deal with an SD card. You could upgrade to hardware with more RAM: Mega, Teensy, Feather M4 etc.

Of course, the nice thing about the SD card is that you don't have to tweak the code to add new entries.
It would be smart to plan for around 75 codes, but present day I can get away with 50 total.  Last time I tried to add additional codes it appears like I was getting short on memory.  I will have to look into the RAM options you listed as I didn't know this was an option.

You are correct, the SD card would a much easier way to add new codes.  Any other options I should consider?  Upgrade to a Mega and call it a day?

Go Up