BME680 Environmental Sensor

View on Amazon
Overview
About BME680 Environmental Sensor
The BME680, developed by Bosch Sensortec, is an advanced environmental sensor capable of measuring gas (VOCs & air quality), temperature, pressure, and humidity. Its compact design and low power consumption make it ideal for smart homes, HVAC systems, and wearable devices.
⚡ Key Features
- 4-in-1 Sensing – Measures air quality (VOCs), temperature, humidity, and pressure.
- Air Quality Monitoring – Integrated gas sensor detects volatile organic compounds (VOCs).
- Low Power Consumption – Suitable for battery-powered applications.
- I²C & SPI Communication – Seamless integration with ESP32, Arduino, and microcontrollers.
With its multi-function sensing capabilities, the BME680 is a top choice for indoor air quality monitoring and environmental control applications. 🚀
Get Your BME680
Prices are subject to change. We earn from qualifying purchases as an Amazon Associate.
BME680 Specifications
Complete technical specification details for BME680 Environmental Sensor
📊 Technical Parameters
BME680 Pinout
The **BME680** supports both **I²C** and **SPI** with integrated air quality sensing:
Visual Pinout Diagram

Pin Types
Quick Tips
**Dual Protocol**: Supports both I²C and SPI,📡 **I²C Address**: 0x76 or 0x77,🌡️ **Temperature**: -40°C to +85°C
**Humidity**: 0-100% RH,🎚️ **Pressure**: 300-1100 hPa,💨 **Gas Sensor**: Detects VOCs and air quality
**IAQ Index**: Indoor Air Quality measurement,⚡ **Power**: 3.3V or 5V compatible,🎯 **Applications**: Air quality monitoring, HVAC, smart homes
Pin Descriptions
| Pin Name | Type | Description | Notes |
|---|---|---|---|
1 VIN | Power | Power input | 3.3V or 5V (depending on module) |
2 GND | Power | Ground connection | |
3 SDA/SCL | Communication | I²C data / clock | Connect to ESP32 GPIO21 (SDA) / GPIO22 (SCL) |
4 SCK | Communication | SPI clock (SPI mode only) | GPIO18 for SPI |
5 SDI/MOSI | Communication | SPI data in | GPIO23 for SPI |
6 SDO/MISO | Communication | SPI data out | GPIO19 for SPI |
7 CS | Communication | Chip select (SPI mode) | GPIO5 for SPI |
Wiring BME680 to ESP32
To interface the **BME680** with an **ESP32** using **I²C**:
Visual Wiring Diagram

Connection Status
Protocol

