Hi all,
I‘ve posted this question on Arduino board too.
Usually I don’t start new posts but read only in forums. But after reading posts and blogs for months I need to ask you for help directly. I’ve developed a huge project (at least for me). Now I need to implement an EEPROM to save data and configurations permanently to finish my project. I’ve setup a tiny code for debugging purpose which has same issues.
I’m using a Seeeduino XIAO on an expansion board and have soldered an external M24C02 EEPROM (TSSOP8 case).
I’ve found the EEPROM’s address with the help of I2Cscanner which is 0x51. Now I’m trying to read its data. But it gives me different values each time I read its bytes.
Hope someone can help me.
#include <Wire.h> // for I2C
#define EEPROM 0x51 // EEPROM address
byte data; // data to store in or read from the EEPROM
void setup()
{
Wire.begin();
Serial.begin(9600); // initialize serial and wait for port to open:
while (!Serial) { ; } // wait for serial port to connect. Needed for native USB port only
Serial.println("Setup done.");
}
void loop()
{
Serial.println("Reading EEPROM...");
for(byte address = 0; address < 10; address++)
{
Wire.beginTransmission(EEPROM);
Wire.write(address);
Wire.endTransmission(1);
Wire.requestFrom(EEPROM,1); // get the byte of data
data = Wire.read();
Serial.print(address);
Serial.print(" : ");
Serial.println(data, BIN);
}
Serial.println("DONE\n");
delay(30000);
}
Output:
Setup done.
Reading EEPROM…
0 : 1000
1 : 110101
2 : 10010
3 : 1011000
4 : 100
5 : 1
6 : 10000
7 : 10000000
8 : 11111001
9 : 11111001
DONEReading EEPROM…
0 : 1000
1 : 1110101
2 : 1000010
3 : 1011000
4 : 1000100
5 : 1000001
6 : 1000000
7 : 11000000
8 : 11111001
9 : 11111001
DONEReading EEPROM…
0 : 1000
1 : 110101
2 : 10010
3 : 1011001
4 : 100
5 : 1
6 : 10000
7 : 10000000
8 : 11111001
9 : 11111001
DONEReading EEPROM…
0 : 1000
1 : 1110101
2 : 1000010
3 : 1011001
4 : 1000100
5 : 1000001
6 : 1000000
7 : 11000000
8 : 11111001
9 : 11111001
DONEReading EEPROM…
0 : 1000
1 : 110101
2 : 10010
3 : 0
4 : 101
5 : 1
6 : 10000
7 : 10000000
8 : 11111001
9 : 11111001
DONE
…