Arduino BMP280 Pressure Sensor: Wiring, Code and Simulator

To build this Arduino BMP280 Pressure Sensor project you need an Arduino Uno and a pressure sensor BMP280. Temperature and air pressure from a BMP280 over I2C with the Adafruit library. Make the 4 connections in the wiring table, upload the Arduino C++ code, and move the Pressure slider and compute altitude with bmp.readAltitude(1013.25).

Open this circuit in the free Arduino Uno simulator

Parts list

QtyPartWhat it does
1Arduino Unothe microcontroller board
1Pressure Sensor BMP280Temperature and air pressure on I²C (0x76; 0x77 with SDO high): bmp.begin(0x76), readTemperature(), readPressure(), readAltitude(1013.25).

Wiring

#FromTo
1Arduino Uno 5VPressure Sensor BMP280 VCC
2Arduino Uno GNDPressure Sensor BMP280 GND
3Arduino Uno A4Pressure Sensor BMP280 SDA
4Arduino Uno A5Pressure Sensor BMP280 SCL

Step by step

  1. Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the Arduino Uno. No install or account is needed.
  2. Add the parts. Add a pressure sensor BMP280 from the parts palette.
  3. Wire 1. Connect Arduino Uno 5V to Pressure Sensor BMP280 VCC.
  4. Wire 2. Connect Arduino Uno GND to Pressure Sensor BMP280 GND.
  5. Wire 3. Connect Arduino Uno A4 to Pressure Sensor BMP280 SDA.
  6. Wire 4. Connect Arduino Uno A5 to Pressure Sensor BMP280 SCL.
  7. Paste the Arduino C++ code. Paste the Arduino C++ code below into the code editor.
  8. Run it. Press Run. Move the Pressure slider and compute altitude with bmp.readAltitude(1013.25).

Arduino C++ code

// Adafruit BMP280: temperature and air pressure over I2C (address 0x76).
#include <Adafruit_BMP280.h>

Adafruit_BMP280 bmp;

void setup() {
  Serial.begin(9600);
  if (!bmp.begin(0x76)) {
    Serial.println("BMP280 not found.");
    while (true) {}
  }
}

void loop() {
  Serial.print("T = ");
  Serial.print(bmp.readTemperature(), 1);
  Serial.print(" C, P = ");
  Serial.print(bmp.readPressure() / 100.0, 1);
  Serial.println(" hPa");
  delay(1000);
}

What to try

Move the Pressure slider and compute altitude with bmp.readAltitude(1013.25).

Frequently asked questions

How do I wire the BMP280 Pressure Sensor project on an Arduino Uno?

Make 4 connections: Arduino Uno 5V to Pressure Sensor BMP280 VCC; Arduino Uno GND to Pressure Sensor BMP280 GND; Arduino Uno A4 to Pressure Sensor BMP280 SDA; Arduino Uno A5 to Pressure Sensor BMP280 SCL.

What parts do I need for this Arduino project?

An Arduino Uno and a pressure sensor BMP280.

Can I simulate this Arduino project online for free?

Yes. The BitForBytes Embedded Lab runs this exact circuit and Arduino C++ code in your browser for free, with no install and no hardware. The sketch is compiled with the real Arduino toolchain and runs on an emulated ATmega328P.

What does the code do?

Temperature and air pressure from a BMP280 over I2C with the Adafruit library.

More Arduino Uno projects