0

Audrino Uno EEPROM question
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Audrino Uno EEPROM question

by dkanday on Tue Jun 22, 2021 1:59 pm

Hi,

I am using an Audrino Uno with a fingerprint sensor and a TFT display. I have a ID counter which runs every time I run the code and the user tries to enroll a fingerprint, so this data is stored in that specific ID. For example: at the start the ID value is 1 and the first user who enrolls gets the data stored in ID1 and this goes on.
The issue I have is when I turn off the audrino or reset it, the ID value reinitiates again from 1 and erases the last fingerprint which was stored in ID=1 and stores the new fingerprint.
In order to resolve that I was thinking on using the EEPROM. I was thinking of using an counter with EEPROM address as 1 and ID as 1, so the counter keeps incrementing and storing the data in respective addresses. So I am back to the old issue where how would I continue from the last stored Address after power cycle/reset?
Can someone point out to an example?

dkanday
 
Posts: 41
Joined: Mon Jun 07, 2021 4:49 pm

Re: Audrino Uno EEPROM question

by dastels on Tue Jun 22, 2021 2:21 pm

So.. you want to know how many have been used and what's the next one to use?

You could write sentinel value to the EEPROM locations initially (maybe with a special setup mode or a separate program), say 255. Then as you handle the fingerprints you would replace that 255 with other values. When the code starts, it would just have to scan through EEPROM looking for the first location containing 255, and that's the next one to use. Naturally, you can't use 255 as a "real" data value.

Make sense?

Dave

dastels
 
Posts: 6804
Joined: Tue Oct 20, 2015 3:22 pm

Re: Audrino Uno EEPROM question

by dkanday on Tue Jun 22, 2021 2:31 pm

dastels wrote:So.. you want to know how many have been used and what's the next one to use?
{dkanday}Yes that is correct

You could write sentinel value to the EEPROM locations initially (maybe with a special setup mode or a separate program), say 255. Then as you handle the fingerprints you would replace that 255 with other values. When the code starts, it would just have to scan through EEPROM looking for the first location containing 255, and that's the next one to use. Naturally, you can't use 255 as a "real" data value.

Make sense?
{dkanday}Kinda, let me try that and see if that works.
Thanks for the suggestion!

Dave

dkanday
 
Posts: 41
Joined: Mon Jun 07, 2021 4:49 pm

Re: Audrino Uno EEPROM question

by dkanday on Tue Jun 22, 2021 4:47 pm

Hi Dastels, that Idea worked. I used in combo with
EEPROM read and EEPROM write logic and it worked
Thanks again for the help!

dkanday
 
Posts: 41
Joined: Mon Jun 07, 2021 4:49 pm

Please be positive and constructive with your questions and comments.