The BMP280 is a high-precision barometric pressure and temperature sensor from Bosch Sensortec that has become a staple in hobbyist and professional projects alike. With its compact form factor, I2C/SPI interface, and +/-1 hPa pressure accuracy, it serves perfectly in weather stations, altitude trackers, drone altimeters, and IoT environmental monitors.
This step-by-step tutorial walks you through everything you need to interface the BMP280 with an Arduino — from unboxing and wiring to library installation, code examples, and practical troubleshooting. No prior sensor experience is required; by the end you will have live pressure, temperature, and altitude readings scrolling in the Serial Monitor.
1. Components Required
- Arduino Uno (or Nano, Mega, ESP32)
- GY-BMP280 sensor module (the breakout board, not the bare chip)
- Breadboard and jumper wires
- USB cable for Arduino programming
- Arduino IDE installed on your computer
- Optional: 0.96 inch I2C OLED display for a standalone weather station
BMP280 Barometric Pressure and Altitude Sensor I2C/SPI Module
Genuine GY-BMP280 module compatible with Arduino Uno, Nano, Mega, and ESP32. Supports both I2C and SPI interfaces.
2. BMP280 Module Pinout Explained
| Pin Label | Function | Notes |
|---|---|---|
| VCC | Power supply | 3.3 V or 5 V (module has onboard regulator) |
| GND | Ground | Connect to Arduino GND |
| SCL | I2C Clock / SPI Clock | A5 on Uno, Pin 21 on Mega |
| SDA | I2C Data / SPI MOSI | A4 on Uno, Pin 20 on Mega |
| CSB | Chip Select (SPI) | Leave floating or tie to 3.3 V for I2C |
| SDO | I2C Address Select / SPI MISO | GND=0x76, 3.3V=0x77 |
3. Wiring BMP280 to Arduino via I2C
BMP280 Module --> Arduino Uno
VCC --> 3.3V (preferred) or 5V
GND --> GND
SCL --> A5
SDA --> A4
CSB --> (leave unconnected)
SDO --> GND (I2C address: 0x76)
// If SDO is connected to 3.3V:
// I2C address becomes 0x77 -- change bmp.begin(0x77) in code
Pro tip for Indian summer: Keep I2C wires under 30 cm on breadboard. Longer wires pick up noise from high-current devices like motors and relays, corrupting I2C communication.
4. Wiring BMP280 to Arduino via SPI
BMP280 Module --> Arduino Uno (SPI)
VCC --> 3.3V
GND --> GND
SCL --> Pin 13 (SCK)
SDA --> Pin 11 (MOSI)
SDO --> Pin 12 (MISO)
CSB --> Pin 10 (SS/CS)
// In code, use: Adafruit_BMP280 bmp(10); // CS pin
5. Installing the Adafruit BMP280 Library
- Go to Sketch → Include Library → Manage Libraries
- Search for Adafruit BMP280
- Click Install. When prompted to install dependencies, click Install All
- Wait for installation to complete (under 30 seconds)
- Verify: File → Examples → Adafruit BMP280 Library → bmp280test should now be available
6. Basic Arduino Code — Pressure & Temperature
#include <Wire.h>
#include <Adafruit_BMP280.h>
Adafruit_BMP280 bmp; // I2C mode
void setup() {
Serial.begin(9600);
while (!Serial) delay(100);
Serial.println("BMP280 Test");
if (!bmp.begin(0x76)) {
Serial.println("BMP280 not found! Check:");
Serial.println(" 1. VCC and GND connected");
Serial.println(" 2. SDA->A4, SCL->A5");
Serial.println(" 3. SDO=GND for address 0x76");
while (1) delay(10);
}
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL,
Adafruit_BMP280::SAMPLING_X2,
Adafruit_BMP280::SAMPLING_X16,
Adafruit_BMP280::FILTER_X16,
Adafruit_BMP280::STANDBY_MS_500
);
Serial.println("BMP280 initialized successfully!");
}
void loop() {
float temperature = bmp.readTemperature();
float pressure = bmp.readPressure() / 100.0F;
Serial.print("Temperature: "); Serial.print(temperature, 1); Serial.println(" C");
Serial.print("Pressure: "); Serial.print(pressure, 2); Serial.println(" hPa");
Serial.println();
delay(2000);
}
Upload this sketch, open Serial Monitor at 9600 baud, and you should see readings every 2 seconds. A typical reading at sea level in India during summer: 1008-1015 hPa, 30-42 deg C.
7. Altitude Calculation Code
Altitude calculation requires a reference sea-level pressure. The standard ISA sea-level pressure is 1013.25 hPa, but this changes daily with weather. For a weather station that also shows accurate altitude, fetch the current Mean Sea Level Pressure (MSLP) from the India Meteorological Department website for your nearest station.
#include <Wire.h>
#include <Adafruit_BMP280.h>
Adafruit_BMP280 bmp;
// Update this to today's local sea-level pressure from weather.in or IMD
const float SEALEVEL_HPA = 1013.25;
void setup() {
Serial.begin(9600);
if (!bmp.begin(0x76)) { Serial.println("BMP280 not found!"); while (1); }
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL,
Adafruit_BMP280::SAMPLING_X2, Adafruit_BMP280::SAMPLING_X16,
Adafruit_BMP280::FILTER_X16, Adafruit_BMP280::STANDBY_MS_500);
}
void loop() {
float temp = bmp.readTemperature();
float pressure = bmp.readPressure() / 100.0F;
float altitude = bmp.readAltitude(SEALEVEL_HPA);
Serial.print("Temp: "); Serial.print(temp, 1); Serial.println(" C");
Serial.print("Pressure: "); Serial.print(pressure, 2); Serial.println(" hPa");
Serial.print("Altitude: "); Serial.print(altitude, 1); Serial.println(" m");
Serial.println("-----");
delay(2000);
}
8. Oversampling & Filter Settings Explained
| Oversampling | Pressure Noise (RMS) | Altitude Noise (RMS) | Measurement Time |
|---|---|---|---|
| x1 | 3.3 Pa | +/-27 cm | 4.5 ms |
| x2 | 2.3 Pa | +/-19 cm | 7.5 ms |
| x16 | 0.6 Pa | +/-5 cm | 41.5 ms |
The IIR filter (FILTER_X16) suppresses short-term pressure spikes caused by wind gusts, door slams, or vibration. For weather monitoring in a static location, always use FILTER_X16. For a drone where you need fast pressure response, use FILTER_OFF or FILTER_X2.
9. Advanced: Low-Power Weather Station Mode
#include <Wire.h>
#include <Adafruit_BMP280.h>
Adafruit_BMP280 bmp;
void setup() {
Serial.begin(9600);
bmp.begin(0x76);
bmp.setSampling(Adafruit_BMP280::MODE_FORCED,
Adafruit_BMP280::SAMPLING_X1,
Adafruit_BMP280::SAMPLING_X1,
Adafruit_BMP280::FILTER_OFF,
Adafruit_BMP280::STANDBY_MS_1000);
}
void loop() {
bmp.takeForcedMeasurement();
float temp = bmp.readTemperature();
float pres = bmp.readPressure() / 100.0F;
Serial.print(temp); Serial.print(" C, ");
Serial.print(pres); Serial.println(" hPa");
delay(60000); // Log every minute
}
In forced mode with x1 oversampling, the BMP280 consumes just 2.74 µA on average at 1 Hz — a coin cell can power it for months.
10. Displaying Readings on OLED
#include <Wire.h>
#include <Adafruit_BMP280.h>
#include <Adafruit_SSD1306.h>
Adafruit_BMP280 bmp;
Adafruit_SSD1306 display(128, 64, &Wire, -1);
void setup() {
bmp.begin(0x76);
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL,
Adafruit_BMP280::SAMPLING_X2, Adafruit_BMP280::SAMPLING_X16,
Adafruit_BMP280::FILTER_X16, Adafruit_BMP280::STANDBY_MS_500);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.setTextColor(SSD1306_WHITE);
}
void loop() {
float t = bmp.readTemperature();
float p = bmp.readPressure() / 100.0F;
float a = bmp.readAltitude(1013.25);
display.clearDisplay();
display.setTextSize(1);
display.setCursor(0, 0); display.print("Temp: "); display.print(t, 1); display.println(" C");
display.setCursor(0, 20); display.print("Pres: "); display.print(p, 1); display.println(" hPa");
display.setCursor(0, 40); display.print("Alt: "); display.print(a, 0); display.println(" m");
display.display();
delay(2000);
}
11. Practical Project Ideas
- Home weather station: Log pressure, temperature, and altitude to an SD card. Analyse pressure trends to predict rain (falling pressure signals incoming weather front).
- Trekking altimeter: Pair with a GPS module and OLED for a standalone trekking computer. The BMP280’s fast pressure response gives smoother altitude tracking than GPS alone.
- Drone altitude hold: Feed BMP280 readings into a PID controller to maintain fixed altitude above ground. Combine with an ultrasonic sensor for accurate low-altitude hold (under 3 m).
- Industrial oven pressure monitor: Track pressure in sealed chambers during industrial processes.
- Refrigerated truck monitor: Log temperature and pressure during cold chain transport for compliance auditing.
GY-BME280-3.3 Precision Altimeter Atmospheric Pressure Sensor Module
Want to also measure humidity? Upgrade to the BME280 — adds humidity sensing with identical wiring and nearly identical code.
12. Troubleshooting Common Issues
BMP280 not found at startup
- Verify wiring: SDA to A4, SCL to A5 on Uno. Check no wires are loose.
- Run I2C scanner sketch — what address does it find? If 0x77 instead of 0x76, change bmp.begin(0x77).
- Check power: VCC must be 3.3 V or 5 V. Do not use the Uno’s 3.3 V pin if it is heavily loaded by other peripherals.
Pressure reading is obviously wrong (e.g., 900 hPa in Mumbai at sea level)
At sea level in India, pressure should be 995-1025 hPa. If reading is far off: (1) module might need 2-3 minutes to warm up for thermal stabilisation; (2) oversampling settings may not have been applied — call bmp.setSampling() before the first read; (3) check if module is counterfeit.
Readings change by +/-5 hPa between consecutive reads
Enable the IIR filter: change FILTER_OFF to FILTER_X16. This dramatically smooths pressure readings without affecting the output data rate.
Altitude shows large errors despite known location
Update the sea-level pressure constant to your local current weather station reading (available on weather.com or Windy.com). A 10 hPa error in the sea-level reference causes approximately 85 m altitude error.
Frequently Asked Questions
Do I need pull-up resistors for BMP280 I2C?
The GY-BMP280 module includes 4.7 kOhm pull-up resistors on SDA and SCL. You do not need to add external ones when using a single BMP280 on the I2C bus. If you have multiple I2C devices, the parallel combination of pull-ups may be too low, causing I2C errors.
Can I use BMP280 with ESP8266 or ESP32?
Yes. For ESP8266: SDA=GPIO4 (D2), SCL=GPIO5 (D1). For ESP32: SDA=GPIO21, SCL=GPIO22 by default. Both boards operate at 3.3 V, fully compatible with the BMP280 chip.
How accurate is the BMP280 altitude reading?
With correct sea-level pressure reference and x16 oversampling plus IIR filter, you can detect altitude changes of approximately 50 cm reliably. Absolute accuracy depends on weather conditions: on a stable clear day, expect +/-1-3 m.
What is the difference between MODE_NORMAL and MODE_FORCED?
MODE_NORMAL continuously samples at the rate defined by standby time. MODE_FORCED takes one sample and returns to sleep — you must call bmp.takeForcedMeasurement() before reading. FORCED mode consumes far less power and is ideal for battery-powered devices that log data at intervals of 1 minute or more.
Can BMP280 measure indoor vs outdoor altitude differences?
In principle yes — moving from ground floor to 3rd floor (approximately 9 metres) corresponds to about 1 hPa pressure change, which the BMP280 can detect reliably with x16 oversampling. This is how smartphones detect floor level changes in multi-storey buildings.
What happens if I accidentally power BMP280 with 5V directly without the module regulator?
The bare BMP280 chip is rated for maximum 3.6 V. Connecting 5 V directly to the chip VDD pin will permanently damage it. Always use the GY-BMP280 module which includes a 3.3 V LDO regulator, or add your own 3.3 V regulator circuit when using the bare chip.
Add comment