Unable to find BME680

Hello!

I've read https://forum.arduino.cc/t/not-working-with-qwiic-devices/1143109.

I have a Sparkfun BME680 sensor with a Qwiic interface. Furthermore, I understand the need to use:
Wire1.begin();
but I cannot find a suitable header file to use:
libraryName(Wire1);

I'm using the SV-Zanshin library with the I2C example. I've inserted the Wire1.begin() statement before the Serial.begin() statement in setup().

The examples in the Zanshin library have an I2Cdemo.ino sketch where I inserted the Wire1.begin() statement. However, the BME680.begin() statement in the sketch fails with:
Unable to find BME680. Trying again in 5 seconds.

What is the correct library to use for the Sparkfun BME680? (Sparkfun example is for the AT20). Thanks.

Regards.

P.S.
Since there is only one way to plug in the Qwiic boards, my basic assumption is that I have wired the Sparkfun BME680 board correctly as shown in https://docs.arduino.cc/tutorials/uno-r4-wifi/qwiic/ without the daisy chain for my tests.

Knowing what libraries to use is a bit of a dark art. Here are two that I considered and chose the Bosch (maker of the sensor)

1 Like

I searched that and "BME680" and found this.

It's not enough just to call Wire1.begin() in setup. This library was written assuming that Wire would be the only I2C instance. If you look at the library you find a bunch of this kind of thing:

    if (_I2CAddress)                                      // Using I2C if address is non-zero
    {                                                     //
      Wire.beginTransmission(_I2CAddress);                // Address the I2C device
      Wire.write(addr);                                   // Send register address to write
      for (uint8_t i = 0; i < sizeof(T); i++)
        Wire.write(*bytePtr++);  // loop for each byte to be written
      Wire.endTransmission();    // Close transmission
    } 

A nicer library might allow you to pass in which instance you want to use. This one just uses Wire directly everywhere.

The quick fix would be to save another version of this library and go change those all to Wire1.

1 Like

Hello @Delta_G,

It's not enough just to call Wire1.begin() in setup. This library was written assuming that Wire would be the only I2C instance.

That became immediately apparent when I added a second (Shenzhen) BME680. The SV-Zanshin demo worked without any extra line of code (other than ensuring the second instantiated entity was named differently).

I will work on your suggestion. Thanks.

Regards.

Hello @sonofcy,

A few years ago, I found that the Bosch Sensortec library, admirable naturally, was above my job grade. I will revisit it now that, thanks to your suggestion.

My understanding of I2C is limited in the sense that I cannot think beyond the address assignment other than the fact that there are two I2C implementations on the UNO R4 for understandable reasons.

Regards.

Yes, with 2 I2C buses, you can use 2 devices with hard coded addresses. Of course as long as the addresses are different, one I2C can support many devices in parallel.

1 Like