ESP32 BME280 Temperature and Humidity Sensor

BME280 Temperature and Humidity Sensor image

BME280

Protocol: I2C,SPI

Overview

The BME280 is a compact digital sensor by Bosch Sensortec, designed for measuring temperature, humidity, and pressure with high accuracy and low power consumption. It supports both I²C and SPI communication protocols, making it versatile for integration into IoT devices, weather stations, and portable electronics. Operating within a wide range of environmental conditions, it features a small 2.5mm x 2.5mm package.

About BME280 Temperature and Humidity Sensor

The BME280, developed by Bosch Sensortec, is a highly integrated environmental sensor that provides accurate temperature, humidity, and pressure measurements. Its low power consumption and compact size make it perfect for IoT, wearables, and weather monitoring applications.

Key Features

  • 3-in-1 Sensing – Measures temperature (-40°C to 85°C), humidity (0–100% RH), and pressure (300–1100 hPa).
  • Multiple Communication Interfaces – Supports I²C and SPI for flexible integration.
  • Ultra-Low PowerConsumes as little as 1.8 µA, ideal for battery-powered devices.
  • Compact Design – Small 2.5 × 2.5 × 0.93 mm form factor for space-constrained applications.

🔗 Learn more about the BME280 sensor.

Where to Buy

BME280 Temperature and Humidity Sensor

Starting from

7$ per unit

Amazon com
Amazon.com Ships worldwide
View Price
Amazon de
Amazon.de Ships to EU
View Price
Aliexpress
AliExpress Best value
View Price

Prices are subject to change. We earn from qualifying purchases as an Amazon Associate.

Technical Specifications

Interface I2C (up to 3.4 MHz), SPI (3- and 4-wire, up to 10 MHz)
Accuracy ±3% RH (humidity), ±0.5 °C (temperature), ±1 hPa (pressure)
Operating Range -40°C to 85°C, 0 – 100% RH, 300 – 1100 hPa
Supply Voltage 1.71V to 3.6V for VDD, 1.2V to 3.6V for VDDIO
Current Consumption 1.8 µA @ 1 Hz (humidity + temp), 3.6 µA @ 1 Hz (humidity + pressure + temp)
Sleep Mode Current 0.1 µA
Response Time 1 second (humidity, τ63%)
Package Dimensions 2.5 mm x 2.5 mm x 0.93 mm (LGA)

Pinout Configuration

The VCC pin is used to supply power to the sensor, and it typically requires 3.3V or 5V (refer to the datasheet for specific voltage requirements). The GND pin is the ground connection and must be connected to the ground of your ESP32.

When using the I2C protocol, the sensor communicates via the SCL (clock) and SDA (data) pins. These pins connect to the respective clock and data lines of the microcontroller. The I2C protocol is efficient for minimal wiring, requiring only two data pins. For the SPI protocol, the sensor uses four pins: SCK (clock), SDI (MOSI), SDO (MISO), and CS (chip select). This setup provides higher data transfer speeds and is suitable for applications requiring fast and reliable communication. Both protocols also use VIN (or VCC) for power (typically 3.3V or 5V) and GND for grounding.

Wiring with ESP32

The GPIO pins for I2C communication with BME280 and ESP32 is as following:
  • SCK (SCL Pin): GPIO 22
  • SDI (SDA Pin): GPIO 21
The GPIO pins for SPI (Serial Peripheral Interface) communication with BME280 and ESP32 is as following:
  • SCK (SPI Clock): GPIO 18
  • SDO (MISO): GPIO 19
  • SDI (MOSI): GPIO 23
  • CS (Chip Select): GPIO 5

Troubleshooting Guide

Common Issues

🔍 I2C Sensor Found, but Could not find a valid BME280 sensor

🆔 Incorrect Sensor Identification

Debugging Tips

🔍 Serial Monitor

⚡ Voltage Checks

Code Examples

Arduino Example

C++
🔧

ESP-IDF Example

C++
🏠

ESPHome Example

YAML
🛠️

PlatformIO Example

C++
🐍

MicroPython Example

Python

Conclusion

The ESP32 BME280 Temperature and Humidity Sensor is a powerful environment sensor that offers excellent performance and reliability. With support for multiple development platforms including Arduino, ESP-IDF, ESPHome, PlatformIO, and MicroPython, it's a versatile choice for your IoT projects.

For optimal performance, ensure proper wiring and follow the recommended configuration for your chosen development platform.

Always verify power supply requirements and pin connections before powering up your project to avoid potential damage.