This should get you started. It's not very elegant, but since it appears that the ST24XX eeproms works like the AT24XX, there is plenty to find on the web about how to use the external eeprom with the Arduino.
#include "Wire.h" // for I2C
#define eeprom24c16 0x50 // device address B01010000(80)
//function writes a byte of data to the I2C address 'device', in memory location 'add'
void writeData(int device, unsigned int add, byte data)
{
Wire.beginTransmission(device);
Wire.write((int)(add >> 8)); // left-part of pointer address
Wire.write((int)(add & 0xFF)); // and the right
Wire.write(data);
Wire.endTransmission();
delay(5);
}
//function reads a byte of data at the I2C address 'device', in memory location 'add'
byte readData(int device, unsigned int add)
{
Wire.beginTransmission(device); // I2C address
Wire.write((int)(add >> 8)); // bit shift for high byte of pointer address
Wire.write((int)(add & 0xFF)); // mask for the low byte
Wire.endTransmission();
Wire.requestFrom(device, 1); // request one byte...
byte result = Wire.read();
return result; // and return it as a result of the function readData
}
//Examples using function
byte num=0; //for reading numerical data
char d=0; //for reading ASCII characters
int a; //eeprom storage location
//example of writing text string
char data[]="This is data from eeprom 24CXX";
int L=strlen(data);
int i=0; //to index through the array when sending
void setup()
{
Serial.begin(9600);
Wire.begin();
Serial.println("Writing single byte data...");
//set storage address and value
writeData(eeprom24c16, 999 , 99 );
delay (1000);
Serial.println("Reading single byte data...");
Serial.print("location ");
Serial.print(999);
Serial.print(" holds ");
num = readData(eeprom24c16, 999 );
Serial.println(num);
Serial.println();
delay(1000);
Serial.println("Writing text string...");
Serial.print("string length= ");
Serial.println (L);
//set starting storage address and length
for (a=500; a<500+L; a++)
{
writeData(eeprom24c16, a , data[i++] );
}
delay(1000);
Serial.println("Reading text string...");
//set starting storage register and length
for (a=500; a<500+L; a++)
{
Serial.print("location ");
Serial.print(a);
Serial.print(" holds ");
d=readData(eeprom24c16,a);
Serial.println(d);
}
}
void loop()
{
}