This project includes to to use an AT24C64 EEPROM and read an BME280 sensor.
First i only connected the EEPROM and it was not found.

After i connected additionally the BME280 i get
I have not analyzed the timing or anything else yet and want to ask if maybe someone has an idea why this happens?Scanning...
I2C device found at address 0x50 !
I2C device found at address 0x76 !
My assumption is that it has to do with the I2C bus speed.
But how i can find out which one is used or how it can be configured?
There is this basic documentation https://github.com/stm32duino/wiki/wiki/API#i2C
and I2C-Timing in https://github.com/stm32duino/wiki/wiki ... i2c-timing.
For an blue-pill the variant.h has to be modified in ../arduino15/packages/STM32/hardware/stm32/1.8.0/variants/PILL_F103XX ?
I2C_TIMING_SM for Standard Mode (100kHz)
I2C_TIMING_FM for Fast Mode (400kHz)
I2C_TIMING_FMP for Fast Mode Plus (1000kHz)
Is the lowest speed the standard speed?
At least the speed is not critical - it only has to work and it would be fine if the EEPROM could be used standalone.
Here is the basic code:
Code: Select all
#include <Wire.h>
void scan(void) {
byte error, address;
int nDevices;
Serial.println("Scanning...");
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.print(address,HEX);
Serial.println(" !");
nDevices++;
}
else if (error==4)
{
Serial.print("Unknown error at address 0x");
if (address<16)
Serial.print("0");
Serial.println(address,HEX);
}
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");
}
void setup() {
Wire.begin(); // initialise the connection
Serial.begin(115200);
Serial.println("I2C Test");
}
void loop() {
scan();
delay(5000);
}
