Closed lnlp closed 5 years ago
calling Wire.begin() is the well established method of verifying I2C is initalized. ESP32 does a nonstandard thing, which would mean breaking every other board, including official ones. so we won't 'fix' this - it would be better to have ESP32 allow creation of Wire2 which has a different pinout and does not mess with Wire.begin() :)
BME280.begin() for I2C allways calls TwoWire.begin() without parameters, which resets the I2C interface to its default state.
This occurs even if an already initialized TwoWire object is passed to BME280.begin() as input parameter. The Wire interface is a shared object that may have been explicitly configured by the application already, different from its default state. Resetting it then causes problems. (The bus may have been configured for a different speed, or on ESP32 for using custom I2C pins. ESP32 supports 2 hardware I2C interfaces).
Please do not call Wire.begin() in BME280.begin(), at least not when a TwoWire object is passed as input parameter.