EEPROM DataLogger

Hello everyone,
I do a project with arduino RFID Time Tracking, i want please to know how can i register and log data to eeprom i want to create a CSV file and to create two table one for the registration also Write and one for the Logging also read.
Thanks

is your intention to use the ATmega328P's internal EEPROM?

lots of limitations there like small size...

Why not add an external FRAM, easy to add huge amounts of memory, write speed same a writing to SRAM, with trillion+ re-write capability of EEPROM nonvolatility

Read the datasheet, some will run at 5V, some at 3.3V

You can add the CSV part when you send the data via serial.
Store your data as byte, each address a unique value, or by int (unsigned int?), with every other address a unique value.

There are many Arduino/EEPROM data logging projects on the web. Google can find them, but here is one link: Building a Standalone Temperature Logger: Part 1 « insideGadgets

Maybe Jack's serial data logger is your answer, it works great.
http://forum.arduino.cc/index.php?topic=252905.0

BulldogLowell:
is your intention to use the ATmega328P's internal EEPROM?

lots of limitations there like small size...

I have an extern EEPROM with 1024 kbyte

Here is the code for SD Datalogger :

/*
SD card datalogger

This example shows how to log data from three analog sensors
to an SD card using the SD library.

The circuit:

  • analog sensors on analog ins 0, 1, and 2
  • SD card attached to SPI bus as follows:
    ** MOSI - pin 11
    ** MISO - pin 12
    ** CLK - pin 13
    ** CS - pin 4

created 24 Nov 2010
modified 9 Apr 2012
by Tom Igoe

This example code is in the public domain.

*/

#include <SPI.h>
#include <SD.h>

const int chipSelect = 4;

void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

Serial.print("Initializing SD card...");

// see if the card is present and can be initialized:
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
// don't do anything more:
return;
}
Serial.println("card initialized.");
}

void loop() {
// make a string for assembling the data to log:
String dataString = "";

// read three sensors and append to the string:
for (int analogPin = 0; analogPin < 3; analogPin++) {
int sensor = analogRead(analogPin);
dataString += String(sensor);
if (analogPin < 2) {
dataString += ",";
}
}

// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
File dataFile = SD.open("datalog.txt", FILE_WRITE);

// if the file is available, write to it:
if (dataFile) {
dataFile.println(dataString);
dataFile.close();
// print to the serial port too:
Serial.println(dataString);
}
// if the file isn't open, pop up an error:
else {
Serial.println("error opening datalog.txt");
}
}

My question is if the code for Eeprom datalogger is the same or not, i want to know which code are there for the eeprom datalog

My question is if the code for Eeprom datalogger is the same or not,

NOT.

I have an extern EEPROM with 1024 kbyte

At this size you probably have an I2C eeprom and your first order of business is to learn how to write and read one byte at a time using Wire.h. Here's a link to a tutorial, but there are many others out there.

If you need to use block writing/reading there is an issue of "page size" to deal with and you may be better off using a library like J.Christensen's extEEPROM.h.

In the future, if you post code, please use the code tags </> on the tool bar, so that the code looks like this

I think that my question was not clear, i know how i make read and write but i don't know how to register in csv data and how to log from csv data.

To write .csv data, you send or store lines of character data, consisting of ASCII representations of numbers or ASCII characters, with commas in between each data item.

For example:

123,2,5
118,4,5

etc.

Monday,10,25
Tuesday,11,30

is also valid.

Please give an example of the data you wish to store and retreive. You mentioned RFID. Do you have numerical or ascii character data? How much data do you need to put in the EEPROM?

You will take up extra space if you need to store a "," to separate data. Why do you want to store data in csv format in an eeprom?

I have to make 2 tables one for the registration for the read tags from the RFID and one Table to log this tags with time and name or ID, in the first Table i have to registrate 255 tags with 5 bytes ( the adress for the card has 5 bytes) and the second i want to log the tags with time and ID with 10 byte because the time and ID have 5 bytes too, i have 1024 kbyte in the eeprom

Sounds like you need more then. 255 * 5 + 255 * 10 = 3825 bytes.
Atmega1284 has 4K bytes (4096). So does Atmega2560.

I want to register not more than 255 Tags and to log them i want to need the rest. After creating a cardsregistration table, i want to search the read card from RFID reader and to storage it in another table with the time. And this procedure must saved in a EEPROM.
Do you have any idea please?

Have you written any code at all? The EEPROM is a small part of your project.

