How to Use the Adafruit BMP280 Sensor - Arduino Tutorial




About: Arduino Tutorials by Team

In this tutorial we will use the Adafruit BMP280 sensor. This sensor can measure barometric pressure and temperature with very good accuracy. Because pressure changes with altitude we can also use it as an altimeter with ±1 meter accuracy! Accuracy for barometric pressure is ±1 hPa and ±1.0°C for temperature.

You can connect it with your Arduino board with I2C or SPI connection protocol. It has a 3.3V regulator and level shifting so you can use it with a 3V or 5V logic micro controller without any problems.

In this tutorial we will use the Arduino UNO board with this sensor and the serial monitor of Codebender to print measured values every 5 sec.

So, let's get started!

Step 1: What You Will Need

For this tutorial you will need:

  • Arduino uno
  • Breadboard (or breadboard shield)
  • Adafruit BMP280
  • Some breadboard cables

Step 2: The Circuit

The connections are pretty easy, see the above image with the breadboard circuit schematic.

We will use the I2C connection (SCL and SDA pins)

Connections of the Adafruit BMP280 sensor:

  • Vin to Arduino 5V pin
  • 3Vo
  • GND to GDN
  • SCK to Arduino SCL pin (A5)
  • SDO
  • SDI to Arduino SDA pin (A4)
  • CS

Step 3: The Code

Here's the code, embedded using Codebender!
Try downloading the Codebender plugin and clicking on the "Run on Arduino" button to program your Arduino board with this sketch. And that's it, you've programmed your Arduino uno board with this sketch!

Step 4: Measured Values

Press the "connect" button to the serial monitor of Codebender below:

Step 5: Well Done!

You have successfully completed one more "How to" tutorial and you learned how to use the Adafruit BMP280 sensor with the Arduino uno board.

I hope you liked this, let me know in the comments. There will be more of them, so make sure to click Follow button!



    • Frozen Treats Challenge

      Frozen Treats Challenge
    • Beauty Tips Contest

      Beauty Tips Contest
    • Pets Challenge

      Pets Challenge

    10 Discussions


    6 months ago

    I'm getting an error during compilation: (library file) Adafruit_Sensor/Adafruit_Sensor.cpp:4:23: error: out-of-line definition of 'constructor' does not match any declaration in 'Adafruit_Sensor'
    void Adafruit_Sensor::constructor() {
    1 error generated.
    Any ideas?


    9 months ago on Step 4

    I get this:

    Pressure: 0.00 PaTemp: 0.00 oCAltimeter: -21206 m

    whats wrong?

    2 replies

    Reply 9 months ago

    Firstly, scan BMP280 for its address using I2C scanner code

    Then with the address obtained, go to Adafruit_BMP280.h library in Arduino directory and edit the #define BMP_280ADDRESS (0x75) line with your device address obtained by scanning, it will give you the required result.

    Hope it helps.


    Reply 9 months ago

    I am using bosch bmp280 and it needs conversion of the logic levels... thats why all the zeros I guess


    10 months ago on Step 4

    After 3 days it is working! Thank You


    1 year ago

    hijos de puta mamrraxos comerme los huevecillos


    3 years ago

    I need to use 6 to 8 BMP280's Using I2C and common wiring to 5V, GND, SCK & SDI. There is no chip selection in any of the tutorials that I could find that shows how to enable/disable communications in I2C mode.

    Looking at the BMP280's documentation, there is a "Vdd io" that must have 5V applied to enable communication. But nowhere in the tutorials is CS or CSO connected in I2C mode.

    Looking the SPI documentation there is an inference that the CS can be set. Is it active in I2C?

    Can I, set CS to 5V to enable one BMP280 at a time in I2C ? Or does Adafruit's BMP280 use SC to disable?

    2 replies

    Reply 2 years ago

    From datasheet.. hope this help..

    "Interface selection is done automatically based on CSB (chip select) status. If CSB is connected to VDDIO, the I²C interface is active. If CSB is pulled down, the SPI interface is activated.

    The I²C 7-bit device address is 111011x. The 6 MSB bits are fixed. The last bit is changeable by SDO value and can be changed during operation. Connecting SDO to GND results in slave address 1110110 (0x76); connection it to VDDIO results in slave address 1110111 (0x77), which is the same as BMP180’s I²C address. The SDO pin cannot be left floating; if left floating, the I²C address will be undefined."


    Reply 2 years ago

    After purchasing a Chinese BMP280 4 pin sensor, I had trouble with getting any response at all; all 0000's. I changed the Adafruit_BMP280.h from the standard library to the *.h file that has the


    #define BMP280_ADDRESS (0x76)
    #define BMP280_CHIPID (0x58)


    and all works perfectly now.


    3 years ago


    Is the answer there in the methods available to instantiate the Adafruit_BMP280 object? The three options are shown in this Instructable without explanation. the simplest/default as

    Adafruit_BMP280 bmp; // I2C

    /*//For SPI connection!

    #define BMP_SCK 13

    #define BMP_MISO 12

    #define BMP_MOSI 11

    #define BMP_CS 10

    The second is "Adafruit_BMP280 bme(BMP_CS);" where BMP_CS is the user's pin number choice.

    The third is "Adafruit_BMP280 bme(BMP_CS, BMP_MOSI, BMP_MISO, BMP_SCK);" where all four pins are user values. I don't know if these are optional arguments with defaults or not. The obvious application for this method is to allow Mega1280 or Mega2560 as well as UNO

    Not being familiar with this chip/module, I presume the first option is I2C if SDA/SCL connected but have no idea how the library figures out to use the default SPI. Also not expert with I2C vs SPI but it may not be possible to use I2C for 6-8 devices.

    Your 6-8 modules will certainly tax a UNO assuming TX.RX(2) SCK.MISO.MOSI(3) if your using Arduino pins directly. The analog pins can be used as pin #14-19 but not 18,19 when using SDA/SCL.

    Lots of little tripping hazards.

    Good Luck