What I2C address should I set for this 24LC04 EEPROM?

Hello, I have this project including Arduino Zero's SAMD21G18, and EEPROM 24LC04BT

image

The pins SDA/SCL are connected to ports PA22/23.

In my code, I'm trying to write into the EEPROM using library I2C_EEPROM.

I've started with this code:

I2C_eeprom ee(0x50, I2C_DEVICESIZE_24LC04);
ee.begin();
if (!ee.isConnected())
{
   // error!
}

Sadly, I enter in the error case so I started thinking that the 0x50 address I gave is not correct.
How can I be sure that the address is correct? What should I have to check?

Thanks

Run the attched scanner program to know the address of your EEPROM.
i2cScanner.ino (540 Bytes)

0x50 is correct (without the ** **)
Is WP connected to ground?

0x50 is correct (without the ** **)
Is WP connected to ground?

Sorry, ** was a typo during the copy/paste
WP is connected to GND, this is the full picture

image

I've run the I2CScanner and the output was:

I2C Device found at address: 0x50
I2C Device found at address: 0x51
I2C Device found at address: 0x52
I2C Device found at address: 0x53
I2C Device found at address: 0x54
I2C Device found at address: 0x55
I2C Device found at address: 0x56
I2C Device found at address: 0x57

So I've started to try every address, but I always end inside the error case :frowning:
Should I check other things?

If the scanner find it then you have an error in your code.
Post your entire code.

1 Like

0x50 is the correct address. Your library has a number of examples that can test your setup. You should first get one of those examples working, then switch to testing your code.

1 Like

Please, post the picture of your EEPROM to see how many pins it has.

In the IDE click on Edit then on Copy for Forum. That will copy your code. Then come here and just do a paste. No code tags or quotes needed

Here is the most minimal code I've tested. The begin() always returns FALSE.
Do you think I should set some GPIOs/peripherals in certain ways before initializing the eeprom?

#include <I2C_eeprom.h>

#define EEPROM_ADDRESS 0x50
#define EEPROM_SIZE I2C_DEVICESIZE_24LC04

void setup() {
  SerialUSB.begin(9600);
  while(!SerialUSB);

  I2C_eeprom eeprom(EEPROM_ADDRESS, EEPROM_SIZE);
  if (!eeprom.begin())
  {
    SerialUSB.println("Eeprom init failed");
  }
  else SerialUSB.println("OK");
}

void loop() {
  // put your main code here, to run repeatedly:

}

Please, post the picture of your EEPROM to see how many pins it has.

Here is it...

image

I'm an idiot :slight_smile: I must call Wire.begin() before the eeprom init...

Sorry everyone, thanks for your time!

1 Like

Been there.
Glad you got it to work

Read the datasheet

What a nice little part with no address legs to worry about whether they float high or whatever.

@misterbirra as @jim-p sez, we all done that. You can sorta go easier on yourself as many things that use Wire do no need the explicit call to its begin() method… I bet there are lotsa ppl who don't even know it's at the bottom of what they are doing.

a7

1 Like

Well, I for one have never done anything like that. No. Not once. And I'm sure I never would. I'm never rong.

Indeed

1 Like