And, you've presumably modified your code to write and read using that address, and you had problems. I thought it was that code you wanted help with.
Yes, I've modified my code to read/write one byte at a time at 0xE8.
Here is the code I am using:
#include <Wire.h> //I2C library
byte DEV_ADDR = 0xE8;
uint8_t i2c_eeprom_write_byte( int deviceaddress, unsigned int eeaddress, byte data ) {
int rdata = data;
Wire.beginTransmission(deviceaddress);
Wire.write((int)(eeaddress >> 8)); // MSB
Wire.write((int)(eeaddress & 0xFF)); // LSB
Wire.write((byte)rdata);
return Wire.endTransmission();
}
byte i2c_eeprom_read_byte( int deviceaddress, unsigned int eeaddress ) {
byte rdata = 0xFF;
Wire.beginTransmission(deviceaddress);
Wire.write((int)(eeaddress >> 8)); // MSB
Wire.write((int)(eeaddress & 0xFF)); // LSB
Wire.endTransmission();
delay(25);
Wire.requestFrom(deviceaddress,1);
if (Wire.available()) rdata = Wire.read();
return rdata;
}
void setup()
{
Wire.begin(); // initialise the connection
Serial.begin(115200);
// write from A..Z in addresses 0..25
for (byte i=0;i<=25;i++)
if (i2c_eeprom_write_byte(DEV_ADDR, i, i+65) == 0) {
Serial.print("W:0x");
Serial.print(i, HEX);
Serial.print(" = > ");
Serial.println((char)(i+65)); // byte written
delay(1000);
}
Serial.println("\n\nMemory written ------------------ \n\n");
}
void loop()
{
Serial.println("\n\n ------------------ Reading memory");
byte b = '-'; // just to make sure it's not gibberish
for (int addr = 0; addr <= 25; addr++)
{
b = i2c_eeprom_read_byte(DEV_ADDR, addr);
Serial.print("R:0x");
Serial.print(addr, HEX);
Serial.print(" = > ");
Serial.println((char)b); //print content to serial port
b = '-';
delay(1);
}
Serial.println(" ");
delay(200000);
}
In the setup, it just appears to be doing the writing successfully, but actually nothing is done.
The problem is that when reading, it only reads 'Z' all the time, because that's the last byte that was written, so I guess it is something that was left in some buffer, but not actually written to the EEPROM.
I run that code once. Bytes from 0..25 should be A..Z, right? Because it wsa written in the previous run. However, if I comment the writting code and just leave the reading code, nothing is read. Literally, it reads blanks.
I am sure that the WP pin is grounded, so writing should be enabled.
So that are 2 things that are weird.
BTW, I am feeding this IC with 5V. According to its marking, it is the 2.7V version, so it can go up to 5.5V (and 6.5V absolute maximum according to the datasheet).
Thanks a lot for your help, PaulS.