Main Content

The Most Comprehensive Guide to Programming the AT24C32 / AT24C64

I love tutorials that DIYers put online. They save so much time, and can make tackling new projects a little less intimidating and easy to comprehend. The problem I continue to run into however is the fact that no one seems to want to take the time to explain how their code or circuitactually works. They’re pretty much just like if your setup isn’t exactly like mine, than good luck figuring out how to use this code that I put 4 comments on.
What I’m here to do is change that. I want to explain the deeper level concepts, so that when it comes time for you to customize the code to your applications, you have a great starting place. So if you’re interested in how this code actually works, put down your TV remote and get ready for long tutorial.

What I cover:

Datasheet Portion:
How to read and understand the AT24 (or other I2C device) datasheet
Determine device address from datasheet
How the memory is organized
How the address rollover works
How to organize a data packet based on datasheet. We thoroughly examine the packet structure outlined in the datasheet and use that information to construct our data packet.
Understand what an 8 bit address really means

Arduino Coding Portion:
How to write the Arduino code with a line by line walkthrough
How to split a 12-bit address across 2 bytes
How to understand these lines Wire.write(byte >> 8); & Wire.write(byte & 0xFF);
How the Arduino Wire library works from the functions to the start, stop, and ACK bits.

Supplies
Wiring one of these modules is super easy! There are plenty of other tutorials showing you how to connect it all up. Since it’s an I2C device, the only connections are:

5V
GND
SDA (with 2.2K pullup to 5V)
SCL (with 2.2K pullup to 5V)”

Link to article