Troubles with dual i2c bus

I’m having troubles using wemos d1 mini with OLED Shield and BME280.

My yaml:
#i2c bus definitions
i2c:

  • id: bus_a
    sda: D1
    scl: D2
    scan: True
  • id: bus_b
    sda: D3
    scl: D4
    scan: True

Example configuration entry

sensor:

  • platform: bme280
    i2c_id: bus_b
    temperature:
    id: temp
    name: “BME280 Temperature”
    oversampling: 16x
    pressure:
    id: pres
    name: “BME280 Pressure”
    humidity:
    id: hum
    name: “BME280 Humidity”
    address: 0x76
    update_interval: 60s

Example configuration entry

display:

  • platform: ssd1306_i2c
    i2c_id: bus_a
    model: “SSD1306 64x48”
    address: 0x3C
    lambda: |-
    it.printf(0, 5, id(font1), “Temp : %.1fc”, id(temp).state);
    it.printf(0, 20, id(font1), "Humi : %.1f ", id(hum).state);
    it.printf(0, 35, id(font1), "Pres : %.1f ", id(pres).state);

The trouble I’m having is that it would seem it only detects the last i2c bus. If I use the config up here, Then the bme280 works but not the screen. If I do this:

i2c:

  • id: bus_b
    sda: D3
    scl: D4
    scan: True
  • id: bus_a
    sda: D1
    scl: D2
    scan: True

Then the screen will work but not the BME280…

Is there a particular reason you want to set up two I2C buses instead of connecting both devices to one bus?

Other than that, I can recommend the following tutorial about pin usage. It doesn’t explicitly say that D3 and D4 wouldn’t work though.

Well I have no experience with esp8266 and i2c, I just wanted to connect the bme280 with an oled and it to home assistant. How can I connect both devices to the same bus? I connect both to the same pins ? D1 and D2 ?
I will read your link and try to guess what I’m doing incorrectly. Thanks

Yes… they just connect to same pins in parallel. They have different addresses so they will work. I don’t think the esp8266 supports 2 i2c bus’

2 Likes

I connected the oled as well as the bme280 on pins D1 and D2 and adjusted config to set a single bus. Everything worked on first try.

Thanks everyone!

3 Likes