Trouble interfacing to a AT24C256 EEPROM Using NAno

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

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??


#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:
  delay(1000);                                                                                    // wait for console opening


void loop() {

Serial.print("INITIAL VALUE: ");


Serial.print("NEW VALUE: ");


Have you tried the example sketches that come with the EEPROM library you used? Do you have pull up resistors on the I2C lines?

I checked the example but it wasn't useful. And yes the pull up resistors are present - the other i2c devices work correctly on the same 'bus'.

I tried using the EEPROM.h library instead and that did seem to work fine so I think I'm going to just use that instead of AT24C256.h

It's weird though because I'm sure I had a sketch working with that library previously

This AT24C256 library ?

That library uses default 0x50 as I2C address and your chip is at 0x51.
If the device does not exist, then the library returns 0xFF.

1 Like

Sorry, does that mean you tried it or just read it? If you tried it, what happened?

1 Like

Yes I had already changed the address in AT24C256.h so that shouldn't have been an issue. Just to make sure I tried changing it back to 0x50 but it still didn't work.

Did you do that in your sketch, or in the example sketch?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.