Help connecting two I2C slaves with Arduino Uno master.

Hello, I am trying to get an Arduino Uno Rev. 3 to communicate to a BME280 sensor and a 128x32 OLED. I’ve connected both slaves and master parallel to the SCL and SDA buses as per protocol, and those respective buses to VCC with pull-up resistors. I can pull data from the BME sensor, but when I try to display a message to the OLED, I get some white noise which faintly resembles my message.

I have ensured that the sensor and OLED are not defective by testing them successfully in a 1 slave 1 master setup.

I have attached my code as well as a picture of my setup and a list of troubleshooting routes taken to help arrive at a solution quicker.

Troubleshooting:
Using pairs of 10K, 2K, and 1K pull-up resistors to VCC for the SCL and SDA buses.
Using no resistors, but still connecting SDA and SCL to VCC.
Using no resistors and no VCC connection on SCL and SDA.
Replacing resistors.
Replacing jumper wires.
Measuring voltage levels on each component.

/*******************************************************************************************
   @author    
   @date      

 *******************************************************************************************/
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_BME280.h>

#define SCREEN_WIDTH            128
#define SCREEN_HEIGHT           32

volatile float display_val; //Value from BME280 register reads go here

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire); //OLED I2C init
Adafruit_BME280 bme;                                          //BME280 I2C init

void setup() {
  Serial.begin(9600);
  while(!Serial);  
  
  unsigned status;
  status = bme.begin(0x76, &Wire); //Start BME280 Connection
  if (!status) {
      Serial.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
      Serial.print("SensorID was: 0x"); Serial.println(bme.sensorID(),16);
      Serial.print("        ID of 0xFF probably means a bad address, a BMP 180 or BMP 085\n");
      Serial.print("   ID of 0x56-0x58 represents a BMP 280,\n");
      Serial.print("        ID of 0x60 represents a BME 280.\n");
      Serial.print("        ID of 0x61 represents a BME 680.\n");
      while (1) delay(10);
  }
 
  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { //SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V; 0x3C = Address for 128x32 OLED
    Serial.println(F("SSD1306 allocation failed"));
    for (;;);
  }

  
  display_val = bme.readTemperature();  //test
  Serial.println("Temperature");        //test
  Serial.println(display_val);          //test
  
  
  display.clearDisplay();               //Clear OLED buffer
  display.setTextSize(3);               // Normal 1:1 pixel scale
  display.setTextColor(SSD1306_WHITE);  // Draw white text
  display.cp437(true);  
  display.setCursor(0,0);               //test
  display.print("HELLO");               //test
}

void loop() {

}

oled_bme280_forum.ino (1.98 KB)

serial_out.PNG

Forgot to include attachment of my setup. Here it is.
Orange = SCL
Yellow = SDA
Red = VCC
Blue = Ground.

More members will see your code if you post the code as directed by the forum guidelines.

OP images:
serial_out.PNG

How to post an image.

Thanks for the advice - I've added my code inline.

To me it looks like missing Gnd connections, reason for 99% of such beginner problems.

Thanks for the reply.

I've made sure that everything is connected to a common ground. It's hard to see from the picture but there are two very small blue jumpers from each slave leading to the ground rail.

What is the value of those external pullup resistors? There may be pullups on the BME module and/or the display module. It can be a problem if the total pullup resistance is to small (overly strong pullup).

If the display shows the correct characters (even with noise), then the I2C connection is NOT the problem.

Could be a power or display setting issue.

You were right, jremington - it was software related. Turns out I wasn't calling display.display() after I filled the buffer with print(). I should've examined my code closer...Thanks.