Hello, I have this project including Arduino Zero's SAMD21G18, and EEPROM 24LC04BT
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?
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
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
Should I check other things?
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.
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.
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.