Multiple I2C on Uno does not work

I have an Arduino Uno, controlling a 0.96" OLED on I2C bus. Works well.
I then connect a temperature sensor to the same I2C bus, but then the code is stuck at initialization:

display.begin(SSD1306_SWITCHCAPVCC, 0x3C);

If I use the I2C_scanner from the Arduino IDE example, then it finds both I2C devices.

Can you please help me find out why it is stuck?

are all your devices 5V compatible ?
Did you try adding some pull-ups on the I2C lines?

Please post your code you are trying to use with code tags.

No, I run all I2C on +3V3 using pull-ups. Uno runs on 5V.
Threshold for reading "1" is 2.6V according to fig. 29-11 in the 328P datasheet.

but your Arduino Pins for SCL & SDA are on 5V. Are you using an I2C voltage shifter ?

you can find ready made components that take 5V on one side and 3.3V on the other side and will deal with shifting the voltage in both directions

(look for I2C level shifter)

The high level for SDA and SCL are minimal 3.5V according to the datasheet.

Using this datasheet, page 317, VIH should be minimal 0.7 VCC.

I see typical signaling at power-on on at both SCL and SDA, but SDA never returns to +3V3 idle, like it should. SCL does.

Does the ssd1306 library really support other I2C devices on the bus, if it isn't same or similar displays?

The inputs should accept 3.3V as "high" as the threshold for reading "1" is 2.6V according to fig. 29-11 in the 328P datasheet with 5V as supply voltage.

Which datasheet are you looking at ? I can not find fig. 29-11 in the datasheet at the manufacturer's page: https://www.microchip.com/en-us/product/ATmega328p.

Even the "automotive" version has 0.7 VCC on page 264, that is 3.5V as minimum to see SDA and SCL as a high.

I tried to increase the pull-up voltage to 3.55V. Still the same.

OLED displays are known for disturbing the I2C bus for others. They are internally 3.3V, but are sold as 3-5V. Only Adafruit makes them compatible to 5V Arduino boards by adding a level shifter.
Can you tell what the temperature sensor is ?
Do you use cables ?

If the temperature sensor has a 5V I2C bus, then perhaps a level shifter for the OLED will help.

Thanks, but it there any work around?
Yes, temp sensor works if I remove the display on the bus.

It was just a matter of too high pull-up resistors. Thanks for helping me out.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.