Free shipping for orders above 60 €

How to Connect two BME280 Sensors on the I²C bus

Did you know that the BME280 sensor has two different I²C addresses? That means you can read two BME280 sensors simultaneously on the I²C bus. As a consequence, one sensor will use the default address (0x77) and the other will use the alternative address (0x76).

First, let’s connect the sensors like this:

  • VCC pin from both sensors to either 3.3V or 5V. If you are using an Arduino Uno, use the 5V pin.
  • GND pin from both sensors to the GND pin on your Arduino.
  • SCK pin from both sensors to the I²C clock SCL pin on your Arduino. On the Arduino Uno that would be the pin A5.
  • SDI pin from both sensors to the I²C data SDA pin on your Arduino. On the Arduino Uno that would be the pin A4.
  • Leave the CS pin from both sensors unconnected.
  • Leave the SDO pin from only one sensor unconnected.
  • Connect the SDO pin from the other sensor to the GND.

When you leave the SDO pin from one sensor unconnected, you are telling this sensor to use the default I²C address (0x77). But when you connect the SDO pin from the second sensor to GND, you tell it to use the alternative I²C address (0x76).

Now we need the software

If you have not done this yet, download and install the BlueDot BME280 library through the Arduino IDE. This is important because the BlueDot library does work with two BME280 sensors on the I²C bus.

Not every library for the BME280 available on the internet works with two sensors on the I²C bus. Just to be safe, download and install the BlueDot BME280 libraryJust go to Sketch -> Include Library -> Manage Libraries… and search for the BlueDot BME280 Library. Now click on it and install the library. You can also visit the GitHub repository to download the latest version of the library or just click on this button below.

Uploading and setting up the example sketch

After installing the library, run the example for multiple sensors on the I²C bus. Open up File -> Examples -> BlueDot_BME280_library -> BME280_MultipleSensorsI2C.

After uploading the code into your Arduino,  open up the Serial Monitor at 9600 baud speed to get the temperature, humidity, pressure, and altitude from both sensors at the same time.

The functions for each sensor are slightly different. At the beginning of the program, you declare two objects bme1 and bme2, one for each sensor. We need those to keep the calibration parameters for each sensor separated from each other.

    BlueDot_BME280 bme1;                                     //Object for Sensor 1
    BlueDot_BME280 bme2;                                     //Object for Sensor 2

Now, the functions starting with bme1 refer to the first sensor, while the functions starting with bme2 refer to the second sensor.

    Serial.println(bme1.readTempC());
    Serial.println(bme1.readTempF());
    Serial.println(bme1.readHumidity());
    Serial.println(bme1.readPressure());
    Serial.println(bme1.readAltitudeMeter());
    Serial.println(bme1.readAltitudeFeet());
   
    Serial.println(bme2.readTempC());
    Serial.println(bme2.readTempF());
    Serial.println(bme2.readHumidity());
    Serial.println(bme2.readPressure());
    Serial.println(bme2.readAltitudeMeter());
    Serial.println(bme2.readAltitudeFeet());
 

Leave a Reply

Your email address will not be published. Required fields are marked *