Pin Connections
| BME680 Pin | Connection | ESP32 Pin | Description |
|---|---|---|---|
1 VIN Required | 3.3V | Power supply | |
2 GND Required | GND | Ground | |
3 SDA Required | GPIO21 | I²C data line | |
4 SCL Required | GPIO22 | I²C clock line |
**I²C Address**: 0x76 or 0x77 (check with I²C scanner)
**Gas Sensor**: Requires heating element (sensor handles automatically)
**Power**: Use 3.3V for most modules
**Warm-up**: Gas sensor needs ~30 minutes for accurate readings
**Simple**: Only 4 wires for I²C mode
BME680 Troubleshooting
Common issues and solutions to help you get your sensor working
Common Issues
Issue: The BME680 sensor is not recognized on the I2C bus, resulting in errors such as: Could not find a valid BME680 sensor, check wiring!.
Possible causes include incorrect wiring, improper power supply, or incorrect I2C address configuration.
Solution: Verify that the sensor's SDA and SCL lines are correctly connected to the corresponding pins on the microcontroller. Ensure that the sensor is supplied with the appropriate voltage (3.3V or 5V, depending on the sensor's specifications). Use an I2C scanner to detect the sensor's address; if the sensor is not found, check for loose connections or potential damage to the sensor. Additionally, confirm that the correct I2C address is specified in your code, as some BME680 modules may use different default addresses.
Issue: The BME680 sensor intermittently fails to provide readings over the I2C interface, leading to runtime errors such as: RuntimeError: Failed to find BME680! Chip ID 0x0.
Possible causes include unstable electrical connections, insufficient power supply, or interference on the I2C bus.
Solution: Inspect all electrical connections for stability and ensure that solder joints are secure. Verify that the power supply meets the sensor's requirements and is free from significant noise or fluctuations. Consider adding pull-up resistors to the SDA and SCL lines if they are not already present, as these are essential for proper I2C communication. Additionally, ensure that the I2C bus is not overloaded with too many devices, which can cause communication issues.
Issue: When compiling code that interfaces with the BME680 sensor, errors such as: invalid conversion from 'int' to 'SPIClass*' occur.
Possible causes include outdated or incompatible library versions, or incorrect library usage in the code.
Solution: Ensure that the latest version of the BME680 library is installed and compatible with your development environment. Review the library's documentation to confirm proper usage and initialization in your code. If the issue persists, consider seeking assistance from the library's support resources or community forums.
Issue: The BME680 sensor reports temperature readings higher than the actual ambient temperature, potentially due to self-heating effects from nearby components.
Possible causes include the sensor being placed too close to heat-generating components, such as microcontrollers or voltage regulators.
Solution: Position the sensor away from components that emit heat to prevent thermal interference. Implement proper ventilation around the sensor to allow accurate ambient temperature measurements. If necessary, use physical barriers or enclosures to shield the sensor from external heat sources.
Debugging Tips
Use the Serial Monitor to check for error messages and verify the sensor's output. Add debug prints in your code to track the sensor's state.
Use a multimeter to verify voltage levels and check for continuity in your connections. Ensure the power supply is stable and within the sensor's requirements.
Additional Resources
BME680 Programming Examples
Ready-to-use code examples for different platforms and frameworks
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME680.h>
Adafruit_BME680 bme;
void setup() {
Serial.begin(115200);
if (!bme.begin(0x76)) {
Serial.println("Could not find a valid BME680 sensor, check wiring!");
while (1);
}
bme.setTemperatureOversampling(BME680_OS_8X);
bme.setHumidityOversampling(BME680_OS_2X);
bme.setPressureOversampling(BME680_OS_4X);
bme.setGasHeater(320, 150); // 320*C for 150 ms
}
void loop() {
if (!bme.performReading()) {
Serial.println("Failed to perform reading :(");
return;
}
Serial.print("Temperature = "); Serial.print(bme.temperature); Serial.println(" *C");
Serial.print("Pressure = "); Serial.print(bme.pressure / 100.0); Serial.println(" hPa");
Serial.print("Humidity = "); Serial.print(bme.humidity); Serial.println(" %");
Serial.print("Gas = "); Serial.print(bme.gas_resistance / 1000.0); Serial.println(" KOhms");
delay(2000);
}This Arduino code initializes the BME680 sensor and configures it for temperature, humidity, pressure, and gas readings. Oversampling settings are used to improve data accuracy. The loop() function reads sensor data every two seconds and outputs the values to the Serial Monitor. The setGasHeater function configures the gas sensor for VOC detection.
#include "bme680.h"
#include "esp_log.h"
#define I2C_MASTER_SCL_IO 22
#define I2C_MASTER_SDA_IO 21
#define I2C_MASTER_FREQ_HZ 100000
#define BME680_ADDR 0x76
static const char *TAG = "BME680";
void app_main() {
ESP_LOGI(TAG, "Initializing BME680...");
bme680_dev dev;
bme680_init(&dev, I2C_MASTER_SCL_IO, I2C_MASTER_SDA_IO, I2C_MASTER_FREQ_HZ, BME680_ADDR);
while (1) {
bme680_data data;
bme680_read(&dev, &data);
ESP_LOGI(TAG, "Temperature: %.2f°C", data.temperature);
ESP_LOGI(TAG, "Pressure: %.2f hPa", data.pressure);
ESP_LOGI(TAG, "Humidity: %.2f%%", data.humidity);
ESP_LOGI(TAG, "Gas Resistance: %.2f KOhms", data.gas_resistance);
vTaskDelay(2000 / portTICK_PERIOD_MS);
}
}This ESP-IDF code configures the ESP32 to interface with the BME680 sensor over I2C. The bme680_init function initializes the sensor. In the app_main() loop, the sensor's environmental data (temperature, pressure, humidity, and gas resistance) is read and logged to the console every two seconds.
sensor:
- platform: bme680
temperature:
name: "BME680 Temperature"
pressure:
name: "BME680 Pressure"
humidity:
name: "BME680 Humidity"
gas_resistance:
name: "BME680 Gas Resistance"
address: 0x76This ESPHome configuration integrates the BME680 sensor. It creates sensor entities for temperature, pressure, humidity, and gas resistance, which are monitored via the I2C address 0x76. The setup is ideal for home automation and IoT systems.
platformio.ini
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
adafruit/Adafruit BME680 Library
wire
monitor_speed = 115200main.cpp
#include <Wire.h>
#include "Adafruit_BME680.h"
Adafruit_BME680 bme;
void setup() {
Serial.begin(115200);
if (!bme.begin()) {
Serial.println("Could not find a valid BME680 sensor, check wiring!");
while (1);
}
bme.setTemperatureOversampling(BME680_OS_8X);
bme.setHumidityOversampling(BME680_OS_2X);
bme.setPressureOversampling(BME680_OS_4X);
bme.setGasHeater(320, 150);
}
void loop() {
if (bme.performReading()) {
Serial.printf("Temp: %.2f*C, Pressure: %.2fhPa, Humidity: %.2f%%, Gas: %.2f KOhms\n",
bme.temperature, bme.pressure / 100.0, bme.humidity, bme.gas_resistance / 1000.0);
}
delay(2000);
}This PlatformIO code integrates the Adafruit BME680 library for reading environmental data from the sensor. Temperature, humidity, pressure, and gas readings are fetched and printed to the Serial Monitor every two seconds.
from machine import I2C, Pin
from bme680 import BME680_I2C
# Initialize I2C
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
# Initialize BME680
bme = BME680_I2C(i2c=i2c)
while True:
print(f"Temperature: {bme.temperature:.2f} °C")
print(f"Pressure: {bme.pressure:.2f} hPa")
print(f"Humidity: {bme.humidity:.2f} %")
print(f"Gas: {bme.gas:.2f} KOhms")
sleep(2)This MicroPython code initializes the BME680 sensor using I2C. The sensor reads temperature, pressure, humidity, and gas values, which are printed to the console every two seconds.
Wrapping Up BME680
The ESP32 BME680 Environmental 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.
Best Practices
For optimal performance, ensure proper wiring and follow the recommended configuration for your chosen development platform.
Safety First
Always verify power supply requirements and pin connections before powering up your project to avoid potential damage.
Ready to Start Building?
Now that you have all the information you need, it's time to integrate the BME680 into your ESP32 project and bring your ideas to life!








