adafruit fram read/write

Read Write to an adafruit I2C fram(adafruit 1895). I have a graph program that records 8 reading a day for 52 days.
The program work fine but when I want to change something the program has to restarts at 0 days on the graph.
On startup I would like to use the fram to reload the global array with the past data. I can read and write to the fram but I’m having trouble getting my head around write and reading 420 data points.

#include <Wire.h> // which uses the I2C interface
#include <Adafruit_FRAM_I2C.h>

Adafruit_FRAM_I2C fram = Adafruit_FRAM_I2C(); // Fram

setup{

Graphsize=420

Wire.begin(); // start up I2C for the RTC
fram.begin(0x51); // Start Fram adress 0x51

void writedata(void) {
int i;
for (i=0; i< graphsize+1; ++i ) // Count to 420
fram.write8(0x51, 53); //write to Fram ???
}

void readdata(void) {
int i;
for (i=0; i< graphsize+1; ++i ) // count to 420
fram.read8(0x51, 53); //read to Fram ???
}

The Adafruit demo sketch shows you how to read every value from the FRAM memory. Modify to just read the range of data you need.

void readdata(void)  {                       
  int i;
  for (i=0; i< graphsize+1; ++i )                           // clear out the data array
    fram.write8(0x51, 53);                                     //read to Fram   ?????????
  }

This isn’t really meant to read anything, is it?

Read Write to an adafruit I2C fram(adafruit 1895). I have a graph program that records 8 reading a day for 52 days.
The program work fine but when I want to change something the program has to restarts at 0 days on the graph.
On startup I would like to use the fram to reload the global array with the past data. I can read and write to the fram but I’m having trouble getting my head around write and reading 420 data points. Arduino mega

#include <Wire.h> // which uses the I2C interface
#include <Adafruit_FRAM_I2C.h>

Adafruit_FRAM_I2C fram = Adafruit_FRAM_I2C(); // Fram
setup{
Wire.begin(); // start up I2C for the RTC
fram.begin(0x51); // Start Fram adress 0x51

void writedata(void) {
int i;
for (i=0; i< graphsize+1; ++i ) // count to 420
fram.write8(0x51, 53); //write to Fram ??
}

void readdata(void) {
int i;
for (i=0; i< graphsize+1; ++i ) // count to 420
fram.read8(0x51, 53); //read to Fram ??
}

Yes I can read one at a time. I would like to use “i” with the counter to read data into and out of the array. I just don’t know how to set up fram.read statement to do that.

Hi … I’m using an RTC FM3164 and I just need to read and write the FRAM, but I can not get it. Could you do that? I use thousands of libraries and I do not have a positive result.

Yes I can read one at a time. I would like to use “i” with the counter to read data into and out of the array. I just don’t know how to set up fram.read statement to do that.

That code still doesn’t compile. And learn to use code tags! (that’s the </> button in the editor).

write8(address, value);
read8(address);

That’s the simple interface (that’s not copy/paste code, just in case…) for that library. If you don’t understand the concept, please ask questions.

This may help to clarify my problem. Just how to write in to an array and then read them back.

test.ino (1023 Bytes)

Thanks you Rich555 !!!