* Is an invalid option for [0] error with 8266 and BME280

I’m trying to set up a sensor for my filament cabinet with an esp8266 and a bme280. I have this written to display the temp and humidity on the built in display of the esp device, and that works, yet I cannot get the sensor communicating along with the display. Here is what I am using

# Captive Portal configuration
captive_portal:

# I2C configuration
i2c:
  display_sda: GPIO12  # SDA pin connected to GPIO12 for the SSD1306 display
  display_scl: GPIO14  # SCL pin connected to GPIO14 for the SSD1306 display
  sensor_sda: GPIO4    # SDA pin connected to GPIO4 for the BME280 sensor
  sensor_scl: GPIO5    # SCL pin connected to GPIO5 for the BME280 sensor
  scan: false

# Sensor configuration
sensor:
  - platform: bme280_i2c
    temperature:
      name: "Filament Cabinet Temperature"
      id: bme_temperature
    humidity:
      name: "Filament Cabinet Humidity"
      id: bme_humidity
    pressure:
      name: "Filament Cabinet Pressure"
      id: bme_pressure
    address: 0x77  # Address of the BME280 sensor
    update_interval: 60s

  # Define a template sensor to convert Celsius to Fahrenheit
  - platform: template
    name: "Filament Cabinet Temperature (F)"
    id: bme_temperature_fahrenheit
    unit_of_measurement: '°F'
    accuracy_decimals: 1
    update_interval: 20s
    lambda: |-
      return id(bme_temperature).state * 9.0 / 5.0 + 32.0;

# Font configuration
font:
  - file: 'slkscr.ttf'
    id: font1
    size: 8

  - file: 'BebasNeue-Regular.ttf'
    id: font2
    size: 40

  - file: 'arial.ttf'
    id: font3
    size: 20

# Display configuration
display:
  - platform: ssd1306_i2c
    model: "SSD1306 128x64"
    reset_pin: GPIO16
    address: 0x3C  # Address of the SSD1306 display
    lambda: |-
      // Print temperature label
      it.printf(0, 0, id(font1), TextAlign::TOP_LEFT, "Temp");

      // Print temperature value directly
      it.printf(0, 23, id(font3), TextAlign::TOP_LEFT, "%.1f°F", id(bme_temperature_fahrenheit).state);

      // Print humidity label
      it.printf(64, 0, id(font1), TextAlign::TOP_LEFT, "Humidity");

      // Print humidity value directly
      it.printf(64, 23, id(font3), TextAlign::TOP_LEFT, "%.1f%%", id(bme_humidity).state);

And the problem is ?
Can You please post compilation error(s) etc.

Thank you, it compiles fine, I believe the issue is that I’m not properly specifying the i2c pins for the bme AND the display. I can get one or the other working, but not both of them together.