If not, learn to use the RFID reader and read a card. Then make a small version of your data base and register a few cards. Figure out how to search the data base for an incoming card, and print the arrival time on the serial monitor.

Proceed from there.

yes i written my code but i didn't finish it i can read any card with my RFID and i did the time and date in my LCD this is the code:

#include <Time.h>
#include "Wire.h"
#include <LiquidCrystal.h>
#include <SoftwareSerial.h> // Dependency of ID20Reader. Must include in main file
                            // Due to Arduino software limitations.
#include <ID20Reader.h>
#define DS1307_I2C_ADDRESS 0x68
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
//ID20Reader rfid(rx_pin, tx_pin); //Create an instance of ID20Reader.
ID20Reader rfid(7, 6);
int buzzer=10;
byte secondreg=255; 
byte bcdToDec(byte val)

{
  return ( (val/16*10) + (val%16) );
}
 
void getDateDs1307(byte *second,byte *minute,byte *hour,byte *dayOfWeek,byte *dayOfMonth,byte *month,byte *year)
{
  Wire.beginTransmission(DS1307_I2C_ADDRESS);
  Wire.write(0);
  Wire.endTransmission();
  Wire.requestFrom(DS1307_I2C_ADDRESS, 7);
 
  *second     = bcdToDec(Wire.read());
  *minute     = bcdToDec(Wire.read());
  *hour       = bcdToDec(Wire.read());
  *dayOfWeek  = bcdToDec(Wire.read());
  *dayOfMonth = bcdToDec(Wire.read());
  *month      = bcdToDec(Wire.read());
  *year       = bcdToDec(Wire.read());
}
 
 
void setup()
{
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  Wire.begin();
  lcd.begin(16, 2);
  Serial.begin(9600);
  pinMode(buzzer,OUTPUT);
  Serial.println("RFID Reader - Swipe a card ~~~~~");
 
}
 
void loop()
{
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  String s, m, d, mth, h; 
  getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
  if (secondreg != second )
  {
  secondreg=second;
 
  if (second < 10) { s = "0" + String(second); } else { s = String(second); }
  if (minute < 10) { m = "0" + String(minute); } else { m = String(minute); }
  h = String(hour);
  if (dayOfMonth < 10) { d = "0" + String(dayOfMonth); } else { d = String(dayOfMonth); }
  if (month < 10) { mth = "0" + String(month); } else { mth = String(month); }
   
  char* days[] = { "NA", "Mo", "Di", "Mi", "Do", "Fr", "Sa", "So" };
   
  lcd.clear();
  // JUMP TO CENTER ON A 16X2 SCREEN //
  lcd.setCursor(4,0);
  // CHANGE THE FOLLOWING TO SET THE DATE IN TO YOUR PREFERED ORDER //
  lcd.print(h + ":" + m + ":" + s);
  // NEXT LINE, 1 SPACE IN FROM THE LEFT //
  lcd.setCursor(0,1);
  // PREFIX THE 20 AS THE RTC CHIP ONLY USES 2 DIGITS FOR THE YEAR //
  lcd.print(String(days[dayOfWeek]) + " " + d + "." + mth + ".20" + year);
  
  }
   delay(100);
   rfid.read(); //Receive a tag from the reader if available
  
  if(rfid.available()) //a tag has been read
  {
    String code = rfid.get(); //Get the tag
    Serial.println(code); //Print the tag to the serial monitor
    for (int i=0;i<255;i++){
    digitalWrite (buzzer, HIGH);
    digitalWrite (buzzer, LOW);
    delay(1);}
    
    
 
  }
}

now i want to do the database and to save it in my EEPROM (1024 Kbyte)

What EEPROM?

Google "butterfly data logger" for code to read/write a 512K byte eeprom.

But first, write your database code.

i am sorry but how can i write my database code please, do you have an example ???

I believe there is a fundamental problem with your architecture in that your sketch is using String objects (String with capital S) and you can not write String object's to EEPROM.

The information needs to be broken down into bytes. I don't work with Strings so I do not know if there is a way to cast them into bytes for storage, and reconstruct them on reading.

Why are would you not using an SD card module and an SD library to manage your data base. As has been previously stated, you are going to run into size limitations pretty soon.

how can i write my database code please, do you have an example

No, and it is extremely unlikely that you will find code that fits your requirements.

It is time to learn how to write one. Hint: use a struct to define the basic storage element.