Skip to content

BME68X Gas Sensor

Overview

The BME68X Gas Sensor sample sets up the BME68X gas sensor with the Bosch Sensor Environmental Cluster (BSEC) library.

Here is the overlay file which supports this sample.

nrf54l15_connectkit_nrf54l15_cpuapp.overlay
&pinctrl {
    i2c22_default: i2c22_default {
        group1  {
            psels = <NRF_PSEL(TWIM_SCL, 1, 8)>,
                    <NRF_PSEL(TWIM_SDA, 1, 9)>;
        };
    };

    i2c22_sleep: i2c22_sleep {
        group1  {
            psels = <NRF_PSEL(TWIM_SCL, 1, 8)>,
                    <NRF_PSEL(TWIM_SDA, 1, 9)>;
            low-power-enable;
        };
    };
};

&i2c22 {
    status = "okay";
    zephyr,concat-buf-size = <512>;
    pinctrl-0 = <&i2c22_default>;
    pinctrl-1 = <&i2c22_sleep>;
    pinctrl-names = "default", "sleep";

    bme688: bme688@76 {
        compatible = "bosch,bme680";
        status = "okay";
        reg = <0x76>;
    };
};

Requirements

Before you start, check that you have the required hardware and software:

Wiring the sensor

Refer to the following figure for proper BME688 sensor connection to the nRF54L15 Connect Kit before applying power.

Building the sample

To build the sample, follow the instructions in Getting Started Guide to set up your preferred building environment.

You can use the BME68X IAQ driver to run the Bosch Sensor Environmental Cluster (BSEC) library in order to get Indoor Air Quality (IAQ) readings.

The BSEC library is distributed with a Bosch proprietary license (BSEC license) that prevents it from being part of nRF Connect SDK. To start using it, you have to accept the license and enable the download by running the following commands in the nrf folder:

west config manifest.group-filter +bsec
west update

Use the following steps to build the BME68X Gas Sensor sample on the command line.

  1. Open a terminal window.

  2. Go to NCS-Project/nrf54l15-connectkit repository cloned in the Getting Started Guide.

  3. Build the sample using the west build command, specifying the board (following the -b option) as nrf54l15_connectkit/nrf54l15/cpuapp.

    west build -p always -b nrf54l15_connectkit/nrf54l15/cpuapp samples/sensor/bme68x_iaq
    

    Tip

    The -p always option forces a pristine build, and is recommended for new users. Users may also use the -p auto option, which will use heuristics to determine if a pristine build is required, such as when building another sample.

  4. After building the sample successfully, the firmware with the name merged.hex can be found in the build directory.

Flashing the firmware

Connect the nRF54L15 Connect Kit to the computer with a USB-C cable:

Then flash the sample using west flash:

west flash

Tip

In case you wonder, the west flash will execute the following command:

pyocd load --target nrf54l --frequency 4000000 build/merged.hex

Testing

After programming the sample, test it by performing the following steps:

  1. Open up a serial terminal, specifying the primary COM port that your computer uses to communicate with the nRF54L15:

    1. Start PuTTY.
    2. Configure the correct serial port and click Open:

    Open up a terminal and run:

    screen <serial-port-name> 115200
    

    Open up a terminal and run:

    screen <serial-port-name> 115200
    
  2. Press the DFU/RST button to reset the nRF54L15.

  3. Observe the output of the terminal. You should see the output, similar to what is shown in the following:

    Terminal
    *** Booting nRF Connect SDK v3.1.0-6c6e5b32496e ***
    *** Using Zephyr OS v4.1.99-1612683d4010 ***
    [00:00:00.019,106] <inf> app: App started
    [00:00:06.044,229] <inf> app: temp: 29.605730; press: 99450.281250; humidity: 73.636467; iaq: 50; CO2: 500.000000; VOC: 0.499999
    [00:00:09.044,289] <inf> app: temp: 28.835971; press: 99446.812500; humidity: 76.732482; iaq: 50; CO2: 500.000000; VOC: 0.499999
    [00:00:12.044,412] <inf> app: temp: 28.715774; press: 99448.398437; humidity: 77.680435; iaq: 50; CO2: 500.000000; VOC: 0.499999
    [00:00:15.044,503] <inf> app: temp: 28.667188; press: 99448.679687; humidity: 78.038581; iaq: 50; CO2: 500.000000; VOC: 0.499999
    [00:00:18.044,594] <inf> app: temp: 28.593027; press: 99448.296875; humidity: 78.303268; iaq: 50; CO2: 500.000000; VOC: 0.499999
    [00:00:21.044,701] <inf> app: temp: 28.562335; press: 99448.992187; humidity: 78.380111; iaq: 50; CO2: 500.000000; VOC: 0.499999
    [00:00:24.044,839] <inf> app: temp: 28.523975; press: 99451.179687; humidity: 78.461883; iaq: 50; CO2: 500.000000; VOC: 0.499999
    ...
    

    Note

    BSEC takes about 24 hours to calibrate the indoor air quality (IAQ) output.