BME680 Arduino

Last Updated on March 16, 2024

Sensing Gas, Pressure, Temperature and Humidity requires different individual sensors so far but from now you don’t need bunch of sensors to measure the environment factors yes here is the solution from Bosch BME680 Sensor. This sensor will measure gas, pressure, temperature and humidity by consuming low power and also very tiny. BME680 Arduino interfacing is very easy to do and the breakout board from adafruit makes it simple.




This sensor on breakout board can be connected to the Arduino or other microcontrollers through I²C Communication. This sensor also supports SPI communication. In this tutorial BME680 breakout board is connected with Arduino through I²C method and tested with BME680 arduino library from adafruit.

BME680 Arduino Interface

 

Connect the breakout board and arduino board as shown in diagram, here four wire is enough to Interface Arduino and BME680, connect 3.3V to VIN pin and GND to GND then connect A4 (SDA) pin of Arduino to SDI pin of breakout board then A5 (SCL) pin of Arduino to SCK pin of sensor breakout board.

In this tutorial Arduino UNO board is used so A4 is SDA & A5 is SCL refer your Arduino board I²C pins before proceed.

BME680

This sensor comes with 8-pin metal lid 3.0 x 3.0 x 0.95 mm³ LGA package and it detects broad range of gases to measure indoor air quality. Interestingly this sensor can detect Volatile Organic Compounds (VOC) from paints (such as formaldehyde), lacquers, paint strippers, cleaning supplies, furnishings, office equipment, glues, adhesives and alcohol.

Breakout Board

BME680 Sensor Breakout board from Adafruit has I²C and SPI communication terminals, hence it can easily interfaced with microcontrollers.

Arduino Code

BME680 Arduino test code to receive all Information gathered by sensor. This is from example of Adafruit BME680 library.

/*************************************************************************** This is a library for the BME680 gas, humidity, temperature & pressure sensor Designed specifically to work with the Adafruit BME680 Breakout
  ----> http://www.adafruit.com/products/3660     These sensors use I2C or SPI to communicate, 2 or 4 pins are required to interface. Adafruit invests time and resources providing this open source code,  Written by Limor Fried & Kevin Townsend for Adafruit Industries.
  BSD license, all text above must be included in any redistribution
 ***************************************************************************/

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_BME680.h"

#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10

#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BME680 bme; // I2C
//Adafruit_BME680 bme(BME_CS); // hardware SPI
//Adafruit_BME680 bme(BME_CS, BME_MOSI, BME_MISO,  BME_SCK);

void setup() {
  Serial.begin(9600);
  while (!Serial);
  Serial.println(F("BME680 test"));

  if (!bme.begin()) {
    Serial.println("Could not find a valid BME680 sensor, check wiring!");
    while (1);
  }

  // Set up oversampling and filter initialization
  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() {
  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");

  Serial.print("Approx. Altitude = ");
  Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
  Serial.println(" m");

  Serial.println();
  delay(2000);
}




Leave a Reply

Your email address will not be published. Required fields are marked *