RFID tags in EEprom...Please help

so i want to safe RFID tag ID's to EEPROM. The ID is in this format: 0F0184F20B (FYI, this is NOT the ID for my specific RFID tag). How do i write this to the atmega's EEPROM?

Thanks

How do you have that tag represented in your program? As a char array? A String? An unsigned long?

void saveToken(int point){ // saves the token in EEprom memory at point
    EEPROM.write(point, (tokensOnBoard[0] >> 24) & 0xff);
    EEPROM.write(point+1, (tokensOnBoard[0] >> 16) & 0xff);
    EEPROM.write(point+2, (tokensOnBoard[0] >> 8) & 0xff);
    EEPROM.write(point+3, tokensOnBoard[0] & 0xff);

http://www.arduino.cc/en/Reference/EEPROM

The value appears to be in hexadecimal. You can store two digits per byte or one character per byte. Are you planning to store a list of valid ID's? How many entries do you need to store?

Could someone please elaborate on grumpy Mike's code(I.e. how it works) and also on how to write a hexadecimal value to eeprom?

Thanks

leeamsi97: Could someone please elaborate on grumpy Mike's code(I.e. how it works) and also on how to write a hexadecimal value to eeprom?

Thanks

When you get round to answering MY question, yes, someone will. Until then, no one can.

Calm down majenko. The answers I got(other than yours) helped, despite your question not being answered. The last question I asked does not require your question to be answered either.

leeamsi97: Could someone please elaborate on grumpy Mike's code(I.e. how it works)

It works by writing bytes into EEprom. As EEprom is only 8 bits wide you have to split your token value into bytes.

also on how to write a hexadecimal value to eeprom?

You put a hex value into the second parameter of the EEPROM.write function. Am I missing something about your question?

See the code in this project:- http://www.thebox.myzen.co.uk/Hardware/RFID_Sequencer.html

Yes it does. How can we advise you how to store your data in EEPROM if we do not know how that data is represented in your program? For instance, if you have a char array of digits 0-9 and letters A-F then we would want to show you how to convert that into a set of numeric values 0-255 for storage. If it’s as a long then we’d need to show you how to split that long into bytes. If it’s an array of bytes already then the method is much sympler.

Since you are unwilling to help us help you then we will just have to take a wild stab in the dark.

  1. Convert your data into an array of bytes.
  2. Use the EEPROM.write() function to write each of those bytes to the EEPROM.

How you do 1 we cannot tell you as you refuse to tell us how the data is represented internally.

There are a million and one ways of representing 0F0184F20B in your program.

Grumpy Mike: so I can just put the whole hex value into the eeprom.write() command and it will automatically be written appropriately? Or do I have to split the hex into appropriate sized chunks first? Btw thanks for your help and patience.

A single EEPROM cell will hold a single 8 bit value from 0 to 255 - that is from 0x00 to 0xFF.

You can store your whole value with:

EEPROM.write(0, 0x0F);
EEPROM.write(1, 0x01);
EEPROM.write(2, 0x84);
EEPROM.write(3, 0xF2);
EEPROM.write(4, 0x0B);

But then, what are you going to do with that stored data?

Thanks majenko. That helps. As for your question, I will probably play around with the code until it works.

leeamsi97: Thanks majenko. That helps. As for your question, I will probably play around with the code until it works.

Make sure yo do not put that code in the loop function. There is a limit to the number of write cycles you can make and this can easly be exceeded.

Oh...where do I put that code then?

Either in the setup function or in your own function that you only call occasionally.

Ok. thanks a lot to everyone who helped, but especially to grumpy Mike for his patience and help.

leeamsi97: Oh...where do I put that code then?

It would really help if we could see your code - without that we can only make vague suggestions.

Majenko: I didn't even write the code yet. I posted this thread so I could get an idea of how to implement what I wanted to do. Thanks for trying to help though.

leeamsi97: Majenko: I didn't even write the code yet. I posted this thread so I could get an idea of how to implement what I wanted to do. Thanks for trying to help though.

Ok, so you're getting a litle bit ahead of yourself really - asking how to store it in EEPROM before you even know just what it is you will be storing, or when, or under what circumstances, etc.

It's a bit like saying "I'm going to design this circuit. It's going to have a 10K? resistor in it, and I want you to tell me how to calculate the current flowing through it. I haven't designed the circuit yet, but it will have a 5V supply. Actually, that's not the real voltage of my supply, but I will tell you it's that anyway, because I am scared of you knowing the actual voltage of my supply."

The real question should have been:

"I am going to write a program to interact with an RFID system. I would like to store my RFID tag number in EEPROM. Is this possible?"

And the answer would have been:

"Yes. You can find out more information about working with the EEPROM here: http://arduino.cc/en/Reference/EEPROM and there is a very useful EEPROM library for storing different data types here: http://playground.arduino.cc/Code/EEPROMWriteAnything"