CONTENTS

    How to Interface AT24C02 EEPROM with Arduino Step by Step

    avatar
    danny@gns-ic.com
    ·August 8, 2025
    ·10 min read
    How to Interface AT24C02 EEPROM with Arduino Step by Step
    Image Source: pexels

    You can easily connect the AT24C02 EEPROM to your Arduino using just a few wires. This chip gives you extra memory for your projects, which is great when you need to store settings or logs. Many people use it for storage devices, communication systems, and even in industrial applications. You will work with bytes, since the AT24C02 stores data in 8-bit chunks. Just gather your parts, hook up the wires, upload the code, and start saving data!

    Key Takeaways

    • Connect the AT24C02 to Arduino using just four main wires plus pull-up resistors for reliable I2C communication.

    • Use simple write and read functions with the Wire library to store and retrieve data byte by byte.

    • Set the chip address by wiring A0, A1, and A2 pins to ground or power to use multiple EEPROMs on one Arduino.

    • Always add a short delay after writing data to let the chip finish saving and avoid data loss.

    • Check wiring carefully and match your code address to the hardware setup to prevent common connection errors.

    Components

    Components
    Image Source: unsplash

    List

    Here’s what you’ll need to get started. You probably already have most of these parts in your electronics kit:

    Component/Pin

    Description

    Arduino Board

    The main controller for your project (Uno, Nano, or Mega work)

    AT24C02 EEPROM

    The memory chip you’ll connect to your Arduino

    Breadboard

    Lets you build the circuit without soldering

    Jumper Wires

    Used to make all the connections

    Pull-up Resistors

    4.7kΩ resistors for the SDA and SCL lines (for I2C reliability)

    USB Cable

    Connects Arduino to your computer for programming

    💡 Tip: If your Arduino board has built-in pull-up resistors, you might not need external ones. But adding them helps make sure your circuit works every time.

    Description

    Let’s break down what each part does and why you need it:

    • Arduino Board: This is your project’s brain. It sends and receives data to and from the memory chip.

    • AT24C02 EEPROM: This chip stores up to 256 bytes of data. That’s enough for settings, logs, or small files. It uses I2C, which means you only need two wires for data and clock.

    • Breadboard: You can quickly plug in your components and move things around. No soldering needed!

    • Jumper Wires: These make all the connections between your Arduino, the EEPROM, and the breadboard.

    • Pull-up Resistors: These resistors (usually 4.7kΩ) go on the SDA and SCL lines. They help the I2C signals stay clear and strong. If you skip them, you might see weird errors or no data at all.

    • USB Cable: You’ll use this to upload your code and power your Arduino.

    The EEPROM chip has a few extra pins you should know about. The A0, A1, and A2 pins let you set the device’s address. This is handy if you want to use more than one memory chip on the same Arduino. The WP (Write Protect) pin can stop you from accidentally erasing your data. Just connect it to GND if you want to write and read as normal.

    The chip runs on 5V, which matches your Arduino. You don’t need to worry about extra power supplies.

    📝 Note: The memory is organized into 32 pages, each with 8 bytes. You can store 256 bytes in total. That’s perfect for small projects!

    AT24C02 Wiring

    AT24C02 Wiring
    Image Source: unsplash

    Pinout

    Let’s start by looking at the pinout for the AT24C02 chip. You’ll see eight pins on the chip, and each one has a special job. Here’s a simple table to help you match each pin to its function:

    Pin Number

    Pin Name

    Description

    1

    A0

    Address input bit 0 for I2C slave address selection

    2

    A1

    Address input bit 1 for I2C slave address selection

    3

    A2

    Address input bit 2 for I2C slave address selection

    4

    GND

    Ground (0V reference)

    5

    SDA

    Serial Data Line (I2C bidirectional)

    6

    SCL

    Serial Clock Line (I2C clock input)

    7

    WP

    Write Protect (active high disables write)

    8

    VCC

    Power supply (1.7V to 5.5V)

    📝 Note: The address pins (A0, A1, A2) let you set the I2C address. If you connect all three to ground, you get the default address (0x50). The WP pin controls write protection. Connect it to ground if you want to write data.

    Connections

    Now, let’s wire the AT24C02 to your Arduino. You only need a few jumper wires and two pull-up resistors. Here’s a quick table to show you how to connect each pin:

    EEPROM Pin

    Arduino Pin/Connection

    Notes

    SDA

    A4 (Arduino SDA)

    Use a 4.7kΩ pull-up resistor to Vcc

    SCL

    A5 (Arduino SCL)

    Use a 4.7kΩ pull-up resistor to Vcc

    Vcc

    5V

    Power supply for the chip

    GND

    GND

    Common ground

    A0, A1, A2

    GND

    Sets default I2C address (0x50)

    WP

    GND

    Enables writing to the chip

    You’ll notice that the SDA and SCL lines need pull-up resistors. Most people use 4.7kΩ resistors, but values between 1kΩ and 10kΩ work too. If your Arduino already has built-in pull-ups, you might not need extra ones. Adding them helps keep your signals clean.

    Tip: Always double-check your connections before powering up. Missing a ground or mixing up SDA and SCL can stop your AT24C02 from working.

    Steps

    Ready to wire everything up? Just follow these steps:

    1. Place the AT24C02 chip on your breadboard. Make sure the notch or dot faces left so you can match the pin numbers.

    2. Connect pin 4 (GND) of the chip to the Arduino’s GND.

    3. Connect pin 8 (VCC) to the Arduino’s 5V pin.

    4. Attach pin 5 (SDA) to Arduino pin A4. Put a 4.7kΩ resistor between SDA and VCC.

    5. Attach pin 6 (SCL) to Arduino pin A5. Put a 4.7kΩ resistor between SCL and VCC.

    6. Tie pins 1, 2, and 3 (A0, A1, A2) to ground. This sets the chip’s address to 0x50.

    7. Connect pin 7 (WP) to ground. This lets you write data to the chip.

    8. Check all connections. Make sure nothing is loose or swapped.

    You’re using the I2C protocol here. It’s a simple way for your Arduino to talk to the AT24C02 using just two wires (SDA and SCL). The address pins (A0, A1, A2) let you set the chip’s address. If you ever add more EEPROM chips, you can change these pins to give each chip a unique address.

    💡 Note: If your circuit doesn’t work, check the pull-up resistors and make sure the address pins are grounded. Most problems come from missing resistors or wrong pin connections.

    AT24C02 Code

    Example

    Let’s get your Arduino talking to the AT24C02! Here’s a simple code example that shows you how to write a byte to the EEPROM and then read it back. You’ll use the Wire library, which makes I2C communication easy.

    #include <Wire.h>
    
    #define EEPROM_ADDR 0x50 // Default I2C address for AT24C02 (A0, A1, A2 = GND)
    
    void setup() {
      Serial.begin(9600);
      Wire.begin(); // Start I2C bus
    
      byte writeAddress = 0x10; // Memory address to write to
      byte writeData = 123;     // Data to write
    
      // Write a byte to EEPROM
      eepromWriteByte(writeAddress, writeData);
      delay(10); // Wait for write cycle to finish
    
      // Read the byte back
      byte readData = eepromReadByte(writeAddress);
    
      Serial.print("Wrote: ");
      Serial.println(writeData);
      Serial.print("Read: ");
      Serial.println(readData);
    }
    
    void loop() {
      // Nothing here
    }
    
    // Function to write a byte to AT24C02
    void eepromWriteByte(byte memAddress, byte data) {
      Wire.beginTransmission(EEPROM_ADDR);
      Wire.write(memAddress); // Memory address
      Wire.write(data);       // Data byte
      Wire.endTransmission();
    }
    
    // Function to read a byte from AT24C02
    byte eepromReadByte(byte memAddress) {
      Wire.beginTransmission(EEPROM_ADDR);
      Wire.write(memAddress); // Memory address
      Wire.endTransmission();
    
      Wire.requestFrom(EEPROM_ADDR, 1);
      if (Wire.available()) {
        return Wire.read();
      }
      return 0; // Return 0 if nothing is read
    }
    

    📝 Note: You can change the writeAddress and writeData values to test different memory locations and data.

    Explanation

    You just saw how to use the Wire library to talk to the AT24C02. Let’s break down what’s happening:

    • You include the Wire library at the top. This library lets your Arduino use the I2C protocol.

    • In setup(), you start the serial monitor and the I2C bus.

    • You pick a memory address and a value to write.

    • The eepromWriteByte function sends the memory address and the data byte to the EEPROM. The chip stores your data at that spot.

    • After writing, you wait 10 milliseconds. This pause gives the AT24C02 time to finish its write cycle. If you skip this, your data might not save correctly.

    • The eepromReadByte function sets the memory address, then asks the chip for the data stored there.

    • You print both the value you wrote and the value you read. If everything works, they should match!

    The Wire library makes I2C communication simple. You don’t need to worry about the details of the protocol. Just tell it what address to use and what data to send or receive.

    I2C Notes

    You might wonder how the Arduino knows which device to talk to on the I2C bus. The AT24C02 uses three pins—A0, A1, and A2—to set its address. Here’s how it works:

    • The base address is 0x50.

    • You can connect A0, A1, and A2 to either GND or VCC. This lets you set up to eight unique addresses, from 0x50 to 0x57.

    • If you want to use more than one AT24C02 on the same bus, just change the wiring on these pins.

    The Wire library helps you:

    1. Start I2C communication with Wire.begin().

    2. Send the device address and data using Wire.beginTransmission() and Wire.write().

    3. End the transmission with Wire.endTransmission().

    4. Request data from the EEPROM with Wire.requestFrom() and read it with Wire.read().

    ⏱️ Tip: Always wait at least 10 milliseconds after writing data to the AT24C02. This pause lets the chip finish saving your data. If you try to read or write too soon, you might get errors or lose data.

    You can use these steps to store settings, logs, or any small bits of data your project needs to remember—even after you turn off the power.

    Troubleshooting

    Issues

    You might run into a few problems when you try to connect your EEPROM to your Arduino. Here are some common issues and what you can do about them:

    • The Arduino does not detect the memory chip. This often happens if the address pins (A0, A1, A2) are not set correctly before you power up. You need to connect these pins to either GND or VCC before turning on your circuit. The chip locks in its address at power-up, so changing the pins later will not help.

    • The SDA and SCL lines do not work as expected. These lines form the I2C bus. If SDA does not stay HIGH when idle, or if SCL is HIGH but SDA never falls, your chip will not respond. Noise or a short on these lines can also cause problems.

    • The EEPROM does not respond to the address you set in your code. Double-check that the address in your code matches the wiring of the address pins. For example, if A0 is HIGH and A1, A2 are LOW, your address should be 0x51.

    • Data does not save or read back correctly. This can happen if you skip the delay after writing or if you try to write too much data at once.

    🛠️ Tip: Always check your pull-up resistors on SDA and SCL. If these lines are held LOW or shorted, communication will fail.

    Tips

    You can make your project more reliable with a few simple tricks:

    • Use small, modular functions for reading and writing. This keeps your code tidy and easy to debug.

    • Write data in blocks that fit the chip’s page size. For the 24C02, that means 8 bytes per page. If you cross a page boundary, you might lose data.

    • Add a short delay (about 10 ms) after each write. The chip needs this time to finish saving your data.

    • Read and write data in chunks that fit within the Arduino Wire library’s buffer (usually 32 bytes). This helps prevent buffer overruns.

    • Always check that the address in your code matches how you wired the address pins.

    • After writing, read the data back and print it out. This helps you catch mistakes early.

    "Breaking up your writes into page-sized blocks, waiting for the chip to finish each write, and matching your code’s address to your wiring are the best ways to avoid data corruption. When you need to store more complex data, write and read it one byte at a time to keep everything safe."

    If you follow these steps, you will have a much smoother experience. You will spend less time debugging and more time building cool projects!

    You’ve seen how simple it is to connect the AT24C02 to your Arduino and start saving data. Here are some key takeaways for beginners:

    Key Takeaway Aspect

    Explanation

    I2C Communication

    Learn how the Wire library handles data transfer and device addressing.

    Writing & Reading Data

    Use simple functions to write and read bytes reliably.

    Wiring

    Just four connections and pull-up resistors make setup easy.

    Practical Tips

    Always add a delay after writes and watch for address rollover.

    Want to learn more? Try these resources:

    The AT24C02 can handle up to 1,000,000 write/erase cycles, so avoid unnecessary writes to keep your memory chip healthy. Keep experimenting and see what you can build next!

    FAQ

    How do I know if my AT24C02 is working?

    You can check by running the example code. If the Serial Monitor shows the same value for "Wrote" and "Read," your chip works. If not, double-check your wiring and address settings.

    Can I use more than one AT24C02 on the same Arduino?

    Yes, you can! Change the A0, A1, or A2 pins to set a different I2C address for each chip. This way, you can connect up to eight chips on the same bus.

    What happens if I forget the pull-up resistors?

    Your Arduino might not talk to the EEPROM. The I2C signals need pull-up resistors to work right. If you skip them, you may see errors or no data at all.

    Is it safe to power the AT24C02 with 3.3V?

    Yes, the AT24C02 works with both 3.3V and 5V. Just make sure your Arduino also uses 3.3V logic if you pick that voltage.

    See Also

    A Comprehensive Guide To Microcontrollers And Flash Memory

    Step By Step Guide To Programming The 555 Timer IC

    An Introduction To Digital Integrated Circuits In Electronics

    Best USB To Serial Port IC Chips For 2025 Projects

    Exploring Logic IC Bus Transceivers And Their Functions

    GNS Electronics is an electronic components distributor expert.