I'm trying to figure out how to write a program that will dump the entire contents of an I2C EEPROM (in this case, a 24LC16B) out to serial. From what I read in the datasheet for the EEPROM, there's an internal pointer or something on the chip, and a read will start wherever it is (random read). If you want to do a sequential read, you have to do a write first to update that pointer, then switch to reading.

Can anyone give me an idea on how to get started? I've looked at the I2E_EEPROM sample on the playground, but there's something I'm missing.

Hi, I have a 24LC256 (which I believe is similar to yours but just with a larger capacity).

To update the pointer you send the address that you want to read from using Wire.send(). There are two Wire.send() calls because the EEPROM address, which ranges from 0x0000 to 0x07FF takes 2 bytes to store. So as an example, if you wanted to start reading from the 1024th byte of the EEPROM you would do:

Do not read more than 30 bytes in one requestFrom() call because the size of the Wire library's receive buffer is 30 bytes.When dumping your EEPROM, I recommend you use 16 bytes as its evenly divisible into 2048 bytes (the size of your EEPROM). This way you can split your EEPROM into 128 "pages" or blocks (each 16 bytes in size).

So to dump your entire EEPROM, loop through all 128 pages, incrementing the internal pointer by 16 each time. Instead of storing the result from Wire.receive() in an array you can print it directly over the serial connection.

Note: In the above code examples, I2C_EEPROM_ADDR, should be the I2C address of your EEPROM (if you leave the 3 address pins floating or connected to ground, it will be 0x50).

If I do some basic math and set "eeaddress" to 1023, the above lines would send "3" and "255" to the I2C bus. Should it be sending "255" for the LSB, or should it be sending "FF"? Something more like this:

From what I can tell, this should open the I2C bus, move the address pointer to the first memory block, and write either the decimal value "33" or the ASCII equivalent "!" to that space. My understanding from the datasheet for the 24LC16B is that the pointer increments by 1 after every operation, so the next little piece moves back to 0x0000 and does a read. I would expect that the read would come back with either the 33 or the ! as well, but I get nothing. My serial monitor shows the 33 on one line, and that unprintable square character on the second line.

To write you only pass it two values, one which specifies the lower 8 bits of the address, and one for data. Then, there needs to be a delay to allow the writing to happen, the data sheet says a max of 10ms, so 15ms might be longer than needed, but ensures it is definately written. Also, the requesting needs to go between its own set of begin/end transmission commands.

Here's a simple method I wrote to dump the whole EEPROM for a project of mine:

and so on, down to 0x08-0xF8. I get the same results with two different chips, which is why I think something isn't right. One of them is a brand new engineering sample, delivered from Taiwan earlier this week. The other was removed from a device (motorcycle dash) that was produced in 2003.

I'm using a Sparkfun Wee, attached to an FTID TTL-232R cable. I've got pins A0, A1, A2, and Vss on the EEPROM wired to GND on the Wee, Vcc wired to 3.3V, WP jumpered over to Vcc (which should enable WP), SCL to pin 5, and SDA to pin 4.

and so on, down to 0x08-0xF8. I get the same results with two different chips, which is why I think something isn't right. One of them is a brand new engineering sample, delivered from Taiwan earlier this week. The other was removed from a device (motorcycle dash) that was produced in 2003.

I'm using a Sparkfun Wee, attached to an FTID TTL-232R cable. I've got pins A0, A1, A2, and Vss on the EEPROM wired to GND on the Wee, Vcc wired to 3.3V, WP jumpered over to Vcc (which should enable WP), SCL to pin 5, and SDA to pin 4.

I'd check your power connections, I get exactly that output when I remove the chip from the circuit.

I am a beginner, and probably don't know what I am talking about, but I have been having problems interfacing with I2C and a sparkfun wee. I was wondering if pin 4 is still sda and pin 5 is scl on that board.

and so on, down to 0x08-0xF8. I get the same results with two different chips, which is why I think something isn't right. One of them is a brand new engineering sample, delivered from Taiwan earlier this week. The other was removed from a device (motorcycle dash) that was produced in 2003.

I'm using a Sparkfun Wee, attached to an FTID TTL-232R cable. I've got pins A0, A1, A2, and Vss on the EEPROM wired to GND on the Wee, Vcc wired to 3.3V, WP jumpered over to Vcc (which should enable WP), SCL to pin 5, and SDA to pin 4.

Just to clarify....do you have it connecte to pin 4 & 5 digital or analog - I2C bus is pins 4 & 5 of the Analog inputs. I've seen quite a few people get this mixed up.