Source: https://mokxi.com/libraries/adafruit-bmp280
Updated: 2026-11-02

Libraries / Sensors
Arduino library · Sensors

# Adafruit BMP280: pressure and altitude on I2C

The BMP280 is Bosch’s barometric pressure and temperature sensor, the cheaper sibling of the BME280 without the humidity part. The Adafruit BMP280 library reads it over I2C and turns the chip’s compensated values into floats: degrees Celsius, pascals, and an altitude worked out from the pressure.

Open the example in the editor See the calls

Built in on Mokxi: #include <Adafruit_BMP280.h> and it builds, with nothing to install. Free, and no account needed.

## What Adafruit BMP280 Library does

The address catches almost everyone. The library looks at 0x77 unless told otherwise, which is where Adafruit’s own board sits, while most blue and purple GY-BMP280 modules answer at 0x76. Pass the address to begin() and that problem goes away.

Altitude from a barometer is only as good as the sea-level pressure you compare against. readAltitude(1013.25) uses the standard atmosphere, which can be tens of meters off on a given day; use your local weather report’s sea-level pressure in hectopascals for a better answer, or track changes in altitude rather than the absolute number.

Library Manager name | Adafruit BMP280 Library

Author | Adafruit

Include | #include <Adafruit_BMP280.h>

Boards | every board Mokxi compiles for but ATtiny85

In the simulator | Simulated: it runs against the part the way it does on the bench.

Parts it drives | Pressure and temperature, BMP280

## Install it

It builds on every board Mokxi compiles for but ATtiny85.

In Mokxi it is built in: #include <Adafruit_BMP280.h> and the sketch compiles, with no download, no zip and no Library Manager.

On a real board, install "Adafruit BMP280 Library" by Adafruit from the Arduino IDE’s Library Manager (Sketch, Include Library, Manage Libraries), or add Adafruit BMP280 Library to lib_deps in PlatformIO. Mokxi follows the calls of release 2.6.8, so a sketch written here builds there too.

What to know in the simulator: The SPI constructors build, and begin() says on Serial that the SPI module is not simulated: Mokxi’s BMP280 is the I2C module.

ESP32-C3 · Arduino Uno · Arduino Nano · Arduino Mega 2560 · Arduino Leonardo · SparkFun Pro Micro · Arduino Micro · ESP32-C6 · Raspberry Pi Pico · Raspberry Pi Pico W · Seeed XIAO SAMD21 · STM32 · STM32 Nucleo-F411RE · STM32 Blue Pill · micro:bit V2 · Arduino Uno R4 · ESP32 DevKit · ESP32-S3-DevKitC-1 · ESP8266 NodeMCU · Arduino Pro Mini 3.3 V · Seeed XIAO ESP32-C3 · ESP32-C3 SuperMini · Seeed XIAO ESP32-C6 · ESP32-DevKitC V4 · LOLIN32 Lite · Wemos D1 R32 · Cheap Yellow Display · TTGO T-Display · Seeed XIAO ESP32-S3 · Arduino Nano ESP32 · Arduino Nano RP2040 Connect · Seeed XIAO RP2040 · Waveshare RP2040-Zero · Arduino Uno R4 WiFi

## The calls you will use

In the order a sketch meets them.

### Adafruit_BMP280 bmp

Creates the sensor on the Wire bus.

### bmp.begin(0x76)

Starts the sensor at the given address and checks the chip ID. Returns false when nothing suitable answers. Without an argument it tries 0x77.

### bmp.readTemperature()

Temperature in degrees Celsius.

### bmp.readPressure()

Pressure in pascals. Divide by 100 for hectopascals (millibars).

### bmp.readAltitude(1013.25)

Altitude in meters, against the sea-level pressure you pass in hectopascals.

### bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, Adafruit_BMP280::SAMPLING_X2, Adafruit_BMP280::SAMPLING_X16, Adafruit_BMP280::FILTER_X16, Adafruit_BMP280::STANDBY_MS_500)

Sets the mode, the temperature and pressure oversampling, the IIR filter and the standby time, as the library’s example does.

### bmp.sensorID()

The chip ID the board reported: 0x58 for a BMP280, 0x60 for a BME280.

## Example: Rocket flight computer

On the Arduino Uno R3. It runs in the browser exactly as printed.

sketch.ino · Arduino Uno R3

The sketch is cut short here; the editor has every line of it.

Open it in the editor, wired and ready to run · Rocket flight computer: the project page

## Common errors and how to fix them

### Could not find a valid BMP280 sensor, check wiring!

Try begin(0x76): most modules are not at the library’s default 0x77. If the address is right, check SDA and SCL, and print sensorID(), since a board sold as BMP280 may carry a BME280 or another chip.

### Altitude is off by tens of meters

readAltitude() needs today’s sea-level pressure. Replace 1013.25 with the value from a local weather report, in hectopascals, or measure the change from where you started.

### Pressure reads about 100000 and you expected about 1000

readPressure() is in pascals. Divide by 100 to get hectopascals or millibars, the unit weather reports use.

## Keep going

### Learn

- Arduino BMP180: Pressure, Altitude and Code
- Arduino BME680: Air Quality, Gas and Weather

### Parts

- Pressure and temperature, BMP280

### More sensors libraries

- DHT sensor library
- DHT20
- VL53L0X
- Adafruit_VL53L0X
- HX711 Arduino Library
- MPU6050
- Adafruit MPU6050
- BME280

Every built-in library · Open the editor

## Try Adafruit BMP280 Library without installing anything

Open the example, change the sketch, and keep your version in a free account.

Start building free

Open the editor
