Copy data 24c08wp arduino uno

Hello,

What I want to do is read data from a 24C08 and save it to an Arduino Uno. And then write the data to another 24C08.

So, copy the data from one 24C08 to another.

Could you give me some tips on how to do this or where I can find information?

This is because I don't have much experience with this yet.

There are libraries that can read external I2C EEPROMs.

The 24C08 is a 1kByte EEPROM. Storing its content in the UNO's RAM eats away 50% of the RAM which might not leave you much for other variables; you'll have to test that. So it might be better to read a smaller batch of bytes and write that to the other EEPROM.

That might give the problem that both EEPROMs need to be connected at the same time and that they need to have different I2C addresses.

If that is not possible you can copy the content of the EEPROM to the Arduino's EEPROM (it's 1k so will just fit).
After reading you can power off the setup, disconnect the external EEPROM, reconnect the other one and write the data from de UNO's EEPROM to the new external EEPROM.

EEPROMs don't have an eternal life if you write often. If you want to do your copy exercise via the UNO's EEPROM you can do that 100,000 times before the UNO's EEPROM might become unreliable.

Interesting application!

Not tested with the 24C08 but I expect it to be compatible with the 24LC08

This library has the functions

  • uint8_t readByte(uint16_t memoryAddress)
  • uint16_t readBlock(uint16_t memoryAddress, uint8_t * buffer, uint16_t length)
  • bool writeByteVerify(uint16_t memoryAddress, uint8_t value)

So you can verify every byte if there is an error when writing the byte.
The library has also block functions to write that are much faster but those do not indicate which byte fails.

