BME280 With ESP32-C3

I’m trying to use a BME280 sensor with the Sparkfun BME280 library. I don’t seem to be able to change the SDA/SCL pins and I’m also getting a read error when I connect to the pins that the ESP32-C3 is sending I2C over.

#include <Wire.h>

#include "SparkFunBME280.h"
BME280 mySensor;

void setup()
{
  Serial.begin(115200);
  Serial.println("Example showing alternate I2C addresses");

  Wire.begin();
  Wire.setClock(10000); //Increase to fast I2C speed!

  mySensor.setI2CAddress(0x77);
  mySensor.beginI2C();

  mySensor.setReferencePressure(101200); //Adjust the sea level pressure used for altitude calculations
}

void loop()
{
  Serial.print("Humidity: ");
  Serial.print(mySensor.readFloatHumidity(), 0);

  Serial.print(" Pressure: ");
  Serial.print(mySensor.readFloatPressure(), 0);

  Serial.print(" Locally Adjusted Altitude: ");
  //Serial.print(mySensor.readFloatAltitudeMeters(), 1);
  Serial.print(mySensor.readFloatAltitudeFeet(), 1);

  Serial.print(" Temp: ");
  //Serial.print(mySensor.readTempC(), 2);
  Serial.print(mySensor.readTempF(), 2);

  Serial.println();

  delay(1000);
}

The serial monitor reads:

Humidity: [271381][E][Wire.cpp:513] requestFrom(): i2cRead returned Error -1
0 Pressure: [271388][E][Wire.cpp:513] requestFrom(): i2cRead returned Error -1
0 Locally Adjusted Altitude: [271395][E][Wire.cpp:513] requestFrom(): i2cRead returned Error -1
145442.2 Temp: [271403][E][Wire.cpp:513] requestFrom(): i2cRead returned Error -1
32.00

Thank you

You should be able to call Wire.begin(SDA, SCL, FREQ); before calling the begin() function since version 2.0.9 of the library.

The latest available version of the library is 2.0.10 by using the github link directly:

lib_deps = 
  https://github.com/sparkfun/SparkFun_BME280_Arduino_Library @ ^2.0.10

Did you try Example1_BasicReadings?