The BME280 measures temperature, humidity and air pressure in one tiny chip, which makes it the usual sensor for a home weather station. It is more accurate than a DHT22 and reads in milliseconds instead of seconds.
The chip is 3.3 V-only, and most cheap purple 6-pin boards pass the pins straight through. On a 5 V Uno that means two things. Power it from the 3.3V pin, which can supply about 50 mA — far more than the sensor needs. And put a BSS138 level shifter on SDA and SCL, because the Uno’s Wire library pulls those lines up to 5 V.
The sketch prints the chip ID so you can tell a real BME280 from a BMP280. It then takes a forced-mode reading every 5 seconds.
Wiring
| Arduino Uno R3 | BME280 breakout | Wire | Notes |
|---|---|---|---|
| 3.3V | VIN / VCC | red | Bare 6-pin boards are 3.3 V-only. The sensor draws about 1 mA — easy for the Uno’s 3.3V pin. |
| GND | GND | black | |
| SCL | SCL | yellow | Via level shifter — Shifter LV = 3.3V, HV = 5V, GND shared. |
| SDA | SDA | blue | Via level shifter |
| GND | SDO | black | Address 0x76 (SDO to 3.3V = 0x77). |
| 3.3V | CSB | red | HIGH keeps the chip in I2C mode. |
3.3 V (VIN boards with a regulator: 3.3–5 V) part, 5 V board. The chip itself is 3.3 V-only. Many purple 6-pin boards have no regulator — feed them 3.3 V only. Boards with a VIN pin and regulator accept 5 V, but keep SDA/SCL at the board's logic level.
Board quirks
- Bosch rates the BME280 at 3.6 V maximum on every pin. On the Uno, the Wire library pulls SDA/SCL up to 5 V, so a direct connection overstresses a bare board. The level shifter fixes that.
- Boards with a VIN pin, a 3-pin regulator and two small transistors already shift levels — wire those to 5V and SDA/SCL directly and skip the shifter.
- Many “BME280” listings ship a BMP280 (no humidity). The sketch prints the chip ID: 0x60 = BME280, 0x58 = BMP280.
- Forced mode takes one reading every 5 s and sleeps in between, so the chip doesn’t heat itself and read high.
Code
// BME280 temperature + humidity + pressure on an Arduino Uno R3 (I2C).
// 3.3 V-only 6-pin board: VIN/VCC → 3.3V, SDA/SCL through a BSS138 level shifter,
// SDO → GND (0x76), CSB → 3.3V (I2C). Forced mode: one reading per request, then sleep,
// so the sensor doesn't warm itself up.
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
Adafruit_BME280 bme;
void setup() {
Serial.begin(9600);
if (!bme.begin(0x76) && !bme.begin(0x77)) {
Serial.println(F("No BME280 at 0x76 or 0x77 - check 3.3V, the shifter and SDO"));
for (;;) {}
}
Serial.print(F("BME280 found (chip ID 0x"));
Serial.print(bme.sensorID(), HEX);
Serial.println(F(")"));
bme.setSampling(Adafruit_BME280::MODE_FORCED, Adafruit_BME280::SAMPLING_X1, Adafruit_BME280::SAMPLING_X1,
Adafruit_BME280::SAMPLING_X1, Adafruit_BME280::FILTER_OFF);
}
void loop() {
bme.takeForcedMeasurement();
Serial.print(F("Temp "));
Serial.print(bme.readTemperature(), 1);
Serial.print(F(" C Humidity "));
Serial.print(bme.readHumidity(), 1);
Serial.print(F(" % Pressure "));
Serial.print(bme.readPressure() / 100.0, 1);
Serial.println(F(" hPa"));
delay(5000);
}// BME280 temperature + humidity + pressure on an Arduino Uno R3 (I2C).
// 3.3 V-only 6-pin board: VIN/VCC → 3.3V, SDA/SCL through a BSS138 level shifter,
// SDO → GND (0x76), CSB → 3.3V (I2C). Forced mode: one reading per request, then sleep,
// so the sensor doesn't warm itself up.
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
Adafruit_BME280 bme;
void setup() {
Serial.begin(9600);
if (!bme.begin(0x76) && !bme.begin(0x77)) {
Serial.println(F("No BME280 at 0x76 or 0x77 - check 3.3V, the shifter and SDO"));
for (;;) {}
}
Serial.print(F("BME280 found (chip ID 0x"));
Serial.print(bme.sensorID(), HEX);
Serial.println(F(")"));
bme.setSampling(Adafruit_BME280::MODE_FORCED, Adafruit_BME280::SAMPLING_X1, Adafruit_BME280::SAMPLING_X1,
Adafruit_BME280::SAMPLING_X1, Adafruit_BME280::FILTER_OFF);
}
void loop() {
bme.takeForcedMeasurement();
Serial.print(F("Temp "));
Serial.print(bme.readTemperature(), 1);
Serial.print(F(" C Humidity "));
Serial.print(bme.readHumidity(), 1);
Serial.print(F(" % Pressure "));
Serial.print(bme.readPressure() / 100.0, 1);
Serial.println(F(" hPa"));
delay(5000);
}Library: Adafruit BME280 Library (Adafruit (also install Adafruit Unified Sensor)) — compiled with Adafruit BME280 Library 2.3.0.
Expected serial output
BME280 found (chip ID 0x60)
Temp 27.8 C Humidity 61.2 % Pressure 1007.9 hPa
Temp 27.8 C Humidity 61.4 % Pressure 1007.9 hPaBME280 found (chip ID 0x60) Temp 27.8 C Humidity 61.2 % Pressure 1007.9 hPa Temp 27.8 C Humidity 61.4 % Pressure 1007.9 hPa
Common errors
“No BME280 at 0x76 or 0x77”
Check the shifter’s LV and HV supplies and that CSB is HIGH. More causes in BME280 could not find sensor.
Humidity always 0 % (or the chip ID is 0x58)
It’s a BMP280 sold as a BME280. Use the BMP280 guide.
“Adafruit_Sensor.h: No such file”
Install Adafruit Unified Sensor too. See this fix.