Saving sensor data to an external EEPROM (24LC512)

Dear all,

I’m acquiring measurements from 2 accelerometers (MPU6050) that are connected to my Arduino UNO through the I2C address (0x68 and 0x69).

The measurements are presented in a format: ax1 ay1 az1 T1 ax2 ay2 az2 T2
ax, ay, and az are acceleration amplitudes and T is the temperature; the index 1 and 2 indicate the number of the sensor (0x68 and 0x69).

I would like to save these measurements (8 float numbers in each line) to the external EEPROM (24LC512) until 2000 lines would be written and saved on it. Then the data would be sent in a package of 8x2000 float numbers to my computer and the process would be repeated. The new data would rewrite the old etc.

Could anyone with experience of using external EEPROM help me with the coding process?

This is the code I’m using for data acquisition:

#include <Wire.h>
const int MPU_addrs[] = { 0x68, 0x69 };

float AcX[2], AcY[2], AcZ[2], Tmp[2]; // definition of variables

void setup()
{
  for (byte b = 0; b < 2; b++)
  {
    Wire.begin();
    Wire.beginTransmission(MPU_addrs[b]);
    Wire.write(0x6B);  // PWR_MGMT_1 register
    Wire.write(0);     // set to zero (wakes up the MPU-6050)
    Wire.endTransmission(true);
  }

  Serial.begin(9600);
}

void loop()
{
  for (byte b = 0; b < 2; b++)
  {
    Wire.beginTransmission(MPU_addrs[b]);
    Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
    Wire.endTransmission(false);

    Wire.requestFrom(MPU_addrs[b], 8, true); // request a total of 8 registers
    AcX[b] = Wire.read() << 8 | Wire.read(); // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)
    AcY[b] = Wire.read() << 8 | Wire.read(); // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
    AcZ[b] = Wire.read() << 8 | Wire.read(); // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
    Tmp[b] = Wire.read() << 8 | Wire.read(); // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)
  }
  Serial.print(AcX[0] / 16384);
  Serial.print(" ");
  Serial.print(AcY[0] / 16384);
  Serial.print(" ");
  Serial.print(AcZ[0] / 16384);
  Serial.print(" ");
  Serial.print(Tmp[0] / 340.00 + 36.53);
  Serial.print(" ");
  Serial.print(AcX[1] / 16384);
  Serial.print(" ");
  Serial.print(AcY[1] / 16384);
  Serial.print(" ");
  Serial.print(AcZ[1] / 16384);
  Serial.print(" ");
  Serial.println(Tmp[1] / 340.00 + 36.53);
  delay(2);
}

I have never before used an external EEPROM, but I found references, such as:
REF1
REF2 (describes the Arduino process of code block saving)
REF3

The problem is that this code (from references) is gibberish to me because I don’t really understand what specific lines are meant to do. I know exactly what I need to do with the acquired measurements, but I don’t know how to implement that…

Any help is HIGHLY appreciated.
Regards,

L

but I don't know how to implement that...

Suppose that you need to save baseball cards, and you ask me for some boxes. All I have are shoe boxes.

Are you going to tell me that you can't use them because you don't have shoes to store?

All that you can store in EEPROM is bytes. What you have to store is floats. Well, a float is 4 bytes, so you CAN easily store the floats in EEPROM. There are plenty of threads on how to do just that, or you can use the EEPROM_WriteAnything() methodology without understanding it.

There are plenty of threads on how to reconstruct a float from 4 bytes read from EEPROM, or you can use the EEPROM_ReadAnything() methodology without understanding it.