How To: BME680

by JackSoldano in Circuits > Sensors

1283 Views, 1 Favorites, 0 Comments

How To: BME680

BME680 Module.jpg

The goal of this guide is to demonstrate how to setup & use the BME680 Module with an Arduino in the most simple way possible!

Supplies


To replicate my example you will need...

  1. BME680 Sensor Module (Almost all variants of the BME680 module should work the same or similar)
  2. Arduino Nano
  3. Breadboard
  4. Jumper Wires
  5. Arduino IDE

What Is the BME680 Sensor?

Untitled-1.jpg
BME680 Tech data.PNG

The BME680 module is a powerful 4-in-1 sensor that can measure,

- Temperature

- Relative Humidity

- Barometric Pressure

- Gas (VOC: Volatile Organic Compounds such as Ethanol & Carbon Monoxide)

The BME680 sensor can communicate with either I2C or SPI at a logic level of 3V3.

The Adafruit BME680 shield uses an onboard regulator to step down a 5V supply to 3V3 and logic level shifts the communication line so that it can work with an Arduino's 5V logic output. (Shown below in the schematic of the module)

See the attached datasheet for BME680 sensor accuracy and specifications.

How to Wire Up

BME680 Arduino Connections.PNG
IMG_20220917_225231.jpg

As the BME680 module can be used in either I2C or SPI communication modes we have 2 options for wiring up the module. The I2C option uses only 4 wires so we will use that to demonstrate the functionality of the module.

Code & Test

Arduino IDE Navigate to Libs.PNG
BME680 LIB.PNG
Capture.PNG

Before you can program the Arduino, you will need to get the Adafruit BME680 Library, to do so first open the Library Manager as shown below,


In the Library Manager search for "adafruit bme680" and install the latest version.


The Arduino code I used to test out the BME680 module can be found below, download the BME680_Demo.ino attached, and program your arduino with it via the IDE.


You should then be able to see the BME680 output all its readings every second.


Note that if you want to use the SPI interface you need to remove the comment outs around SPI comms and ensure you have followed the wire diagram correctly.

Downloads

Additional Comments

When reviewing the code you will likely have a few questions,

These answers have all come from the Bosch datasheet for the BME680 found here - https://community.bosch-sensortec.com/t5/Knowledge-base/BME680-Sensor-Data-Interpretation/ta-p/8713


What is "SEALEVELPRESSURE_HPA"?

  • This is a float that is used to "Calibrate" the BME680 sensors reference to sea level pressure
  • This value is measured in milibar.


How to use SPI?

 * Default Definitions

#define BME_SCK 13 //SCL

#define BME_MISO 12 //SDO

#define BME_MOSI 11 //SDA

#define BME_CS 10  //CS

 * My example SPI pins

#define BME_SCK 7 //SCL

#define BME_MISO 5 //SDO

#define BME_MOSI 6 //SDA

#define BME_CS 4  //CS


  • Remove the comment from "Adafruit_BME680 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI"
  • Double check your BME_SCK, BME_MISO, BME_MOSI & BME_CS pins are defined correctly


What are these Oversampling lines?

bme.setTemperatureOversampling(BME680_OS_8X);

bme.setHumidityOversampling(BME680_OS_2X);

bme.setPressureOversampling(BME680_OS_4X);

  • These are ways to effectively increase sample time, which can remove noise at the cost of increased power consumption. The values above are default.


What is the IIR Filter?

bme.setIIRFilterSize(BME680_FILTER_SIZE_3);

  • The IIR Filter is used to remove short fluctuations in pressure from readings which can occur when doors / windows are open or shut.


What code gets the data out of the BME sensor?

Note that all of these commands return float values, so make sure any variables used to store this data can support decimal points.

bme.temperature: returns temperature reading

bme.pressure: returns pressure reading

bme.humidity: returns humidity reading

bme.gas_resistance: returns gas resistance

These commands will only return the last measured value, to make the BME sensor take a reading you need to first send this command.

bme.performReading();

Thanks for Reading

I hope this short guide has been helpful, if you have any questions please leave a comment or direct message me!