Zum Hauptinhalt springen

BME280 Hookup Guide

What You Will Build

Read temperature, humidity, and barometric pressure from a BME280 sensor with Arduino or ESP32.

Parts List

  • BME280 breakout board (3.3V or 5V version)
  • Arduino Uno or ESP32
  • 4× jumper wires (female-to-female)
  • Breadboard

Wiring

BME280 PinArduino Pin
VCC3.3V
GNDGND
SDAA4 (SDA)
SCLA5 (SCL)

For ESP32: SDA → GPIO21, SCL → GPIO22.

Code

Install the Adafruit BME280 library: Sketch → Include Library → Manage Libraries → search "Adafruit BME280"

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>

Adafruit_BME280 bme;

void setup() {
Serial.begin(115200);
if (!bme.begin(0x76)) {
Serial.println("BME280 not found! Check wiring.");
while (1);
}
}

void loop() {
Serial.print("Temp: "); Serial.print(bme.readTemperature());
Serial.print(" C, Humidity: "); Serial.print(bme.readHumidity());
Serial.print(" %, Pressure: "); Serial.print(bme.readPressure() / 100.0F);
Serial.println(" hPa");
delay(2000);
}

Expected Output

Temp: 23.45 C, Humidity: 52.3 %, Pressure: 1013.25 hPa

Troubleshooting

  • Sensor not found — Check I2C address (0x76 vs 0x77, jumper on breakout)
  • Garbage readings — Check VCC is 3.3V, not 5V
  • No I2C — Run I2C scanner sketch first