Is code available to read a Bosch BME688 with a Seeeduino ESP32C3?

Greetings,

I have been working on this for a week with nothing to show for it. I am wondering if some kind soul out there can throw me a lifeline?

I am trying to interface a BME688 with an ESP32C3 and failing miserably. I am working in the Arduino IDE and even the examples given under bsec2 fail to compile. I CAN compile and run code for the BME680 and it works with the BME688 (backwards compatible) but only displays gas resistance for the VOC section and I am seeking AQI readings using the AI in the BME688.

I was told that the example code was based on v2 and that the current Seeeduino ESP32C3 is a v3 device. Is this so and should this make a difference?

So, if anyone can direct me to a basic C++ code that enables the ESP32C3 to interact with the BME688, I would be eternally grateful (or, at least, for many days;). Thank you.

Hi there,

WOW, shouldn’t take that long man… :grin:

Just be sure to Before running the code, make sure you install:

  • Adafruit BME680 Library (works for BME688)
  • Adafruit Unified Sensor Library

In Arduino IDE:

  1. Go to Tools → Manage Libraries.
  2. Search for “Adafruit BME680” and install it.
  3. Search for “Adafruit Unified Sensor” and install it.
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME680.h>

#define SEALEVELPRESSURE_HPA (1013.25)  // Adjust for your location

Adafruit_BME680 bme;  // Create sensor object

void setup() {
    Serial.begin(115200);
    while (!Serial); // Wait for serial monitor

    Wire.begin(); // Initialize I2C

    if (!bme.begin(0x76)) {  // Default I2C address for BME688
        Serial.println("BME688 not found! Check wiring.");
        while (1);
    }

    // Set oversampling rates and gas heater 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 150ms

    Serial.println("BME688 initialized!");
}

void loop() {
    Serial.println("Reading BME688 data...");

    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 Resistance: ");
    Serial.print(bme.gas_resistance);
    Serial.println(" ohms");

    Serial.println("--------------------");
    delay(2000); // Wait 2 seconds before next read
}

How This Works

  • Reads Temperature, Pressure, Humidity, and Gas Resistance from the BME688.
  • Uses I2C (Wire.begin()) for communication.
  • Adjustable gas heater settings to fine-tune gas readings.

HTH
GL :slight_smile: PJ :v:

I would start there and then push further. :+1: be mindful of the BSP used as well.

next is :crossed_fingers:
To enable AI-powered sensing, you need to use the BSEC library instead of the standard BME680/BME688 driver.

Step 1: Install Bosch BSEC Library

  1. Download BSEC 2.4.0 (or latest) for ESP32C3 from Bosch Sensortec GitHub

  2. Copy the library into your Arduino libraries folder.

  3. Restart Arduino IDE. did you do this step ?

  4. Load the AI-based BSEC Example Code

#include <Wire.h>
#include "bsec.h"

Bsec iaqSensor;

void setup() {
    Serial.begin(115200);
    Wire.begin();

    // Initialize BSEC library
    iaqSensor.begin(BME68X_I2C_ADDR_HIGH, Wire);

    // Load standard BSEC configuration
    bsec_virtual_sensor_t sensorList[] = {
        BSEC_OUTPUT_IAQ, BSEC_OUTPUT_CO2_EQUIVALENT, BSEC_OUTPUT_BREATH_VOC_EQUIVALENT
    };
    
    iaqSensor.updateSubscription(sensorList, 3, BSEC_SAMPLE_RATE_LP);
    
    Serial.println("BME688 AI-based air quality detection started.");
}

void loop() {
    if (iaqSensor.run()) {
        Serial.print("IAQ: ");
        Serial.print(iaqSensor.iaq);
        Serial.print(" | eCO2: ");
        Serial.print(iaqSensor.co2Equivalent);
        Serial.print(" ppm | bVOC: ");
        Serial.print(iaqSensor.breathVocEquivalent);
        Serial.println(" ppm");
    } else {
        Serial.println("BSEC data read failed!");
    }

    delay(3000);
}

What This Code Does

  • Uses BSEC AI to analyze gas data.
  • Provides Indoor Air Quality (IAQ) score (0-500).
  • Estimates CO2-equivalent (eCO2 in ppm) and VOC-equivalent (bVOC in ppm).

AI-Based Outputs

AI Output Meaning
IAQ (0-500) Air Quality Score (0 = clean, 500 = polluted)
eCO2 (ppm) Estimated CO2 level in indoor air
bVOC (ppm) Breath VOC detection (volatile organic compounds)

Any custom gas training needs to use the Bosch AI studio BTW :v: to train the AI model.
All the info is on there web site.

HTH
GL :slight_smile: PJ :v:

if you get no data, you may need to heat it longer(preheat)

1 Like

Since you are using the BME688 and seeeduino ESP32C3, you may find this tutorial helpful. Teapotlabs Plantpal: Your pal in plant care! - Share Project - PCBWay
This project uses BME688 and ESP32-C6FH4. It is a good device to monitor soil moisture and surrounding environments, ensuring your plants thrive in optimal conditions! Its low-power e-paper display keeps you updated without draining energy. Plus, with the BME688 sensor, it is able to monitor air quality and CO2 levels, ensuring your plants thrive in optimal conditions.