Multiple BMP280 sensors with Uno via SPI

I need to connect three BMP280 (atmospheric pressure sensor) devices with one Arduino Uno (with 16x2 LCD).

I connected the Uno to the LCD via IIC (by module LCM1602), at pins A4 and A5; it's OK.

I connected the three BMP280 to Arduino via SPI, as shown in the pinout table below:

Arduino pin. . . . . .BMP280 (1). . BMP280 (2). . BMP280 (3)
D13 (SCLK). . . . . .SCL. . . . . . . . . . .SCL. . . . . . . . . .SCL
D12 (MISO). . . . . .SDO. . . . . . . . . .SDO. . . . . . . . . .SDO
D11 (MOSI). . . . . .SDA. . . . . . . . . . .SDA. . . . . . . . . .SDA
D10 (ss1). . . . . . . .CSB
D9 (ss2). . . . . . . . . . . . . . . . . . . . . . .CSB
D8 (ss3). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .CSB

This seems congruent with SPI communication theory.

Now the difficulty is finding the library that allows multiple SPI-connected devices to:

  1. Uno receives data from BMP280(1) and displays on LCD;
  2. Uno receives data from BMP280(2) and displays on LCD;
  3. Uno receives data from BMP280(3) and displays on LCD;

The three BMP280 libraries found are poorly documented and do not demonstrate multiple device capabilities:

  • Adafruit_BMP280_Library
  • BMP280_DEV
  • BMP280_Grove

I tried toggle:

  • digitalWrite (ss1, LOW) and digitalWrite (ss1, HIGH)
  • digitalWrite (ss2, LOW) and digitalWrite (ss2, HIGH)
  • digitalWrite (ss3, LOW) and digitalWrite (ss3, HIGH)
    and create different instances for BMP(1), BMP(2) and BMP(3) but it didn't work.

There are plenty of WEB demonstrations of how to connect a BMP280 sensor to Uno (or ESP) but I didn't find one that connected two or more BMP280 via SPI or IIC (I2C). In the forums, a lot of speculation but nothing concrete.

Any suggestion?

see if Connect Multiple BME280 Sensors on SPI - BlueDot Sensors is helpful

I will try. Thank you very much

Remember to add level shifters such as the 74hct125 and power the things off the 3.3V output of your Arduino. Otherwise you're going to destroy those sensors very very quickly.

Or use I2C, enabling the SCL line as needed. Needs diode and resistor for each SCL:


Set the enable high to communicate with a specific sensor, low to disable that one. You will have to shift down your level, so use the top schematic.

Hi asasergio,

The three BMP280 libraries found are poorly documented and do not demonstrate multiple device capabilities:

  • Adafruit_BMP280_Library
  • BMP280_DEV
  • BMP280_Grove

Ouch! :wink: As the author of the BMP280_DEV library, I admit that there's no example code with multiple devices, but I have to take issue with your assertion that it's poorly documented.

In my opinion, the BMP280_DEV documentation provides step-by-step instructions on how to use the barometer, together with a variety of examples for operating the BMP280 in both NORMAL and FORCED modes with I2C and SPI: https://github.com/MartinL1/BMP280_DEV.

The following code shows how to use the BMP280_DEV library with multiple BMP280 devices over a SPI interface:

///////////////////////////////////////////////////////////////////////////////
// BMP280_DEV - SPI Communications, Default Configuration, Normal Conversion
///////////////////////////////////////////////////////////////////////////////

#include <BMP280_DEV.h>                             // Include the BMP280_DEV.h library

float temperature, pressure, altitude;              // Create the temperature, pressure and altitude variables
BMP280_DEV bmp280_1(10);                            // Instantiate (create) a BMP280_DEV object and set-up for SPI operation on digital pin D10
BMP280_DEV bmp280_2(9);                             // Instantiate (create) a BMP280_DEV object and set-up for SPI operation on digital pin D9

void setup() 
{
  Serial.begin(115200);                             // Initialise the serial port
  bmp280_1.begin();                                 // Default initialisation, place the BMP280_1 into SLEEP_MODE 
  bmp280_1.setTimeStandby(TIME_STANDBY_2000MS);     // Set the standby time to 2 seconds
  bmp280_1.startNormalConversion();                 // Start BMP280_1 continuous conversion in NORMAL_MODE 
  bmp280_2.begin();                                 // Default initialisation, place the BMP280_2 into SLEEP_MODE 
  bmp280_2.setTimeStandby(TIME_STANDBY_2000MS);     // Set the standby time to 2 seconds
  bmp280_2.startNormalConversion();                 // Start BMP280_2 continuous conversion in NORMAL_MODE  
}

void loop() 
{
  if (bmp280_1.getMeasurements(temperature, pressure, altitude))    // Check if the measurement is complete
  {
    Serial.print(F("BMP280_1 "));
    Serial.print(temperature);                      // Display the results    
    Serial.print(F("*C   "));
    Serial.print(pressure);    
    Serial.print(F("hPa   "));
    Serial.print(altitude);
    Serial.println(F("m"));  
  }
  if (bmp280_2.getMeasurements(temperature, pressure, altitude))    // Check if the measurement is complete
  {
    Serial.print(F("BMP280_2 "));
    Serial.print(temperature);                      // Display the results    
    Serial.print(F("*C   "));
    Serial.print(pressure);    
    Serial.print(F("hPa   "));
    Serial.print(altitude);
    Serial.println(F("m"));  
  }
}
1 Like

Thank you very much.

https://www.instructables.com/id/Multiples-BMP280-Sensors-in-Arduino-Uno-Via-SPI/ is helpfull too.

1 Like