[11:34:45][C][i2c.arduino:071]: I2C Bus:
[11:34:45][C][i2c.arduino:072]:   SDA Pin: GPIO4
[11:34:45][C][i2c.arduino:073]:   SCL Pin: GPIO5
[11:34:45][C][i2c.arduino:074]:   Frequency: 50000 Hz
[11:34:45][C][i2c.arduino:086]:   Recovery: bus successfully recovered
[11:34:45][C][bme280_i2c.sensor:025]:   Address: 0x76
[11:34:45][C][bme280.sensor:182]: BME280:
[11:34:45][C][bme280.sensor:194]:   IIR Filter: OFF
[11:34:45][C][bme280.sensor:195]:   Update Interval: 60.0s
[11:34:45][C][bme280.sensor:197]:   Temperature 'Filament Cabinet Temperature'
[11:34:45][C][bme280.sensor:197]:     Device Class: 'temperature'
[11:34:45][C][bme280.sensor:197]:     State Class: 'measurement'
[11:34:45][C][bme280.sensor:197]:     Unit of Measurement: '°C'
[11:34:45][C][bme280.sensor:197]:     Accuracy Decimals: 1
[11:34:45][C][bme280.sensor:198]:     Oversampling: 16x
[11:34:45][C][bme280.sensor:199]:   Pressure 'Filament Cabinet Pressure'
[11:34:45][C][bme280.sensor:199]:     Device Class: 'pressure'
[11:34:45][C][bme280.sensor:199]:     State Class: 'measurement'
[11:34:45][C][bme280.sensor:199]:     Unit of Measurement: 'hPa'
[11:34:45][C][bme280.sensor:199]:     Accuracy Decimals: 1
[11:34:45][C][bme280.sensor:200]:     Oversampling: 16x
[11:34:45][C][bme280.sensor:201]:   Humidity 'Filament Cabinet Humidity'
[11:34:45][C][bme280.sensor:201]:     Device Class: 'humidity'
[11:34:45][C][bme280.sensor:201]:     State Class: 'measurement'
[11:34:45][C][bme280.sensor:201]:     Unit of Measurement: '%'
[11:34:45][C][bme280.sensor:201]:     Accuracy Decimals: 1
[11:34:45][C][bme280.sensor:202]:     Oversampling: 16x
[11:34:45][C][ssd1306_i2c:023]: I2C SSD1306
[11:34:45][C][ssd1306_i2c:023]:   Rotations: 0 °
[11:34:45][C][ssd1306_i2c:023]:   Dimensions: 128px x 64px
[11:34:45][C][ssd1306_i2c:024]:   Address: 0x3C
[11:34:45][C][ssd1306_i2c:025]:   Model: SSD1306 128x64
[11:34:45][C][ssd1306_i2c:026]:   Reset Pin: GPIO16
[11:34:45][C][ssd1306_i2c:027]:   External VCC: NO
[11:34:45][C][ssd1306_i2c:028]:   Flip X: YES
[11:34:45][C][ssd1306_i2c:029]:   Flip Y: YES
[11:34:45][C][ssd1306_i2c:030]:   Offset X: 0
[11:34:45][C][ssd1306_i2c:031]:   Offset Y: 0
[11:34:45][C][ssd1306_i2c:032]:   Inverted Color: NO
[11:34:45][C][ssd1306_i2c:033]:   Update Interval: 1.0s
[11:34:45][E][ssd1306_i2c:036]: Communication with SSD1306 failed!
[11:34:45][E][component:082]:   Component display is marked FAILED

I think your problem is that the 8266 only supports one I2C bus.

You can, however, attach more than 1 device to the same bus.

3 Likes

You could use an ESP32 that allows more than one bus for I2c.

1 Like

That was the ticket, one bus, using the addresses for communication. I connected the sensor to the OLED pins on the board and all is working well now.

Thank you.

# I2C configuration for the BME280 sensor
i2c:
  sda: GPIO12
  scl: GPIO14
  scan: false

# Sensor configuration
sensor:
  - platform: bme280_i2c
    temperature:
      name: "Filament Cabinet Temperature"
      id: bme_temperature
    humidity:
      name: "Filament Cabinet Humidity"
      id: bme_humidity
    pressure:
      name: "Filament Cabinet Pressure"
      id: bme_pressure
    address: 0x76  # Address of the BME280 sensor
    update_interval: 60s

# Font configuration
font:
  - file: 'slkscr.ttf'
    id: font1
    size: 8

  - file: 'BebasNeue-Regular.ttf'
    id: font2
    size: 40

  - file: 'arial.ttf'
    id: font3
    size: 20

# Display configuration
display:
  - platform: ssd1306_i2c
    id: screen
    model: SSD1306_128X64
    address: 0x3C
    lambda: |-
      // Print temperature label
      it.printf(0, 0, id(font1), TextAlign::TOP_LEFT, "Temp");

      // Print temperature value directly
      it.printf(0, 23, id(font3), TextAlign::TOP_LEFT, "%.1f°C", id(bme_temperature).state);

      // Print humidity label
      it.printf(64, 0, id(font1), TextAlign::TOP_LEFT, "Humidity");

      // Print humidity value directly
      it.printf(64, 23, id(font3), TextAlign::TOP_LEFT, "%.1f%%", id(bme_humidity).state);
    auto_clear_enabled: True
    brightness: 1.0
    contrast: 1.0
    flip_x: True
    flip_y: True
    offset_x: 0
    offset_y: 0
    invert: False
    update_interval: 1s
1 Like