Multiple BME80 on arduino

Hello, I working on a project back in the beginning of 2024 a multiple temperature logger using the bme680 on i2c. I had to put it on hold and forgot all about it. I just went recently went through some of my files and saw it. The problem I'm having back then is the second sensor. I couldn't figure out how to get it running because of the library. I found the adafruit library for the bme680 here https://github.com/adafruit/Adafruit_BME680 It works but I there is no example on how I can display the second sensor. Or how to address it. Then I found out I need to attach the SD0 to ground to get the second address.

Once I did that I used an i2c scanner and saw both sensors. It still brings me back to how to get the second sensor working. I searched online for a long time. I couldn't find an example or figure it out how to get it woeking back than.

I'm here once again asking for help on how I can get it to work. Please help me?

Joseph

I haven't looked at the library in detail. But, I'd suggest instantiating a second Adafruit_BME680 object and provide it's I2C address in the begin() function. See Adafruit_BME680.h:

  bool begin(uint8_t addr = BME68X_DEFAULT_ADDRESS, bool initSettings = true);

@gfvalvo I did take a look at the library and before I was able to change it manuslly in the library to test.

There's no need to change the library. Just supply the second address as an argument to the begin() function.

@gfvalvo Just a quick update. I wasn't able to get it working I went throught the datasheet and library. I guess My still lack of skills somehow I couldn't figure it out. And searching online leed me to nowhere. However I did manage to find this on github after searching over 200 sites trying to figure this out. A library that has an example with both sensors on it here https://github.com/sparkfun/SparkFun_BME280_Arduino_Library/tree/V_1.2.0 it's an older library. However it does work and I did manage to get both sensors working.

well not at first it was seeing the first one but not the sensor one. And I didn't know why. I looked at all my wiring and it looked good. I looked over the example code and that looked good. I even learned a little from it on how to grab the sensor sensor and how to set it up in the settings which I didn''t know. Now I do know. But I couldn't get it to display a second sensor. Turns out that it was my fault.

I have both sensors set to 0x76 instead of one being 0x76 and second one being 0x77. I put botgh SD0 to ground at the same time. Now I corrected that and I can now see both sensors with no problem.

Thank you @gfvalvo for all the help and information. And also to the community for the great work in here.

Joseph

If you're interested, you can post your attempt at making it work. Forum members will provide assistance. We can't help you if you don't post the code.

Hello, @gfvalvo I went back to the original cde because I was having problems. I'm trying to change the address for the i2c from 0x77 to 0x76. I added in the setup bme.begin(0x76); in the beginning and in serial monitor says BME680 testCould not find a valid BME680 sensor, check wiring! Not sure why it wouldn't change here. Adding the sktch in here. Not sure what to do to change it to see the other sensor?

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_BME680.h"

#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10

#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BME680 bme; // I2C
//Adafruit_BME680 bme(BME_CS); // hardware SPI
//Adafruit_BME680 bme(BME_CS, BME_MOSI, BME_MISO,  BME_SCK);

void setup() {
  bme.begin(0x76);
  Serial.begin(9600);
  while (!Serial);
  Serial.println(F("BME680 test"));

  if (!bme.begin()) {
    Serial.println("Could not find a valid BME680 sensor, check wiring!");
    while (1);
  }

  // Set up oversampling and filter initialization
  bme.setTemperatureOversampling(BME680_OS_8X);
  bme.setHumidityOversampling(BME680_OS_2X);
  bme.setPressureOversampling(BME680_OS_4X);
  bme.setIIRFilterSize(BME680_FILTER_SIZE_3);
  bme.setGasHeater(320, 150); // 320*C for 150 ms
}

void loop() {
  if (! bme.performReading()) {
    Serial.println("Failed to perform reading :(");
    return;
  }
  Serial.print("Temperature = ");
  Serial.print(bme.temperature);
  Serial.println(" *C");

  Serial.print("Pressure = ");
  Serial.print(bme.pressure / 100.0);
  Serial.println(" hPa");

  Serial.print("Humidity = ");
  Serial.print(bme.humidity);
  Serial.println(" %");

  Serial.print("Gas = ");
  Serial.print(bme.gas_resistance / 1000.0);
  Serial.println(" KOhms");

  Serial.print("Approx. Altitude = ");
  Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
  Serial.println(" m");

  Serial.println();
  delay(2000);
}

However if i change it in the library and take out that bme.begin(0x76); in setup then It can see the sensor.

Did you get both BME680s to work together?
You can change the BME680 i2c address with the SDO pin.

@SurferTim Yes I have the SD0 to ground. If I change it in the library it can see the 0x76 but if I add the bme.begin(0x76); in the setup it doesn't see it.

If you want to use 2 on the same i2c bus, connect one device SDO to GND and the other to V+.
One will show as 0x76 and the other 0x77.

at the moment I'monly using one sensor for testing. I only have one wired up. and put the sd0 to ground. When I finish testing this then I'll wire up a second ine. But for now I can not address this one correctly in setup.

Did you use the i2c_scanner sketch to determine if the BME680 is at the i2c address you think it is?

i2c scanner says.

I2C Scanner
Scanning...
I2C device found at address 0x76 !
done

its there and working. again if I change it in the library it works with no ptoblem But if I address it in the setup with bme.begin(0x76); it doesn't see it. It wants to revert back to that 0x77 address.

The library uses 0x77 as the default.
Try this in setup.
bme.begin(addr = 0x76);

@SurferTim 'addr' was not declared in this scope.

Try this:
bme.begin(0x76,true);

@SurferTim Same thing. BME680 testCould not find a valid BME680 sensor, check wiring! but this time no error.

The example shows a different way to declare the bme instance.
Adafruit_BME680 bme(&Wire); // I2C

@SurferTim Yes this is strange. I'm notr sure how to address it like it needs to be.

You are using this in your sketch.
Adafruit_BME680 bme; // I2C
This is what the examples use.
Adafruit_BME680 bme(&Wire); // I2C