Arduino UNO BMP280 Barometric Pressure and Altitude Sensor

The BMP280 Barometric Pressure and Altitude Sensor project demonstrates how to interface a Bosch BMP280 digital sensor with an Arduino UNO. The BMP280 measures atmospheric pressure and temperature with high precision and can use the pressure data to estimate approximate altitude above sea level. This sensor is commonly used in weather stations, drones, altitude‑tracking devices, and IoT‑based environmental‑monitoring systems.

What Is the BMP280 Sensor?

The BMP280 is a compact digital barometric pressure and temperature sensor that uses MEMS technology to deliver accurate readings. It operates over a wide pressure range (typically 300–1100 hPa) and temperature range (about −40°C to +85°C), with pressure accuracy of about ±1 hPa and temperature accuracy of about ±1°C at 25°C, making it suitable for altitude estimation and weather‑monitoring applications.

Most module‑style BMP280 boards expose I2C or SPI pins, and they are compatible with Arduino UNO, Arduino Nano, and many other microcontrollers. The Adafruit‑style BMP280 breakout is one of the most popular versions used in hobby projects.

Components Needed

  • Arduino UNO
  • BMP280 barometric pressure and temperature sensor module (I2C or SPI)
  • Jumper Wires
  • Breadboard
  • Optional: OLED or LCD display for on‑screen data

Circuit Setup (I2C Wiring)

1. Connect BMP280 to Arduino UNO:

Most I2C BMP280 modules expose four pins:

  • VCC → 5V or 3.3V (check your module; many include a 3.3V regulator so 5V is safe).
  • GND → GND on the Arduino UNO.
  • SCL → A5 (SCL) on the Arduino UNO.
  • SDA → A4 (SDA) on the Arduino UNO.

If your module has an additional chip select pin (CS), leave it unconnected or tie it HIGH when using I2C mode; follow the module’s datasheet to decide which pin selects I2C vs SPI.

How the BMP280 Works

The BMP280 measures the ambient air pressure and temperature and returns calibrated values over I2C or SPI. The Arduino UNO reads these values using a library (such as Adafruit_BMP280 and Adafruit_Sensor) that handles the low‑level communication and compensation math. Because atmospheric pressure decreases with altitude, the library can also compute an approximate altitude above sea level when you provide the local sea‑level pressure (hPa) for your area and weather.

This makes the BMP280 useful not only as a barometer and temperature sensor but also as a basic altimeter in drones, balloons, or hiking‑style data loggers.

Program: Arduino UNO BMP280 (Pressure, Temperature, and Altitude)
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>

// Create BMP280 object
Adafruit_BMP280 bmp;

// Local sea‑level pressure in hPa (update for your area)
#define SEALEVELPRESSURE_HPA (1013.25)

void setup() {
  Serial.begin(9600);
  
  // Initialize BMP280 over I2C
  if (!bmp.begin(0x76)) {  // 0x76 or 0x77, check your module
    Serial.println(F("BMP280 not found!"));
    while (1);
  }
  
  Serial.println(F("=== BMP280 READY ==="));
  Serial.println(F("Temp	Pres.	Alt."));
}

void loop() {
  // Read temperature in °C
  float temperature = bmp.readTemperature();
  
  // Read pressure in Pa, convert to hPa
  float pressure = bmp.readPressure() / 100.0f;
  
  // Calculate approximate altitude in meters
  float altitude = bmp.readAltitude(SEALEVELPRESSURE_HPA);
  
  // Print to Serial Monitor
  Serial.print(temperature);
  Serial.print(" °C	");
  Serial.print(pressure);
  Serial.print(" hPa	");
  Serial.print(altitude);
  Serial.println(" m");
  
  delay(2000);
}

// How to install required libraries in Arduino IDE:
// 1) Sketch → Include Library → Manage Libraries
// 2) Search for "Adafruit BMP280"
// 3) Install both "Adafruit BMP280 Library" and "Adafruit Unified Sensor"

Instructions

1. Circuit Setup:

Wire the BMP28 princípio to the Arduino UNO as described in the I2C wiring section, making sure the I2C address (often 0x76 or 0x77) matches the one used in the bmp.begin() call in the code.

2. Install Libraries:

In the Arduino IDE, go to Sketch → Include Library → Manage Libraries and install:

  • Adafruit BMP280 Library
  • Adafruit Unified Sensor

3. Update Sea‑Level Pressure:

Change the SEALEVELPRESSURE_HPA constant to the typical sea‑level pressure for your city or region (obtainable from a weather service); this improves the accuracy of the calculated altitude.

4. Code Upload and Testing:

Upload the BMP280 code to the Arduino UNO via USB and open the Serial Monitor at 9600 baud. The monitor will show the current temperature in °C, pressure in hPa, and estimated altitude in meters, updating every 2 seconds.

Applications

Weather Stations: Use the BMP280 to build a compact weather‑station node that logs pressure, temperature, and estimated altitude for home or school use.

Drones and Altitude Tracking: Integrate the sensor into small drones or balloons to estimate altitude during flight and detect climbs or descents.

Environmental and IoT Monitoring: Combine the BMP280 with Wi‑Fi modules or SD cards to create IoT‑style data loggers that send pressure and temperature values to the cloud or store them for later analysis.

Troubleshooting

  • Sensor not found? Check the I2C wiring, power supply, and that the module’s I2C address (0x76 or 0x77) matches the one passed to bmp.begin(); some modules allow address selection via a jumper.
  • Erratic or impossible values? Ensure the SEALEVELPRESSURE_HPA is set reasonably close to your local sea‑level pressure; incorrect values will distort the altitude calculation.
  • No readings on Serial Monitor? Confirm the correct baud rate (9600) and that the appropriate libraries are installed and selected in the Arduino IDE.

Best Practices and Notes

  • Place the BMP280 away from heat sources, forced air, or direct airflow to get stable pressure and temperature readings.
  • If using the altitude feature, update the sea‑level pressure value regularly (e.g. from a weather report) because barometric pressure changes with weather conditions.
  • Use a stable power supply and avoid long, noisy I2C lines to reduce measurement jitter and sensor communication errors.

Extensions and Ideas

You can extend this project by adding an OLED or LCD display to show pressure, temperature, and altitude in real time, or by logging the values to an SD card, or by combining the BMP280 with an LDR and other sensors in a multi‑parameter environmental station, or by using the altitude data as part of a drone or rocket stabilization system.