

The BMP280 is a high-precision digital barometric pressure sensor designed to measure atmospheric pressure and temperature. It is a compact and energy-efficient component, making it ideal for a wide range of applications. The BMP280 is commonly used in weather stations, drones, and IoT devices for altitude measurement, environmental monitoring, and weather forecasting. Its I2C and SPI communication interfaces make it easy to integrate with microcontrollers and development boards like the Arduino UNO.








The BMP280 has 8 pins, as described in the table below:
| Pin | Name | Description |
|---|---|---|
| 1 | VDD | Power supply pin (1.71V to 3.6V). |
| 2 | GND | Ground pin. |
| 3 | SCL/SPC | Serial clock line for I2C or SPI communication. |
| 4 | SDA/SDI/SDO | Data line for I2C or SPI communication. |
| 5 | CSB | Chip select for SPI communication (active low). Tie to VDD for I2C mode. |
| 6 | SDO | SPI data output. Leave unconnected in I2C mode. |
| 7 | NC | Not connected. Leave floating. |
| 8 | VDDIO | I/O voltage supply pin. Typically connected to VDD. |
Below is an example of how to interface the BMP280 with an Arduino UNO using the Adafruit BMP280 library:
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>
// Create an instance of the BMP280 sensor
Adafruit_BMP280 bmp;
void setup() {
Serial.begin(9600); // Initialize serial communication at 9600 baud
if (!bmp.begin(0x76)) {
// Initialize BMP280 with I2C address 0x76. If initialization fails, print error.
Serial.println("Could not find a valid BMP280 sensor, check wiring!");
while (1); // Halt execution if sensor is not found
}
// Configure the BMP280 sensor
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, // Normal mode
Adafruit_BMP280::SAMPLING_X2, // Temperature oversampling x2
Adafruit_BMP280::SAMPLING_X16, // Pressure oversampling x16
Adafruit_BMP280::FILTER_X16, // Filter coefficient x16
Adafruit_BMP280::STANDBY_MS_500); // Standby time 500ms
}
void loop() {
// Read and print temperature and pressure values
Serial.print("Temperature = ");
Serial.print(bmp.readTemperature());
Serial.println(" *C");
Serial.print("Pressure = ");
Serial.print(bmp.readPressure());
Serial.println(" Pa");
Serial.print("Approx. Altitude = ");
Serial.print(bmp.readAltitude(1013.25));
// Calculate altitude assuming sea level pressure is 1013.25 hPa
Serial.println(" m");
delay(2000); // Wait for 2 seconds before the next reading
}
Sensor Not Detected:
Incorrect Readings:
Communication Errors:
Q: Can the BMP280 measure altitude directly?
A: The BMP280 does not measure altitude directly but calculates it based on atmospheric pressure. You can use the readAltitude() function in the Adafruit library to estimate altitude, assuming a known sea-level pressure.
Q: What is the difference between the BMP280 and BME280?
A: The BMP280 measures pressure and temperature, while the BME280 includes an additional humidity sensor for environmental monitoring.
Q: Can the BMP280 operate at 5V?
A: No, the BMP280 operates at a maximum voltage of 3.6V. Use a level shifter if interfacing with a 5V microcontroller.
Q: How do I switch between I2C and SPI modes?
A: The communication mode is determined by the state of the CSB pin. Tie CSB to VDD for I2C mode or connect it to the SPI chip select line for SPI mode.