How to Hookup Multiple BME280 Pressure Sensors to Arduino

Overview

The BME280 supports either SPI or I2C interface to communicate with the micro controller. In this hookup we connect two BME280 to the Arduino using the I2C bus. The maximum is two per bus as the sensor only has two addresses (0x77 and 0x76).

Hardware and Software Parts List


Data Sheets


Hookup Diagram for Adafruit BME280 breakout board using I2C and Default Address (0x77)


We hookup the BME280 sensors to the Arduino using the same wiring as in the single hookup with the SCK (Yellow) and SDI (blue) going to both sensors.

On the second sensor we need to connect the SDO pin to ground. This will make the sensor use 0x76 as its address.

With the I2C bus we only need to connect the following:

  • Analog Pin 5 to SCK
  • Analog Pin 4 to SDI
  • SDO to Ground on second sensor
Hookup Arduino to Multiple BME280 Sensors I2C


Software

This Arduino Sketch is for connecting a two BME280 sensors and uses the same library as used for a single BME280 sensor.

You will need to download the cactus.io BME280_I2C library to work with this sample sketch. The library supports reading the barometric pressure, humidity and temperature from the sensor.

The sensor returns the temperature in degrees celsius by design. We can call the method in the BME280 library called getTemperature_C to get the celsius value or getTemperature_F for the value in fahrenheit.

The barometric pressure from the sensor is returned in Millibars. The library method getPressure_MB will return the value in millbars.

We need to create two BME280_I2C objects. One for each sensor. We will create an instance of each specifying the address to use. In the setup we need to call begin() on each sensor. This is where the calibration data for the BME280 sensor is loaded into the object instance to be used for calculating the values for pressure, humidity and temperature. These values are unique to the sensor.

(2016-01-03) You can not use the Adafruit BME280 library to connect two BME280 sensors. This is because it uses a static variable to hold the sensor calibration data. It will compile in the IDE but when run on the Arduino it will use the correct calibration data for the first sensor but the incorrect data for the second sensor.

Limitations
  • The sketch Supports only I2C bus connection.
  • The sketch Supports up to two sensors connected.
  • Its blocking code.
Bosch Multiple BME280 I2C Sample Sketch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <Wire.h>
#include "cactus_io_BME280_I2C.h"

// Create two BME280 instances
BME280_I2C bme1(0x77); // I2C using address 0x77
BME280_I2C bme2(0x76); // I2C using address 0x76

void setup() {

Serial.begin(9600);
Serial.println("Multi Bosch BME280 Pressure - Humidity - Temp Sensor | cactus.io");

if (!bme1.begin()) {
Serial.println("Could not find a First BME280 sensor, check wiring!");
while (1);
}

if (!bme2.begin()) {
Serial.println("Could not find a Second BME280 sensor, check wiring!");
while (1);
}

Serial.println("Device\tPressure\tHumdity\t\tTemp");
}

void loop() {

Serial.print("BME 1\t");
bme1.readSensor();
Serial.print(bme1.getPressure_MB()); Serial.print(" mb\t"); // Pressure in millibars
Serial.print(bme1.getHumidity()); Serial.print(" %\t\t");
Serial.print(bme1.getTemperature_C()); Serial.print(" *C\t");

delay(1000);

Serial.print("BME 2\t");
bme2.readSensor();
Serial.print(bme2.getPressure_MB()); Serial.print(" mb\t"); // Pressure in millibars
Serial.print(bme2.getHumidity()); Serial.print(" %\t\t");
Serial.print(bme2.getTemperature_C()); Serial.print(" *C\t");

// Add a 1 second delay.
delay(1000); // just here to slow down the output.
}

Sketch Console Output

Arduino tp multiple Bosch BME280 Sensors Sketch

License