This is what I used it may work with your type ```


#include <Wire.h>
 #define I2C_SDA 27
#define I2C_SCL  22
const int SOURCE_EEPROM_ADDR = 0x53; // Replace with your source EEPROM's address
const int DEST_EEPROM_ADDR = 0x50; // Replace with your destination EEPROM's address
const int EEPROM_SIZE = 32768; // Example: for a 24LC256 (256 Kbit = 32 KB)
const int CHUNK_SIZE = 32;

void setup() {
  Serial.begin(115200);
  Wire.setPins(I2C_SDA,I2C_SCL);
  Wire.begin(I2C_SDA, I2C_SCL);
}

void loop() {
  Serial.println("Starting EEPROM copy...");
  
  for (int address = 0; address < EEPROM_SIZE; address += CHUNK_SIZE) {
    // Read a chunk from the source EEPROM
    byte data[CHUNK_SIZE];
    Wire.beginTransmission(SOURCE_EEPROM_ADDR);
    Wire.write((int)(address >> 8));   // MSB
    Wire.write((int)(address & 0xFF)); // LSB
    Wire.endTransmission();
    
    Wire.requestFrom(SOURCE_EEPROM_ADDR, CHUNK_SIZE);
    int i = 0;
    while (Wire.available() && i < CHUNK_SIZE) {
      data[i++] = Wire.read();
    }
    
    // **New: Serial Dump of the incoming data chunk**
    Serial.print("Address 0x");
    if (address < 0x1000) Serial.print("0");
    if (address < 0x100) Serial.print("0");
    if (address < 0x10) Serial.print("0");
    Serial.print(address, HEX);
    Serial.print(": ");
    
    for (int j = 0; j < CHUNK_SIZE; j++) {
      if (data[j] < 0x10) Serial.print("0");
      Serial.print(data[j], HEX);
      Serial.print(" ");
    }
    Serial.println(); // New line after each chunk
    
    // Write the same chunk to the destination EEPROM
    Wire.beginTransmission(DEST_EEPROM_ADDR);
    Wire.write((int)(address >> 8));   // MSB
    Wire.write((int)(address & 0xFF)); // LSB
    Wire.write(data, CHUNK_SIZE);
    Wire.endTransmission();
    
    // Wait for the write cycle to complete
    delay(5); 
  }
  
  Serial.println("\nCopy complete!");
  while (1); // Stop the program after copying
}

Me being on the looking for an easy way I would simply connect two of them to the Arduino then copy from one to the other. Adapter boards are available and are not very expensive.

Here is the link: https://www.waveshare.com/at24cxx-eeprom-board.htm

That’s the exact unit I used easy to set different address and connections

Two of them a bit of code and you have it.

Okay, thanks for the info.

I'm going to order the AT24CXX EEPROM board first.

Then I'll test Steveiboy's program first.

Many of the different parts are pinned out the same, hopefully that can save you some time and effort,

Sorry, this board is an SMD version, I want a board in a DIL8 socket version for my application.

Get your favorite search engine and look for ‘AT24C breakout board dip socket' I found several. You can also get a plain board and add a test socket if you want.

Hello,

For clarity, I'm using the Arduino UNO SMD and Arduino IDE 2.3.6.

I've now installed the hardware.

After installing and verifying the program, I receive the following error message:

Compilation error: 'class TwoWire' has no member named 'setPins'

I have not yet been able to find the error.

Would you like a tip regarding the error code?

Change your setup to

void setup() {
  Serial.begin(115200);
  //  Wire.setPins(I2C_SDA,I2C_SCL);
  Wire.begin();
}

Sorry I forgot my code is for ESP32 and did not having any issues compiling it but like Rob said remove those lines

Okay, thanks for the information. I'll continue next week.

I'll let you know as soon as I know more.

Hello,

I haven't quite figured it out yet. The serial data isn't on the SCL and SDA pins, but on the TX and RX pins. And I still can't figure out how to adjust that. I assume I need to use either SCL and SDA or A5 and A4 for proper operation.

Hello,

I'm still having the same problem:

I don't have the serial data on the SDA and SCL.

I think I haven't installed something correctly, but I still can't figure out what the problem is.

I've also added the current program.

Can anyone give me a tip on where to look to solve the problem?

#include <Wire.h>

#define I2C_SDA 21
#define I2C_SCL 22

const int SOURCE_EEPROM_ADDR = 0x50; // Replace with your source EEPROM's address
const int DEST_EEPROM_ADDR = 0x53; // Replace with your destination EEPROM's address
const int EEPROM_SIZE = 32768; // Example: for a 24LC256 (256 Kbit = 32 KB)
const int CHUNK_SIZE = 32;


void setup() {
  Serial.begin(115200);
  Wire.begin();    // Initialize I2C communication
}

void loop() {
  Serial.println("Starting EEPROM copy...");
  
  for (int address = 0; address < EEPROM_SIZE; address += CHUNK_SIZE) {
    // Read a chunk from the source EEPROM
    byte data[CHUNK_SIZE];
    Wire.beginTransmission(SOURCE_EEPROM_ADDR);
    Wire.write((int)(address >> 8));   // MSB
    Wire.write((int)(address & 0xFF)); // LSB
    Wire.endTransmission();
    
    Wire.requestFrom(SOURCE_EEPROM_ADDR, CHUNK_SIZE);
    int i = 0;
    while (Wire.available() && i < CHUNK_SIZE) {
      data[i++] = Wire.read();
    }
    
    // **New: Serial Dump of the incoming data chunk**
    Serial.print("Address 0x");
    if (address < 0x1000) Serial.print("0");
    if (address < 0x100) Serial.print("0");
    if (address < 0x10) Serial.print("0");
    Serial.print(address, HEX);
    Serial.print(": ");
    
    for (int j = 0; j < CHUNK_SIZE; j++) {
      if (data[j] < 0x10) Serial.print("0");
      Serial.print(data[j], HEX);
      Serial.print(" ");
    }
    Serial.println(); // New line after each chunk
    
    // Write the same chunk to the destination EEPROM
    Wire.beginTransmission(DEST_EEPROM_ADDR);
    Wire.write((int)(address >> 8));   // MSB
    Wire.write((int)(address & 0xFF)); // LSB
    Wire.write(data, CHUNK_SIZE);
    Wire.endTransmission();
    
    // Wait for the write cycle to complete
    delay(5); 
  }
  
  Serial.println("\nCopy complete!");
  while (1); // Stop the program after copying
}

Did you run an I2C scanner (I think there is one in the IDE) to check whicg addresses are reported for both 24C08 ICs?

I think we don't understand each other well. Perhaps the following is clearer about what I'm getting at.

I want to use the above program to read an external 24C08 and write the code to another external 24C08 with the Arduino UNO R3.

I am unable to select the I2C pins with the above program of the Arduino UNO R3.

You can't select the pins on an Uno. They are A4 and A5 (as well as the matching pins next to AREF).