Hi guys,
I'm new to Arduino and for a simple challenge, I need your help. I had three eeprom (AT24C02) memories with 0x50 addresses over I2C. I want to read the stored data of all three eeproms simultaneously, but because of the same I2C address', I use a tca9548 module as an i2c multiplexer. I looked at some available examples of tca9548 which in most people use the same displays or same sensors. But for accessing eeprom stings, I cannot manage the code. here I put the of one eeproms, which works well, but to merge it into three eeprom with tca9548 I have some problems.
Thanks for your reply and sorry for the delay.
I should mention that I have no problem with an eeprom.
Sorry, I have no access to fritzing or others to draw the wiring diagram. Wiring is so simple;
On one eeprom config, the vcc and ground were connected to power pins on arduino mega and Sda/Scl were also connected to related pins(21/22) on arduino.
** On three config, eeproms all powered by arduino, and Sda/Scl of the first eeprom to the third one are wired to channel 0 to channel 2 of TCA9548A in order. Also, the multiplexer is powered by arduino.
You are right but, the above code is related to one eeprom, so I didn't put any TCA9548 header or library.
In most cases people usually use TCA9548.h, which is available on Arduino's online library.
My problem is how to merge 3 codes of the above one( with same i2c address; 0x50) , to use by TCA9548.
One thing more, I know AT24C02 has ability to have different i2c address by selecting different values on A0, A1 and A2 pins.
the challenge is to set all 3 eeproms on the same address.
Ok. How many pins does your EEPROM have? Is it an 8-pin DIL (aka PDIP) package or another type of surface mount package as @sterretje has already mentioned?
The Atmel datasheet for an AT24C02 shows the following available packages (datasheet from 2007 I think):
As you can see from the above, all package variants EXCEPT SOT23 have the A0, A1 and A2 address pins available. If your device is one of these, then you don't need the multiplexer. Simply connect up the A0, A1 and A2 pins to assign different addresses to each EEPROM.
Again, from the datasheet:
The A2, A1 and A0 pins are device address inputs that are hard wired for the AT24C01A and the AT24C02. As many as eight 1K/2K devices may be addressed on a single bus system (device addressing is discussed in detail under the Device Addressing section).
If you have the SOT23 devices, then you would need to determine if the EEPROM library you are using supports 3 instances of the EEPROM with the same address. As I suspect that having only one instance of the EEPROM but switching between 3 physical devices using the I2C mux might mess things up for you.
Yes. No problem. If you want to keep each EEPROM at the same address, then you can use the I2C mux to switch between them.
Simply select the MUX channel for the EEPROM you want to address the read or write your data.
That's it. But check the EEPROM library you intend to use first in case it does some clever stuff such as caching the data as it will go wrong when you switch MUX channels and access a different EEPROM - the library won't know you've done this.