The BMP280 from Bosch measures air pressure and temperature, and because air pressure falls as you climb, it can also estimate altitude. It's sensitive enough to notice you lifting it from the floor to a table, and stable enough to show the slow pressure changes that come before a change in the weather. That makes it the standard part for weather stations, drone and rocket altimeters, and step or floor counters.
This page explains what the numbers mean, how pressure turns into altitude, which of the many BMP280 boards you have (they are not all wired the same), and the mistakes that trip beginners up. For working builds, follow the Arduino Uno guide, with a relative altimeter, or the ESP32 guide, with a weather page that shows the 3-hour pressure trend.
Run the BMP280 in your browser
Ready-wired circuit with code. No hardware, no install.
BMP280 at a glance
BMP280 at a glance. A 3.3 V I²C sensor at address 0x76 (most purple boards) or 0x77 (Adafruit). Reads pressure in pascals; divide by 100 for hPa. Relative accuracy is about ±1 m of height; absolute altitude needs today's local sea-level pressure. It does not measure humidity: that's the BME280, which looks almost identical.
Specifications
- Measures
- Barometric pressure and temperature (no humidity)
- Pressure range
- 300–1100 hPa (about +9,000 m to −500 m)
- Relative accuracy
- ±0.12 hPa, about ±1 m of height (700–900 hPa, 25 °C)
- Absolute accuracy
- About ±1 hPa (950–1050 hPa, 0–40 °C)
- Pressure resolution
- 0.16 Pa (0.0016 hPa) at the highest oversampling
- Pressure noise
- 1.3 Pa RMS unfiltered; about 0.2 Pa with the IIR filter
- Temperature
- −40 to +85 °C range; ±1 °C accuracy (0–65 °C), 0.01 °C resolution
- Supply (chip)
- VDD 1.71–3.6 V, VDDIO 1.2–3.6 V. Not 5 V tolerant
- Current
- 2.7 µA at one reading per second; 0.1 µA asleep
- Interfaces
- I²C up to 3.4 MHz (address 0x76 or 0x77) and SPI up to 10 MHz
- Chip ID
- 0x58 (BME280 is 0x60)
- Package
- 8-pin LGA, 2.0 × 2.5 × 0.95 mm
From the Bosch BMP280 datasheet. Breakout boards add pull-up resistors and sometimes a regulator; check yours.
How it measures pressure
Inside the tiny metal can is a piezo-resistive membrane: a thin silicon diaphragm with resistors built into it. Air pressure flexes the membrane, the resistors change value, and the chip's own converter measures the change. Every chip is calibrated at the factory, and the calibration constants are stored inside it; the library reads them at start-up and uses them to correct every reading. That's why there's nothing for you to calibrate for pressure itself.
The temperature sensor is there mainly so the chip can correct the pressure reading for temperature. You can read it too, but it measures the chip, not the room: anything warm nearby, including the ESP32 next to it, makes it read high.
From pressure to altitude
At sea level, air pressure averages 1013.25 hPa. It drops by roughly 1 hPa for every 8.3 m you climb near sea level, and more slowly higher up. The library uses the standard-atmosphere formula:
altitude = 44330 × (1 − (P ÷ P₀)^0.1903)
where P is the measured pressure and P₀ is the sea-level pressure right now. That second number is the catch. Weather moves sea-level pressure by 10–20 hPa over a few days, and each 1 hPa of error is about 8 m of altitude error. With the default 1013.25 hPa, a BMP280 can be tens of metres out while every reading looks perfectly steady.
There are two ways around it:
- Absolute altitude: look up today's sea-level pressure (QNH) from a nearby airport's METAR report or a weather service and put it in your sketch.
- Relative altitude: don't care about sea level; zero the sensor where you start and measure the change. This is where the BMP280 shines: its relative accuracy of ±0.12 hPa is about ±1 m.
Which BMP280 board do you have?
The chip is the same everywhere, but the boards differ in ways that matter for wiring.
Common BMP280 boards
GY-BMP280-3.3 (purple, 6 pins)
- How to recognise it
- Tiny board, pins VCC GND SCL SDA CSB SDO, no regulator
- Power
- 3.3 V only
- Default address
- 0x76
5 V-ready module
- How to recognise it
- Has a small 3-pin regulator (often marked 662K) and level-shift transistors
- Power
- 3.3–5 V
- Default address
- 0x76 or 0x77
Adafruit BMP280
- How to recognise it
- Blue board with regulator and level shifting; STEMMA QT connectors
- Power
- 3–5 V
- Default address
- 0x77
"BMP280" that is really a BME280
- How to recognise it
- Looks identical; chip marked differently; sold mislabelled
- Power
- As above
- Default address
- 0x76/0x77, chip ID 0x60
Warning
The address trap. The Adafruit library's default address is 0x77, but most cheap purple boards are 0x76. Calling bmp.begin() without an address on those boards fails with "sensor not found" even though the wiring is perfect. Always pass the address: bmp.begin(0x76). Both board guides start with a scanner sketch that finds the address and reads the chip ID for you.
Pinout (6-pin board)
| Pin | Name | Connection for I²C |
|---|---|---|
| VCC | Power | 3.3 V (or 5 V only if the board has a regulator) |
| GND | Ground | Board ground |
| SCL | I²C clock (SPI: SCK) | Uno A5, ESP32 GPIO22 |
| SDA | I²C data (SPI: SDI) | Uno A4, ESP32 GPIO21 |
| CSB | Chip select | Leave as is: the board pulls it HIGH for I²C. Pulling it LOW at power-up switches to SPI |
| SDO | Address select (SPI: data out) | GND or open = 0x76 on most boards; to 3.3 V = 0x77 |
Settings: oversampling, filter and standby
The BMP280 can average several measurements internally (oversampling), smooth out sudden changes such as a door slamming (the IIR filter), and rest between readings (standby). More of each means less noise but slower response and more power. Bosch's datasheet recommends a few combinations:
Recommended settings
Weather station
- Pressure / temp oversampling
- ×1 / ×1, one reading a minute
- IIR filter
- Off
- Why
- Weather changes slowly; lowest power
Floor or lift detection
- Pressure / temp oversampling
- ×4 / ×1
- IIR filter
- ×4
- Why
- Fast enough to see a floor change, low noise
Indoor navigation / altimeter
- Pressure / temp oversampling
- ×16 / ×2
- IIR filter
- ×16
- Why
- Lowest noise for centimetre-level changes
Drop detection
- Pressure / temp oversampling
- ×2 / ×1
- IIR filter
- Off
- Why
- Fastest response
Based on Bosch's recommended modes. The guides use the altimeter and weather settings.
BMP280 vs BME280 vs BMP180 vs BMP388
Bosch pressure sensors compared
BMP180
- Measures
- Pressure, temperature
- Relative accuracy
- ±0.12 hPa
- Notes
- Older, I²C only, fixed address 0x77, 1 Pa resolution
BMP280
- Measures
- Pressure, temperature
- Relative accuracy
- ±0.12 hPa
- Notes
- Lower noise and power than the BMP180, I²C or SPI, two addresses
- Measures
- Pressure, temperature, humidity
- Relative accuracy
- ±0.12 hPa
- Notes
- Same pinout and addresses; costs more; chip ID 0x60
BMP388 / BMP390
- Measures
- Pressure, temperature
- Relative accuracy
- ±0.08 hPa (BMP388) or ±0.03 hPa (BMP390)
- Notes
- Newer, for drones and precise altitude
Getting good readings
- Keep it away from heat. Mount the sensor a few centimetres from the microcontroller and any regulator, and out of direct sun, or the temperature (and slightly the pressure) reads high.
- Let air in, keep wind out. It needs to see outside air, but a draught or fan causes pressure jumps. A box with a small vent, plus the IIR filter, fixes both.
- Expect pressure to differ from your weather app. The sensor reads the actual pressure where it is ("station pressure"). Weather services report pressure corrected to sea level. At 920 m, those differ by about 100 hPa.
- Don't trust altitude without a reference. Without today's sea-level pressure, absolute altitude can be tens of metres off. Relative changes stay accurate.
Ready to build?
- BMP280 with Arduino Uno: safe 3.3 V wiring, an address and chip-ID scanner, temperature/pressure/altitude readings, and a relative altimeter that shows height changes in centimetres.
- BMP280 with ESP32: direct 3.3 V wiring, the same scanner, and a weather page on your phone with the 3-hour pressure trend.
Troubleshooting
"Sensor not found"
- Likely cause
- Wrong address in the sketch
- Fix
- Run an I²C scanner; use bmp.begin(0x76) or (0x77)
Found but begin() fails
- Likely cause
- It's a BME280 (chip ID 0x60)
- Fix
- Use the BME280 library, or read the chip ID to check
Pressure reads 0 or nan
- Likely cause
- Power or wiring fault
- Fix
- Check 3.3 V on VCC, and SDA/SCL
Altitude tens of metres off
- Likely cause
- Default 1013.25 hPa sea-level pressure
- Fix
- Enter today's local sea-level pressure
Pressure 100 hPa lower than the weather app
- Likely cause
- You live at altitude; the app shows sea-level pressure
- Fix
- Nothing is wrong: compare like with like
Temperature several degrees high
- Likely cause
- Heat from the board or regulator
- Fix
- Move the sensor away from warm parts
Readings jump when a door closes
- Likely cause
- Real pressure change
- Fix
- Use the IIR filter (×4 or ×16)
Frequently asked questions
Does the BMP280 measure humidity? No. The BME280 does, and the two look almost the same. Read the chip ID: 0x58 is a BMP280, 0x60 is a BME280.
Can I connect it to a 5 V Arduino directly? Only if your board has a regulator and level shifting. The purple GY-BMP280-3.3 board must run from 3.3 V, and its data lines should go through a level shifter on a 5 V board. The Uno guide explains why.
How accurate is the altitude? Height changes are good to about ±1 m (better with filtering, over short times). Absolute altitude depends on knowing today's sea-level pressure; with the default 1013.25 hPa, expect errors of tens of metres.
Can I use two BMP280s? Yes: set one to 0x76 and the other to 0x77 using SDO.
Can it measure water depth or tyre pressure? No. It's made for air between 300 and 1100 hPa and isn't waterproof. Use a sealed pressure sensor for liquids or high pressures.
Wiring & code
Board integration
Library
Adafruit BMP280 Library by Adafruit
Library Manager: Adafruit BMP280 Library
In this guide you'll connect a BMP280 pressure sensor to an ESP32 and read temperature, pressure and altitude. You'll start with a scanner that finds the sensor's I²C address and tells you whether it's really a BMP280, then read the sensor, set it up for accurate altitude, and finish with a weather page on your phone showing pressure, temperature and the 3-hour trend that hints at what the weather will do.
Allow about 30 minutes. For how the sensor works and which board you have, see the BMP280 overview.
What you need
| Part | Qty | Notes |
|---|---|---|
| ESP32 DevKit | 1 | Powered from USB |
| BMP280 module | 1 | Purple GY-BMP280 (3.3 V) or a 5 V-ready board |
| Breadboard and jumper wires | 1 + 4–8 |
Wiring
The ESP32 is a 3.3 V board, the same as the BMP280, so it connects directly with no level shifter. Use the ESP32's default I²C pins: GPIO21 (SDA) and GPIO22 (SCL).
Wiring: BMP280 to ESP32
| From | To | Note |
|---|---|---|
| BMP280 VCC | ESP32 3V3 | Never 5V on a 3.3 V-only board |
| BMP280 GND | ESP32 GND | |
| BMP280 SDA | ESP32 GPIO21 | I²C data |
| BMP280 SCL | ESP32 GPIO22 | I²C clock |
| BMP280 SDO | Leave open (or GND) | 0x76; to 3V3 for 0x77 |
| BMP280 CSB | Leave open | The board keeps it HIGH for I²C |
- 1Unplug the ESP32.
- 2Connect VCC to 3V3 and GND to GND.
- 3Connect SDA to GPIO21 and SCL to GPIO22.
- 4Leave CSB and SDO unconnected. Mount the sensor a few centimetres from the ESP32, which gets warm.
- 5Plug in USB.
Set up the IDE and library
- In Arduino IDE 2, install esp32 by Espressif Systems from the Boards Manager and select ESP32 Dev Module.
- In the Library Manager, install Adafruit BMP280 Library and accept its dependencies (Adafruit Unified Sensor and BusIO).
Step 1: find the address and identify the chip
This sketch lists every I²C device and reads the chip-ID register of anything at 0x76 or 0x77. It catches the two most common problems before you write any real code: the wrong address, and a "BMP280" that's actually a BME280.
// BMP280 - Step 1: find the I2C address and identify the chip
// Prints every I2C device and, for 0x76/0x77, what the chip really is.
#include <Wire.h>
byte chipId(byte addr) {
Wire.beginTransmission(addr);
Wire.write(0xD0); // chip-ID register
if (Wire.endTransmission() != 0) return 0;
Wire.requestFrom(addr, (byte)1);
return Wire.available() ? Wire.read() : 0;
}
void setup() {
Serial.begin(115200);
Wire.begin(21, 22); // ESP32: SDA = GPIO21, SCL = GPIO22
delay(200);
Serial.println(F("Scanning I2C..."));
for (byte a = 1; a < 127; a++) {
Wire.beginTransmission(a);
if (Wire.endTransmission() == 0) {
Serial.print(F("Found device at 0x"));
Serial.print(a, HEX);
if (a == 0x76 || a == 0x77) {
byte id = chipId(a);
Serial.print(F(" chip ID 0x"));
Serial.print(id, HEX);
if (id == 0x58) Serial.print(F(" -> BMP280 (use this guide)"));
else if (id == 0x60) Serial.print(F(" -> BME280! Use the BME280 library"));
else if (id == 0x55) Serial.print(F(" -> BMP180"));
else if (id == 0x56 || id == 0x57) Serial.print(F(" -> BMP280 sample, works the same"));
}
Serial.println();
}
}
Serial.println(F("Done."));
}
void loop() {}Scanning I2C...
Found device at 0x76 chip ID 0x58 -> BMP280 (use this guide)
Done.Reading Step 1
| Result | What to do |
|---|---|
| 0x76, chip ID 0x58 | A BMP280 at 0x76: the most common case. Use 0x76 in Step 2 |
| 0x77, chip ID 0x58 | A BMP280 at 0x77 (Adafruit, or SDO to 3.3 V). Use 0x77 |
| Chip ID 0x60 | It's a BME280: it also measures humidity. Use the BME280 guide |
| No device found | Wiring: check power, ground, and that SDA and SCL aren't swapped |
Step 2: read temperature, pressure and altitude
Set BMP_ADDR to the address from Step 1 and upload. The sketch uses Bosch's low-noise settings: pressure oversampling ×16 and the IIR filter at ×16.
// BMP280 + ESP32 - Step 2: temperature, pressure and altitude
#include <Wire.h>
#include <Adafruit_BMP280.h>
Adafruit_BMP280 bmp;
const byte BMP_ADDR = 0x76; // from Step 1: 0x76 (most purple boards) or 0x77
const float SEA_LEVEL_HPA = 1013.25; // replace with today's local sea-level pressure
void setup() {
Serial.begin(115200);
Wire.begin(21, 22); // SDA = GPIO21, SCL = GPIO22
if (!bmp.begin(BMP_ADDR)) {
Serial.println(F("BMP280 not found - check wiring and BMP_ADDR"));
while (true) delay(10);
}
// Low-noise settings: one filtered reading every 0.5 s
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL,
Adafruit_BMP280::SAMPLING_X2, // temperature oversampling
Adafruit_BMP280::SAMPLING_X16, // pressure oversampling
Adafruit_BMP280::FILTER_X16, // IIR filter smooths gusts
Adafruit_BMP280::STANDBY_MS_500);
}
void loop() {
float tempC = bmp.readTemperature();
float hPa = bmp.readPressure() / 100.0; // library gives pascals
float metres = bmp.readAltitude(SEA_LEVEL_HPA);
Serial.print(F("Temp: ")); Serial.print(tempC, 2);
Serial.print(F(" C Pressure: ")); Serial.print(hPa, 2);
Serial.print(F(" hPa Altitude: ")); Serial.print(metres, 1);
Serial.println(F(" m"));
delay(1000);
}Temp: 27.84 C Pressure: 908.62 hPa Altitude: 908.9 m
Temp: 27.85 C Pressure: 908.61 hPa Altitude: 909.0 m
Temp: 27.85 C Pressure: 908.63 hPa Altitude: 908.8 mHow Step 2 works
| Line | What it does |
|---|---|
bmp.begin(BMP_ADDR) | Starts the sensor at your address and loads its factory calibration |
setSampling(...) | Normal mode, temperature ×2, pressure ×16, IIR filter ×16, a new reading every 0.5 s |
readPressure() / 100.0 | The library returns pascals; 100 Pa = 1 hPa |
readAltitude(SEA_LEVEL_HPA) | Converts pressure to altitude using today's sea-level pressure |
That example was taken in Bengaluru, at about 920 m. Pressure near 908 hPa is normal there. Near the coast you'd see 1000–1020 hPa.
Make the altitude correct. Look up today's sea-level pressure (QNH) for your city: airport METAR reports and many weather sites give it. Put it in SEA_LEVEL_HPA. Or, if you know your exact elevation, work backwards: P0 = P / pow(1 - h / 44330.0, 5.255) gives the sea-level pressure that makes the sensor read your known height.
Project: weather page with a 3-hour trend
Weather forecasters care less about the pressure itself than about how it's changing. A fall of more than about 1.6 hPa in three hours often means unsettled weather is coming; a steady rise usually means it's clearing. This sketch stores a reading every 10 minutes, compares now with three hours ago, and shows the result on a page you open on your phone.
// BMP280 + ESP32 - Project: weather page with a 3-hour pressure trend
#include <WiFi.h>
#include <WebServer.h>
#include <Wire.h>
#include <Adafruit_BMP280.h>
const char* WIFI_SSID = "YourWiFi";
const char* WIFI_PASS = "YourPassword";
const byte BMP_ADDR = 0x76;
Adafruit_BMP280 bmp;
WebServer server(80);
const int SLOTS = 19; // one reading every 10 min: 18 gaps = 3 hours
float history[SLOTS];
int stored = 0;
float tempC, hPa;
void sample() {
tempC = bmp.readTemperature();
hPa = bmp.readPressure() / 100.0;
}
void remember() { // shift the window, newest last
if (stored < SLOTS) history[stored++] = hPa;
else { memmove(history, history + 1, (SLOTS - 1) * sizeof(float)); history[SLOTS - 1] = hPa; }
}
String trend(float &change) {
if (stored < SLOTS) { change = 0; return "Collecting (needs 3 hours)"; }
change = history[SLOTS - 1] - history[0];
float a = fabs(change);
String dir = change > 0 ? "rising" : "falling";
if (a < 0.5) return "Steady";
if (a < 1.6) return "Slowly " + dir;
if (a < 3.6) return change > 0 ? "Rising: improving weather" : "Falling: unsettled weather likely";
return change > 0 ? "Rising quickly: clearing, windy" : "Falling quickly: storm risk";
}
const char PAGE[] PROGMEM = R"html(<!doctype html><meta name=viewport content="width=device-width,initial-scale=1">
<style>body{font-family:system-ui;text-align:center}b{font-size:2.6em;display:block}</style>
<h3>BMP280 weather</h3><p>Pressure<b id=p>-</b></p><p>Temperature<b id=t>-</b></p><p id=r></p>
<script>async function u(){const j=await (await fetch('/data')).json();
p.textContent=j.p.toFixed(1)+' hPa';t.textContent=j.t.toFixed(1)+' °C';
r.textContent=j.trend+(j.ready?' ('+(j.d>0?'+':'')+j.d.toFixed(1)+' hPa in 3 h)':'')}u();setInterval(u,5000)</script>)html";
void setup() {
Serial.begin(115200);
Wire.begin(21, 22);
if (!bmp.begin(BMP_ADDR)) { Serial.println("BMP280 not found"); while (true) delay(10); }
// Bosch's "weather monitoring" idea: low oversampling, filter off, slow updates
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, Adafruit_BMP280::SAMPLING_X1,
Adafruit_BMP280::SAMPLING_X1, Adafruit_BMP280::FILTER_OFF,
Adafruit_BMP280::STANDBY_MS_4000);
sample(); remember();
WiFi.begin(WIFI_SSID, WIFI_PASS);
while (WiFi.status() != WL_CONNECTED) delay(250);
Serial.print("Open http://"); Serial.println(WiFi.localIP());
server.on("/", [] { server.send_P(200, "text/html", PAGE); });
server.on("/data", [] {
float d; String t = trend(d);
String json = "{\"p\":" + String(hPa, 2) + ",\"t\":" + String(tempC, 2) +
",\"d\":" + String(d, 2) + ",\"ready\":" + (stored == SLOTS ? "true" : "false") +
",\"trend\":\"" + t + "\"}";
server.send(200, "application/json", json);
});
server.begin();
}
void loop() {
server.handleClient();
static unsigned long lastRead = 0, lastStore = millis();
if (millis() - lastRead > 5000) { lastRead = millis(); sample(); }
if (millis() - lastStore > 600000) { lastStore = millis(); remember(); } // every 10 min
}How the weather page works
| Part of the code | What it does |
|---|---|
setSampling(... FILTER_OFF, STANDBY_MS_4000) | Weather settings: low oversampling, no filter, a reading every 4 s. Weather is slow; this saves power |
history[19] | Stores one reading every 10 minutes: 19 readings span exactly 3 hours |
trend() | Compares the newest and oldest stored readings and describes the change |
/data | Returns the latest pressure, temperature and trend as JSON for the page |
Reading the trend. For the first three hours the page says "Collecting". After that:
| 3-hour change | Page shows |
|---|---|
| less than ±0.5 hPa | Steady |
| 0.5–1.5 hPa | Slowly rising / falling |
| 1.6–3.5 hPa | Rising: improving, or Falling: unsettled |
| more than 3.5 hPa | Rising quickly, or Falling quickly: storm risk |
These are rules of thumb, not a forecast; local geography matters. Leave the ESP32 running for a day or two and compare with what the sky does.
Going further. Publish the readings to Home Assistant over MQTT, log them for a week-long pressure graph, or run the ESP32 on a battery with deep sleep between readings: the BMP280 itself draws just 2.7 µA at one reading per second.
Try it in the simulator
The circuit below is the wiring from this guide with the Adafruit BMP280 sketch loaded. Press Run and open the Serial Monitor, then change the temperature and pressure from the BMP280's Settings: lower the pressure by 12 hPa and the altitude rises by about 100 m, the same relation the chart on the main BMP280 page shows.
Try this circuit in the SolderHub Simulator
Run this exact circuit in your browserReady-wired, code loadedConfirm simulator behavior against the real wiring and the sensor datasheet before connecting hardware.
Troubleshooting
Common problems and fixes
"BMP280 not found"
- Likely cause
- Address mismatch (library default is 0x77)
- Fix
- Use the address from Step 1 in BMP_ADDR
Scanner finds nothing
- Likely cause
- SDA/SCL swapped, no power, bad solder joint
- Fix
- Check wiring; re-solder the header if needed
Chip ID 0x60
- Likely cause
- It's a BME280
- Fix
- Use the BME280 library and guide
Altitude far from your real height
- Likely cause
- Sea-level pressure not set
- Fix
- Enter today's QNH, or calculate P0 from a known height
Temperature reads several degrees high
- Likely cause
- Heat from the ESP32 or regulator
- Fix
- Move the sensor away on short wires
Values jump when people move nearby
- Likely cause
- Draughts
- Fix
- Shield the sensor; keep the IIR filter on
Readings stop when Wi-Fi starts
- Likely cause
- Power dip on a weak USB supply
- Fix
- Use a better cable or supply
Frequently asked questions
Can I use other I²C pins?
Yes: call Wire.begin(SDA, SCL) with any free GPIOs before bmp.begin(). Avoid input-only GPIO34–39.
Can I use two BMP280s?
Yes. Wire one board's SDO to 3.3 V to make it 0x77, and create two objects: bmp1.begin(0x76) and bmp2.begin(0x77).
Why is my pressure lower than the weather forecast? The forecast shows pressure corrected to sea level. The sensor shows the real pressure where it is, which is lower the higher you live.
Do I need to calibrate the BMP280? Not for pressure: each chip carries its own factory calibration. You only set the sea-level reference for altitude.
What to build next
- Weather station: add humidity with a BME280 or a DHT22.
- Display it: show readings on an LCD1602 I²C sharing the same two I²C pins.
- Altimeter: the Uno guide has a relative altimeter; the same code runs on the ESP32.

