Interfacing a CAT24Cxx I2C EEPROM tho the XIAO

I’ve tried to use the AT24Cxx and WIRE libraries only to succeed in bricking 3 XIAOs in the process. I have a programmer coming, so expect to bring the bricked units back to life.

My question, can anyone recommend a an eeprom library or have a code snippet that works with the I2C EEPROMS?

Thanks…

I use I2C_EEPROM referenced at https://www.arduino.cc/reference/en/libraries/i2c_eeprom/
This works for every Arduino chip I have ever tested (quite a few), including the XIAO
I attached my simple test program. There are a lot of very elaborate tests in the library/examples folder

My test goes like this:

  1. Read a few bytes (byte-at-a-time)
  2. Write something different in each byte
  3. Read again to see if it “took”

Doesn’t depend on any particular values at startup, and can be repeated to give different, verified results each time.

Output looks something like this (read/write/read 8 bytes starting at EEPROM address 0):

Seeeduino XIAO: I2C EEPROM test for 24C04 compiled on Dec 23 2021 at 08:53:58
EEPROM detected at I2C Device Address = 0x50

Initially
0x00:       0x5E 0x7B 0x98 0xB5 0x90 0xAD 0xCA 0xE7
Writing
0x00:       0x5F 0x7D 0x9B 0xB9 0x95 0xB3 0xD1 0xEF
New values
0x00:       0x5F 0x7D 0x9B 0xB9 0x95 0xB3 0xD1 0xEF

This is for a small device where I had defined the DEVICE_SIZE (in bytes) to 512. Works for large devices also. Just change the DEVICE_SIZE definition in my sketch to the number of bytes in your EEPROM

#define DEVICE_SIZE 4096 

Output:

Seeeduino XIAO: I2C EEPROM test for 24C256 compiled on Dec 23 2021 at 09:12:51
EEPROM detected at I2C Device Address = 0x50

Initially
0x00:       0x15 0x2B 0x41 0x57 0x6D 0x83 0x99 0xAF
Writing
0x00:       0x16 0x2D 0x44 0x5B 0x72 0x89 0xA0 0xB7
New values
0x00:       0x16 0x2D 0x44 0x5B 0x72 0x89 0xA0 0xB7

That’s all there is to it: The library works for all creatures, Great and Small.

Regards,

Dave
I2C_EEPROM_Test.zip (1.2 KB)

Thank you Dave, this is perfect and save me a bunch of time and a few bricked XIAOs…

Will dig into it tonight.

Thank you Dave, that worked first try. Excellent!