Skip to content
E

Pressure & Altitude

Interfacing BMP280 Pressure & Altitude with ESP32

What is the BMP280?

The BMP280 is a low-power digital sensor that reads barometric pressure and temperature over I2C or SPI. Pressure readings can be converted to altitude, making it popular for weather stations and altitude-tracking drones. As the successor to the BMP180, it offers lower power consumption, faster measurement conversion, and the flexibility of either I2C or SPI wiring, while remaining one of the cheapest and most widely supported pressure sensors in the hobbyist ecosystem.

Specifications

Sensor typeBosch BMP280 barometric pressure and temperature sensor
Operating voltage1.71V–3.6V DC (breakout boards regulate from 3.3-5V input)
Operating current~2.7 µA at 1 sample/second in standard operating mode
Pressure range300 hPa to 1100 hPa
Pressure resolution0.16 Pa (relative resolution equivalent to roughly ~1cm of altitude change)
Temperature accuracy±1°C typical
InterfaceI2C (up to 3.4MHz) or SPI (up to 10MHz), selectable via wiring/solder jumper on most breakout boards
I2C address0x76 or 0x77, depending on the SDO pin state

BMP280 Pinout

PinNameDescription
1VIN / VCCPower, 3.3–5V DC depending on breakout regulator
2GNDGround
3SCL / SCKI2C clock or SPI clock, depending on interface mode
4SDA / SDII2C data or SPI data-in, depending on interface mode
5CSBChip select — ties HIGH for I2C mode on most breakouts, or used as SPI chip select when in SPI mode
6SDOSets the I2C address (0x76 when LOW, 0x77 when HIGH); doubles as SPI data-out in SPI mode

Most breakout boards default to I2C mode with CSB tied HIGH; the SDO pin's state determines which of the two possible I2C addresses (0x76 or 0x77) the sensor uses, which is handy when running two BMP280-family sensors on the same bus. As with any pressure-based altitude sensor, calibrate against a known local sea-level pressure reading for meaningful absolute altitude results.

Setting Up BMP280 with ESP32

Library

Adafruit BMP280 Library by Adafruit

Arduino IDE → Tools → Manage Libraries → search "Adafruit BMP280"

Library guide

Wiring

Component pinESP32 pinNote
VIN / VCC3.3V
GNDGND
SCL / SCKGPIO22
SDA / SDIGPIO21
CSB3.3VTie HIGH to select I2C mode
SDOGND or 3.3VSets I2C address: LOW = 0x76, HIGH = 0x77 -- match this to the address used in code

Example code

C++

ESP32 default I2C pins are 21 (SDA) / 22 (SCL) but any GPIO pair works with Wire.begin(sda, scl). Match bmp.begin()'s address argument to how SDO is wired.

Related Guides & Projects