The BME688 sensor is a four-in-one sensor that can measure temperature, humidity, pressure, and gas. It is a very popular sensor for use with Arduino & Raspberry Pi boards. In this tutorial, we will show you how to interface the BME688 sensor with an Arduino Using I2C connection.
This high-quality sensor can monitor every part of your environment, taking high-precision measurements of temperature, barometric pressure, and humidity &Â VOC gas sensing capabilities. All over SPI or I2C If you’re looking for something smaller, you might prefer the Bosch BME680.
Required components
- Arduino UNO
- BME688 Sensor Module
- OLED
- Jumper Wires
- Breadboard
BME688 Environmental Sensor with Artificial Intelligence
The BME688 is a special gas sensor that’s trained with Artificial Intelligence (AI) along with really accurate pressure, humidity, and temperature sensors. It’s packed into a tough but small 3.0 x 3.0 x 0.93 mm³ package. This sensor is developed for mobile and connected devices where being small and using very little power is important. It can pick up on things like Volatile Organic Compounds (VOCs), Volatile Sulfur Compounds (VSCs), and even gases like carbon monoxide and hydrogen, even in tiny amounts (parts per billion range).
The BME688, like the BME680 but with extra features, can scan for gases. It’s set up to spot things like volatile compounds, which can indicate things like bacteria. A tool called BME AI-Studio helps you teach the BME688 to recognize specific gases for things like home devices or smart systems.
Spescifications
Characteristic | Description |
---|---|
Operating Voltage | – VDD: 1.71V to 3.6V (Default on Qwiic System: 3.3V) |
– VDDIO: 1.2 to 3.6V | |
Operational Modes | – Sleep (Default) and Forced (low power; single measurement) |
– Parallel (Gas sensor heater operates alongside TPH measurement) | |
Interface | – I²C and SPI |
I²C Address | – BME680: 0x77 (Default) or 0x76 |
– BME688: 0x76 (Default) or 0x77 | |
Average Current Consumption | – 2.1 µA at 1 Hz humidity and temperature |
– 3.1 µA at 1 Hz pressure and temperature | |
– 3.7 µA at 1 Hz humidity, pressure, and temperature | |
– 90 µA at ULP mode for p/h/T & air quality | |
– 0.9 mA at LP mode for p/h/T & air quality | |
– 3.9 mA in standard gas scan mode | |
Humidity Parameters | – Range: 10 to 90 %RH |
– Absolute Accuracy: Âħ3 %RH (20 – 80 %RH) | |
– Resolution: 0.008 %RH | |
Pressure Parameters | – Range: 300 to 1100 hPa |
– Absolute Accuracy: Âħ0.6 hPa | |
– Resolution: 0.18 Pa | |
Temperature Parameters | – Range: 0°C to 65°C (32°F to 149°F) |
– Absolute Accuracy: Âħ(0.5 – 1.0)°C | |
– Resolution: 0.01°C | |
Gas Sensor Parameters | – F1 score for HâS scanning: 0.92 |
– Standard scan speed: 10.8 s / scan | |
– Sensor-to-sensor deviation: +/- 15% | |
– Output data processing: Index for Air Quality (IAQ), bVOC & COâ equivalents (ppm), Gas scan result (%), and more (refer to datasheets) |
BME688 Temperature, Humidity, Pressure, and Gas Sensor Module
The BME280 and BMP280 sensors designed by Bosch both are accurate. They can measure humidity with a precision of Âħ3%, barometric pressure within Âħ1 hPa, and temperature with Âħ1.0°C accuracy. Because they’re so good at measuring pressure, you can even use them as an accurate altimeter, with errors of just Âħ1 meter or less when estimating altitude based on pressure changes.
The BME688 goes a step differently by including a tiny MOX sensor. This technical sensor heats metal oxide and its resistance changes depending on the volatile organic compounds (VOCs) in the air. This means it can detect gases like Ethanol, Alcohol, and Carbon Monoxide, making it useful for air quality monitoring Systems.
It provides a single resistance value, indicating the overall VOC content, but it can’t distinguish between different gases or alcohols.
Schematic Diagram
Pinouts
Power Pins:
- VIN: Power supply (3V to 5V)
- GND: Ground
- 3Vo: Fixed 3.3V power supply
- VCC, Vin: Supplies power (Connect to Arduino’s 5V pin).
SPI Logic Pins:
- SDO: Data out from BME688.
- CS: Chip Select (input).
- SDI: Data into BME688.
- SCK: Clock (input).
For Multiple Sensors:
- Share SDI, SDO, and SCK pins.
- Assign each a unique CS pin.
I2C Logic Pins:
- ADDR: Can bridge pads change the I2C address
- SCK: Clock line (SCL)
- SDI: Data line (SDA)
Features & Specifications
- Sensor Type: Temperature, Humidity, Pressure, and Gas Sensor
- Integrated Circuit: Bosch BME688
- Temperature Measurement Range: -40°C to 85°C
- Temperature Measurement Accuracy: Âħ1°C
- Humidity Measurement Range: 10% to 90% Relative Humidity (RH)
- Humidity Measurement Accuracy: Âħ3%
- Pressure Measurement Range: 300 hPa to 1100 hPa
- Pressure Measurement Accuracy: Âħ1 hPa
- VOC Gas Measurement Range: 0 to 500 IAQ (Indoor Air Quality)
- Communication Interface: I2C Bus
- I2C Interface Address: 0x77
- Supply Voltage: 3V to 5V
- Connectors: STEMMA QT / Qwiic / Solder Fields (2.54 mm pitch)
- Mounting Holes: 4 pieces
- Board Dimensions: 25.5 x 17.6 x 4.6 mm
- Weight: 1.7 grams
Note: For accurate results, it’s important to calibrate the BME688 sensor against known reference sources due to its inherent variability, like all VOC/gas sensors.
For basic environmental sensing, the sensor will give you a general sense of trends and comparisons. We recommend running it continuously for 48 hours when you first get it to let it settle in. Later, run it for 30 minutes each time you use it. This helps the sensor become more accurate and consistent because it can behave differently when it’s new.
Applications
- Indoor Air Quality Monitoring: Detects VOCs and gases.
- Health and Well-being: Monitors personal comfort.
- Environmental Sensing: Measures temperature, humidity, and pressure.
- HVAC Systems: Controls heating and cooling.
- Smart Home Automation: Enhances home systems.
- IoT Devices: Provides data for connected devices.
- Navigation and Altitude: Improves GPS accuracy.
- Weather Forecasting: Supports weather prediction.
- Industrial Control: Monitors manufacturing environments.
- Safety and Security: Detects air quality changes.
- Automotive: Used in vehicles for climate and air quality.
- Consumer Electronics: Enhances devices like smartphones.
- Agriculture: Supports precision farming.
- Research and Development: Used in various scientific fields.
Interfacing BME688 Environmental Sensor with Arduino
1. I2C Wiring
BME288 Pin | Arduino Pin |
---|---|
VIN | 3.3V or 5V |
GND | GND |
SCK | A5 (or SCL) |
SDI | A4 (or SDA) |
Connect the VCC, GND, SDA & SCL pins of BME688 Sensor Module 5V, GND, A4 & A5 of Arduino respectively. You may use a breadboard for assembly and jumper wires for connections.
2. SPI Connections
BME688 sensor module | Arduino UNO |
Vin | 5V |
GND | GND |
SCK | D13 |
SDO | D12 |
SDI | D11 |
CS | D10 |
Example Code & Libraries
-
Install the required libraries:
Upload the below code to your Arduino board.
You can use any of the above circuits, either the I2C Wiring or the SPI Wiring. Then upload any of the codes as per the circuit diagram.
1. I2C Code For BME688 Arduino
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
#include <Wire.h> #include <Adafruit_Sensor.h> #include "Adafruit_BME680.h" #define SEALEVELPRESSURE_HPA (1013.25) Adafruit_BME680 bme; // Create a BME680 sensor object for I2C void setup() { Serial.begin(9600); while (!Serial); Serial.println(F("BME680 test")); // Check if the BME680 sensor is properly initialized if (!bme.begin()) { Serial.println("Could not find a valid BME680 sensor, check wiring!"); while (1); // Stay in a loop if the sensor is not found } // Configure sensor settings bme.setTemperatureOversampling(BME680_OS_8X); bme.setHumidityOversampling(BME680_OS_2X); bme.setPressureOversampling(BME680_OS_4X); bme.setIIRFilterSize(BME680_FILTER_SIZE_3); bme.setGasHeater(320, 150); // 320°C for 150 ms } void loop() { // Check if the BME680 sensor reading was successful if (!bme.performReading()) { Serial.println("Failed to perform reading :("); return; } // Display temperature in degrees Celsius Serial.print("Temperature = "); Serial.print(bme.temperature); Serial.println(" °C"); // Display pressure in hPa (hectopascals) Serial.print("Pressure = "); Serial.print(bme.pressure / 100.0); Serial.println(" hPa"); // Display humidity in percentage Serial.print("Humidity = "); Serial.print(bme.humidity); Serial.println(" %"); // Calculate Dew Point float dewPoint = bme.temperature - ((100 - bme.humidity) / 5); Serial.print("Dew Point = "); Serial.print(dewPoint); Serial.println(" °C"); // Display gas resistance in KOhms Serial.print("Gas = "); Serial.print(bme.gas_resistance / 1000.0); Serial.println(" KOhms"); // Calculate and display approximate altitude Serial.print("Approx. Altitude = "); Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA)); Serial.println(" m"); // Print a blank line for better readability Serial.println(); // Delay for 2 seconds before the next reading delay(2000); } |
2. SPI Code For BME688 Arduino
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
#include <SPI.h> #include <Wire.h> #include <Adafruit_Sensor.h> #include "Adafruit_BME680.h" // Define the BME680 sensor connections for SPI #define BME_CS 10 #define BME_SCK 13 #define BME_MISO 12 #define BME_MOSI 11 // Define the sea-level pressure for altitude calculations #define SEALEVELPRESSURE_HPA (1013.25) Adafruit_BME680 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // Create a BME680 sensor object for SPI void setup() { // Initialize the serial communication Serial.begin(9600); while (!Serial); // Print a message to indicate the start of the program Serial.println(F("BME680 test")); // Check if the BME680 sensor is connected if (!bme.begin()) { Serial.println("Could not find a valid BME680 sensor, check wiring!"); while (1); // Stay in a loop if the sensor is not found } // Set up sensor configurations bme.setTemperatureOversampling(BME680_OS_8X); bme.setHumidityOversampling(BME680_OS_2X); bme.setPressureOversampling(BME680_OS_4X); bme.setIIRFilterSize(BME680_FILTER_SIZE_3); bme.setGasHeater(320, 150); // 320°C for 150 ms } void loop() { // Check if the BME680 sensor reading was successful if (!bme.performReading()) { Serial.println("Failed to perform reading :("); return; } // Display temperature in degrees Celsius Serial.print("Temperature = "); Serial.print(bme.temperature); Serial.println(" °C"); // Display pressure in hPa (hectopascals) Serial.print("Pressure = "); Serial.print(bme.pressure / 100.0); Serial.println(" hPa"); // Display humidity in percentage Serial.print("Humidity = "); Serial.print(bme.humidity); Serial.println(" %"); // Calculate Dew Point float dewPoint = bme.temperature - ((100 - bme.humidity) / 5); Serial.print("Dew Point = "); Serial.print(dewPoint); Serial.println(" °C"); // Display gas resistance in KOhms Serial.print("Gas = "); Serial.print(bme.gas_resistance / 1000.0); Serial.println(" KOhms"); // Calculate and display approximate altitude Serial.print("Approx. Altitude = "); Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA)); Serial.println(" m"); // Print a blank line for better readability Serial.println(); // Delay for 2 seconds before the next reading delay(2000); } |
Working – BME688 Arduino
After uploading the code to the Arduino board, Open the Serial Monitor. You will see the following results.
The serial monitor displays temperature, pressure, humidity, dew point, Altitude, and gas resistance. The sensor can’t calculate the Index of Air Quality (IAQ) with the Adafruit BME680 Arduino Code, so you’ll need another library for IAQ calculation.
Conclusion
We’ve covered the BME680 sensor module and how to use it with an Arduino. This module features a MOX sensor designed to detect various Volatile Organic Compounds (VOCs). The BME688 is a great choice for applications where accurate environmental data is needed.