Problem with i2c EEPROM
Posted: Wed Mar 16, 2022 6:17 pm
I try to use 24LC32 (http://ww1.microchip.com/downloads/en/D ... 21072G.pdf) i2c EEPROM with Nucleo F411RE and wire.h. I connect SCL pin 6 of EEPROM to D15 and SDA pin 5 of EEPROM to D14 as shown in the picture:

The code first is trying to print the output of Wire.endTransmission() after Wire.beginTransmission(address) with address: 0b1010000 (should be the correct one as 24LC32 slave address is 1010, and I connect A0 A1 A2 all to GND), 0b1010001 and 0b1000000 (to see if there is any difference). Then the code will scan through address from 0 to 127 to check any device with the i2c:
The output of this code is always:
Where 2 is the output of Wire.endTransmission() with three different address, it means I2C_NACK_ADDR
(maybe not acknowledged address?) as shown in the code at https://github.com/stm32duino/Arduino_C ... #L247-L248, and `No I2C devices found` means it cannot find any device with address 0 to 127.
I also tried use `TwoWire Wire2(PB9, PB8);` and change Wire to Wire2, or `Wire.setSDA(PB9); Wire.setSCL(PB8);`. None of it works. May I know anyone know what wrong with this? Thanks a lot!
My computer development environment is: Windows 10 19042.1052, arduino IDE 1.8.16, core 2.2.0, upload method SWD
The code first is trying to print the output of Wire.endTransmission() after Wire.beginTransmission(address) with address: 0b1010000 (should be the correct one as 24LC32 slave address is 1010, and I connect A0 A1 A2 all to GND), 0b1010001 and 0b1000000 (to see if there is any difference). Then the code will scan through address from 0 to 127 to check any device with the i2c:
Code: Select all
#include <Wire.h>
// SDA SCL
// TwoWire Wire2(PB9, PB8);
void eepromInit()
{
Serial.begin(9600);
// Wire.setSDA(PB_9); // using pin name PY_n
// Wire.setSCL(PB8); // using pin number PYn
Wire.begin();
delay(100);
byte error, address;
int nDevices;
Wire.beginTransmission(0b1000000);
error = Wire.endTransmission();
Serial.print(error);
Serial.print("\n");
Wire.beginTransmission(0b1010001);
error = Wire.endTransmission();
Serial.print(error);
Serial.print("\n");
Wire.beginTransmission(0b1010000);
error = Wire.endTransmission();
Serial.print(error);
Serial.print("\n");
nDevices = 0;
for (address = 1; address < 127; address++)
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
Serial.print("I2C device found at address 0x");
if (address < 16)
Serial.print("0 ");
Serial.println(address);
nDevices++;
}
else if (error == 4)
{
Serial.print("Unknown error at address 0x");
if (address < 16)
Serial.print("0");
Serial.println(address);
}
}
if (nDevices == 0)
Serial.print("No I2C devices found\n");
else
Serial.print("done\n");
}
void setup(void)
{
eepromInit();
}
void loop()
{
}
Code: Select all
2
2
2
No I2C devices found
(maybe not acknowledged address?) as shown in the code at https://github.com/stm32duino/Arduino_C ... #L247-L248, and `No I2C devices found` means it cannot find any device with address 0 to 127.
I also tried use `TwoWire Wire2(PB9, PB8);` and change Wire to Wire2, or `Wire.setSDA(PB9); Wire.setSCL(PB8);`. None of it works. May I know anyone know what wrong with this? Thanks a lot!
My computer development environment is: Windows 10 19042.1052, arduino IDE 1.8.16, core 2.2.0, upload method SWD