I'm working on building a time attendance device using ESP8266 or ESP32 with an RFID module connected to it through UART (TX/RX). I want to implement a local database or JSON file or array or anything else to register users and record enrollment datetime.
Assuming I have two data structures:
struct User {
int userID;
char userName[50];
long rfid_ID;
int btid;
unsigned long registeredDateTime;
};
struct Enrollment {
int enrollID;
int userID;
char type[10];
unsigned long enrollTimeStamp;
};
I will use functions to add, edit, and delete users:
i read somewhere that there is problem if u rewrite or write many times, is this correct?
because all the time people will make new enrollment and at the end of day ill send them to server and delete from device
and to create users i need to make a namespace and add keys for every user right? not like array or map-like structure
user_1_name=Jon Smith
user_1_rfid=123456678
user_1_btid=12344
user_1_registeredDateTime=123456789
user_2_name=Alice Johnson
user_2_rfid=987654321
user_2_btid=56789
user_2_registeredDateTime=123456790
user_3_name=Bob Doe
user_3_rfid=111223344
user_3_btid=54321
user_3_registeredDateTime=123456791
flash memory has a maximum number of writes for once cell location. after ~10,000 to 100,000 writes you can start having issues (depends on type of flash you use)
The mechanism underlying the Preferences is based on NVS (Non-Volatile Storage) which has wear levelling functionality ( Details are here)
if you have a large enough partition, you could be fine for a few years.
it depends on how many cards you want to manage and if you want to keep an history on device or just the last checkin
if you are worried, you could add FRAM ➜ Each byte can be read/written 10,000,000,000,000 times so you don't have to worry too much about wear leveling
--
you would have to clarify exactly what's kept on the ESP32 (for each user and how many users do you manage)