Go Down

Topic: Problem writting I2C 24Cxx Eeprom (Read 2534 times) previous topic - next topic



I've been trying to work with I2C  24C02 Eeprom and got trough different issues.

With some help from the forum I fixed some but I still have problem writting data in the Eeprom.
I have erratic data when using this code.

Code: [Select]
#include <Wire.h>     // for I2C
#define i2caddr 0x50    // device address
byte d=0; // data to store in or read from the EEPROM

void setup()
  Serial.begin(9600); // Initialize the serial line
  Wire.begin();         // wake up the I2C

  Serial.println("Writing data...");
  for (int i=0; i<257; i++)
  Serial.println("Reading data...");
  for (int i=0; i<257; i++)
    Serial.print(" : ");
    Serial.println(d, DEC);


// writes a byte of data in memory location addr
void writeData(unsigned int addr, byte data)
  // set the pointer position
  //Wire.write((int)(addr >> 8));
  Wire.write((int)(addr & 0xFF));
  while(1) {
      if(Wire.endTransmission() == 0)break;

// reads a byte of data from memory location addr
byte readData(unsigned int addr)
  byte result;
  // set the pointer position
  //Wire.write((int)(addr >> 8));
  Wire.write((int)(addr & 0xFF));
  Wire.requestFrom(i2caddr,1); // get the byte of data
  result = Wire.read();
  return result;

void loop()

I tried many thing and made a mistake.
I put 12V to the Eeprom instead of 5V. It means the Vcc Eeprom  was 12V, but also the SDL and SDA pull up resistor !

And this way, I got the writing procedure working good !

I was lucky to not fry the Eeprom and the SDA /SCL port of my Arduino !

But why does it work with 12V and not with the 5V (Arduino fed from USB or 12V). Even with proper 5V from Arduino board or external 5V, it doesn't write the Eeprom.


Check this - http://playground.arduino.cc/Main/LibraryForI2CEEPROM -

not tried with the 24C02 but it might just work!
let me know so I can update the playground article.

do you have a link to the datasheet of the 24C02?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)


No sorry, I have no datasheet because they are bits from different places.

Some are from my toner printer chip I want to rewrite, and some other from old TV's to try and test.

I'll have a look at the link but I'm very bad in programming and understanding program.

I'll come back and say something.



Well, I put some pull up resistor on SDA and SCL (5KOhm between 5V and SDA and SCL) as it was said on were I've been looking from.

But it seems that the way the code is made is using the inner Arduino's pull up resistor !
And the wiring doesn't need external pull up resistor.

When I remove them, It seems to work fine.
I'll make some new test to be sure now that I'm getting unstuck with this.

But Why, when I made the mistake to put the Eeprom under 12V, it worked ?
Am I missing something ?
A luck I didn't burned my arduino and the Eeprom.

Anybody know the internal Arduino's pull up resistor. These must have been quite hot for some time


As it's been said earlier, the pull-up resistor are necessary (I'm using 4-5kOhm) despite it can work without because of the Arduino's internal pull-up resistor of I think 40kOHm.
But in case of capacitive line, it would not work properly (longer line or more than 1 I2C device on the same bus)

It seems the  "EEPROM_READ" you're using is to read the Arduino's internal Eeprom.

To read I2C Eeprom, you must use the wire.h library.

The pin 7 (WC) must be HIGH only if you want to be sure not to overwrite the Eeprom by mistake.
I usually put pin 1, 2, 3, 4, and 7 to ground to not let them floating (in case)

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131