I have my own PCB and am interfacing a AT24C256 EEPROM with a Nano but I cannot write data to it.
I have SDA and SCL pins connected to the Nano A4 and A5 respectively.
Address is set to 0x51 (A0=5v, A1 and A2 = GND)
VCC is 5v
WP is GND
I have confirmed all of the above with a multimeter.
If I run a i2c scanner sketch it identifies a device at 0x51 as expected.
The sketch below seems to read data from the EEPROM, reporting 255 as the result.
However, after the write command it reads the same value at the next time through the loop, so it didn't program the EEPROM.
Other devices on the I2C bus work correctly (e.g. DS1307 and port expander).
When I ran out of options I swapped out the EEPROM for a different one (identical type) and this still isn't working, so I'm completely clueless about what the issue is now.
Can anybody see anything wrong with the code below??
Thanks
#include <Wire.h>
#include "RTClib.h"
#include "AT24C256.h" // The i2c Address has been set to 0x51 in here (default was 0x50)
AT24C256 eeprom = AT24C256();
byte EEPROMAddress = 0;
byte testdata = 00000000;
byte writedata = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
delay(1000); // wait for console opening
}
void loop() {
Serial.print("INITIAL VALUE: ");
Serial.println(eeprom.read(EEPROMAddress));
delay(2000);
eeprom.write(testdata,EEPROMAddress);
Serial.print("NEW VALUE: ");
Serial.println(eeprom.read(EEPROMAddress));
delay(2000);
}