External EEPROM

I have a code for AT24C16 external eeprom.
But I don't have AT24C16 eeprom.
I have only st24c16wp eeprom.
Can I use my code with ST24C16WP eeprom.

(deleted)

found the datasheet for the st24c16wp here

datasheet for AT24C16 here

Both are I2C EEPROM so fair chance it might work.

ST24C16WP
what does mean by WP.
datasheet didn't give any idea.

I made my code for AT24C1024 in proteus simulator. In simulator the code properly works.
Then I use that code with ST24C16WP. Then program does not work properly.

My code for write data
void eepromWrite(int Input1,int Input2)
{
lcd.clear();
Wire.beginTransmission(0x50);
lcd.print("Writing Data");
delay(50);
Wire.write(lowWrite);
delay(50);
Wire.write(lowWrite);
delay(50);
Wire.write(Input1);
delay(50);
Wire.write(Input2);
delay(50);
Wire.endTransmission();
lowWrite++;
delay(100);

}

My code for read data
lcd.clear();
Wire.beginTransmission(0x50);
lcd.print("Reading Data");
delay(50);
Wire.write(lowRead);
delay(50);
Wire.write(lowRead);
delay(50);
Wire.endTransmission();
delay(50);
Wire.requestFrom(0x50,2);
Out1=Wire.read();
delay(50);
Out2=Wire.read();
delay(50);
OutVal=Out1*256+Out2;
lowRead++;
ReadCount++;
delay(200);
}

your code makes no sense to me

why all the delay(50)'s ?
why 2x Wire.write(lowWrite); // what is in it?

Wire.endTransmission(); does the actual write and returns an integer that shows error conditions.
please add it to the code

EEPROMs are very slow so they want some time to read and Write.
I store integer in EEPROM . EEPROM can't store Integers.
So I break integer into 2 parts.

Input1=Integer/256
Input2=Integer%256

then I wrote them into EEPROM.

I read them also in that way.

I have a Tiny ds1307 rtc module which has an EEPROM marked 24c32wp and an ST laser scribed on it, but it could be a Chinese whatever chip. I use an R3 Uno with standard wire.h for I2C at ox50 to address it.

I also don't understand your code, and the EEPROM requires a high byte/low byte index usually done with bit shift and masking.

Some code samples I have looked at may use a delay(5)or delay(10) but 50 seems excessive.

I think the chip should look like an AT EEPROM. Mine does at the fairly simple ways I am using it.

Can you post your code?

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()
{

}