Using AT24C512 with Arduino I2C and controll the addresses using the serial monitor

Hey everyone!

I recently got my hands on an AT25C512 IC to explore data storage and dive deeper into how I2C works. While most tutorials I’ve found simply connect the address pins to ground, I’m looking to take it a step further! I want to control those address pins dynamically using an Arduino through the Serial Monitor.

Here’s the plan: I’d love to set up an interactive interface in the Serial Monitor where I can write data to the IC in hex, and after each read/write cycle, it asks if I want to continue reading or writing.

If anyone has advice or guidance on how to make this happen, I’d really appreciate your help! Time’s ticking, so I’d love to get this up and running as soon as possible. Thanks in advance!

Have you tried to use the serial monitor to send data back and forth to an Arduino program?

I'm not quite sure how that relates to the I2C addresses of the EEPROM.

You might want to give more details.

Didn't get what you are trying to say.

So when we use the wire library how does it do both reading and writing?

Below are the basics.

I2C uses an address to talk to the device. For some devices, that address is configurable using the address pins. That way you can have multiple devices of the same type on the I2C bus; e.g. multiple EEPROMs.

The above address consists of 7 bits; the remaining bit in the address byte is used to tell device if the microcontroller writes data to the device or reads data from the device.

Then e.g. your EEPROM has 64k storage locations. To store something in that EEPROM, you need to tell it where you want to store it; the location where you want to store it is also known as an address (but it's not the same as the above address). Same for reading, you need to tell the EEPROM from with storage location to read.

It's great to see your enthusiasm. What are the benefits you are hoping for by controlling the address pins this way?

Please, follow these steps to make see progresses of your Project:
1. Connect youe EEPROM with Arduino UNO as per Fig-1:


Figure-1:

2. Create/upload sketch to receive address 0x1234 and the data 0x23 (to be written into this location) from the InputBox of Serial Monitor.

3. Send commad "Read EEPROM from ocation 0x1234" from Serial Monito and show the data (0x23) on the OutputBox of Serial Monitor.

Have you actually tried to do anything yet with the serial monitor, have you written code?

Yes, I have tried but it did not work.

But how do we know when to read or write?

Show us what you have tried; please do not forget to use code tags as described in How to get the best out of this forum. Tell us what you expect that code to do and what it actually does.

I accidently deleted it. :grimacing:

Because then we get to use all the addresses

Ok thanks! now I have usefully done it! thanks for your help :grinning:

@robocoparc

1. Have you read the data sheets of AT24C512 EEPROM?

2. Do you its capacity in bits?

3. Do you know its capacity in bytes?

4. Do yoou know the purpose of the address lines of the EEPROM?

5. Can you show the codes for pointing the address 0x1234 of the EEPROM?

There is no benefit to that. Only one address is needed, unless you have more than one of the chips. Then you need to give each a different address. Once set to different addresses, they don't need to be changed again. So there is no benefit to changing the address dynamically, unless you have thought of something I haven't.

Maybe bank switching? :wink:

1 Like

Go back and read post #7.

The address pins are used to select the I2C address of the AT24C512, so that multiple AT24C512 chips can be connected to the same I2C bus simultaneously. The only time you would need to change those pins dynamically is when there are more than four AT24C512's connected to the same I2C bus, which you have not indicated you are doing.

You need to read the data sheet for the AT24C512, it details the sequence for read/writing the memory in the chip. All memory addresses within the AT24C512 are read/written from the same I2C address, regardless of which I2C address you select with the address pins.

1 Like

So this homework assignment is due Monday and you’ve just started?