ESP32 BME280 Wiring (I2C) + Arduino & ESPHome Example Code (2026)

This guide shows the exact wiring, exact libraries, and tested code to read temperature, humidity, and pressure from a BME280 sensor using I2C.


1. What You Need

Use one of these BME280 modules:

You also need:


2. Check Your BME280 Version

This matters.

If your module has VIN + GND + SCL + SDA → OK.

It already has a voltage regulator + pull-ups.

If your module has only 3.3V + GND + SCL + SDA → 3.3V ONLY

Do NOT connect 5V.


3. Wiring (I2C) — EXACT Pins

Use these exact connections:

BME280ESP32Notes
VIN / VCC3.3VUse 3.3V only.
GNDGNDAny GND pin is fine.
SCLGPIO 22Default I2C SCL on ESP32.
SDAGPIO 21Default I2C SDA on ESP32.

Cable length: keep under 30 cm for stable readings.
No pull-ups needed — BME280 boards include them.


4. Install Required Libraries

You need two libraries.

  1. Open Arduino IDE
  2. Go to Tools → Manage Libraries
  3. Install:
Adafruit BME280

Publisher: Adafruit
Version: latest (works)

Adafruit Unified Sensor

Publisher: Adafruit

That’s all.

5. TESTED Code

This code auto-detects the sensor address (0x76 or 0x77) and prints all readings.

Upload this → Open Serial Monitor (115200).

You should see:

BME280 detected.
Temp: 23.41 °C | Hum: 51.2 % | Pressure: 1009.4 hPa

6. If You Get “BME280 not found”

Do these checks:

1. Wiring

  • SDA must be on GPIO 21
  • SCL must be on GPIO 22
  • GND must be common
  • Use 3.3V only

2. Sensor address

Try swapping:

bme.begin(0x77);

3. Module type

Some cheap modules labeled “BME280” are actually BMP280 (no humidity sensor).

Check printout: if humidity = NAN → it’s a BMP280.

Share your love

Leave a Reply

Your email address will not be published. Required fields are marked *