Skip to content
Go back

BME280 Sensor: Datasheet, I2C Wiring and Calibration

Published:  at  10:45 AM

Editorial note: check the specific module, the ESPHome version and the figures on the manufacturer’s datasheet before publishing this.

What the BME280 measures

The BME280 is a digital sensor from Bosch Sensortec that measures temperature, relative humidity and atmospheric pressure. On prototyping modules it normally talks over I2C, although the component can also use SPI.

It’s an interesting alternative to a DHT when you need pressure on top of temperature and humidity, or when you want a standard bus with registers and oversampling options. It is not an air quality sensor: it doesn’t measure CO2, particles or volatile organic compounds directly.

Indicative specifications

FeatureBME280
MeasurementsTemperature, humidity and pressure
InterfaceI2C or SPI
Chip supplyPer the manufacturer datasheet; the chip runs on a low voltage
Humidity accuracyApproximately ±3 % RH under specified conditions
Temperature accuracyApproximately ±1 °C under specified conditions
Pressure accuracyApproximately ±1 hPa under specified conditions
Typical I2C address0x76 or 0x77, depending on the SDO pin state

These figures are a reference for the BME280 family, not a guarantee for every commercial module. The breakout board may include a regulator, level shifting and a pull-up resistor. Check the documentation of the board you bought and don’t mistake a BME280 for a BMP280: the BMP280 doesn’t measure humidity.

I2C wiring to the ESP32

On an ESP32 development board, a typical connection is:

BME280ESP32
VCC or VINA supply compatible with the module
GNDGND
SDAGPIO21 as a common example
SCLGPIO22 as a common example
I2C wiring diagram between a BME280 and an ESP32 with SDA on GPIO21 and SCL on GPIO22
Typical I2C connection of the BME280 to an ESP32.

GPIO21 and GPIO22 are a frequent choice for I2C on the ESP32, but they aren’t universal. Your board or project may use other pins. Configure them explicitly and avoid pins reserved for booting or already taken by another peripheral.

The BME280 chip runs on a low voltage. Some modules accept 5 V on the pin marked VIN because they include a regulator and adaptation circuitry, while others expose the chip directly. If you don’t know what circuit the module has, use 3.3 V and check its schematic. Feeding 5 V into a GPIO can damage it.

Detecting the I2C address

The address usually depends on the SDO pin. Two modules don’t have to use the same address, and some products include jumpers or resistors to change it. If the sensor doesn’t show up:

  1. Check VCC and GND.
  2. Make sure SDA and SCL aren’t swapped.
  3. Run an I2C scan.
  4. Try 0x76 and 0x77 if the module doesn’t document its address.
  5. Confirm that the pull-ups exist and that the bus voltage is compatible.

Don’t change the address in the configuration to hide incorrect wiring. First confirm that the scanner physically detects the module.

Configuration with ESPHome

This example uses GPIO21 and GPIO22 and leaves the address at 0x76. Adapt the pins, the name and the interval to your setup:

i2c:
  sda: GPIO21
  scl: GPIO22
  scan: true

sensor:
  - platform: bme280_i2c
    address: 0x76
    temperature:
      name: "Living room temperature"
    humidity:
      name: "Living room humidity"
    pressure:
      name: "Atmospheric pressure"
    update_interval: 60s

The address and the component name must match the installed ESPHome version. Compile without any extra automations first and watch the log. If the device shows up but one measurement doesn’t change, review the corresponding block and the update interval.

How to interpret the pressure

The pressure the sensor reports is absolute pressure at the point where it is installed. Don’t compare it directly with a weather forecast without taking altitude and the type of pressure shown by the external service into account.

A pressure change can serve as trend data, but it doesn’t turn the BME280 into a complete weather station. The enclosure, the heat from the board and the sensor position all influence the readings.

Calibration and checks

The BME280 usually comes calibrated from the factory, but that doesn’t mean two cheap modules give exactly the same value. To check this:

  1. Place two sensors together, away from draughts and heat sources.
  2. Wait until they reach a stable temperature.
  3. Compare trends and differences over several hours, not a single reading.
  4. Check that humidity isn’t affected by condensation or by touching the sensing element.
  5. Document an offset only if you have a reasonable reference and the application justifies correcting it.

Don’t use an offset to hide a power problem, a wrong address or a module that is really a BMP280. Fix the electrical and configuration cause first.

Frequent errors

External sources

Next step

If you want to continue with a simple analog reading, you can try the LDR and ESP32 wiring.

If you are still choosing the board, check ESP32: what it is, what it’s for and how to get started. To compare this sensor with the DHT11 and the DHT22, see the DHT11 vs DHT22 guide.

The homeiotguide editorial team

Editorial lead: Néstor Espuch


Suggest changes
Share this article on:

Previous article
HLK-LD2410 mmWave Presence Sensor with Home Assistant
Next article
Matter vs Zigbee vs WiFi vs Bluetooth: what to choose