Chipkit and BME680 environmental sensor example

In this article we will connect a BME680 sensor to a Chipkit

BME680 is an integrated environmental sensor developed specifically for mobile applications and wearables where size and low power consumption are key requirements. Expanding Bosch Sensortec’s existing family of environmental sensors, the BME680 integrates for the first time high-linearity and high-accuracy gas, pressure, humidity and temperature sensors. The gas sensor within the BME680 can detect a broad range of gases to measure air quality for personal well being.

Gases that can be detected by the BME680 include Volatile Organic Compounds (VOC) from paints (such as formaldehyde), lacquers, paint strippers, cleaning supplies, furnishings, office equipment, glues, adhesives and alcohol.

Parameter Technical data
Package dimensions 8-Pin LGA with metal
3.0 x 3.0 x 0.93 mm³
Operation range (full accuracy) Pressure: 300…1100 hPa
Humidity 0…100%
Temperature: -40…85°C
Supply voltage VDDIO
Supply voltage VDD
1.2 … 3.6 V
1.71 … 3.6 V
Interface I²C and SPI
Average current consumption
(1Hz data refresh rate)
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 0.09‒12 mA for p/h/T/gas depending on operation mode
Average current consumption in sleep mode 0.15 μA
Gas sensor
Response time (τ 33-63%)
Sensor-to-sensor deviation
Power consumption
Output data processing
< 1 s (for new sensors)
+/- 15% +/- 15
< 0.1 mA in ultra-low power mode
direct output of IAQ: Index for Air Quality
Humidity sensor
Response time (τ0-63%)
Accuracy tolerance
Hysteresis
8 s
± 3 % relative humidity
≤ 1.5 % relative humidity
Pressure sensor
RMS Noise
Sensitivity Error
Temperature coefficient offset
0.12 Pa (equiv. to 1.7 cm)
± 0.25 % (equiv. to 1 m at 400 m height change)
±1.3 Pa/K (equiv. to ±10.9 cm at 1°C temperature change)

 

Parts List

I used a Chipkit MAX32

Name Link
Chipkit Max32 Digilent chipKIT Max32 Microcontroller Board with Mega R3 Headers – 410-202
BME680 BME680 Sensor Module Temperature and Humidity Air Pressure Air Quality IAQ MCU680 Module
Connecting wire Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire

Schematic

We use the I2C connection for the sensor

 

max32 and bme680

Code

You will need to import the adafruit sensor and bme680 libraries – you can add these using the library manager

My sensor used address 0x76, the default is 0x77 so you may have to change this line from if (!bme.begin(0x76)) to if (!bme.begin()) depending on the sensor you purchase

 

[codesyntax lang=”cpp”]

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


#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BME680 bme; // I2C

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

  if (!bme.begin(0x76)) 
  {
    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);
}

[/codesyntax]

 

Output

Open the serial monitor and you will see something like this

BME680 test
Temperature = 22.34 *C
Pressure = 1007.54 hPa
Humidity = 39.60 %
Gas = 0.00 KOhms
Approx. Altitude = 47.65 m

Temperature = 22.53 *C
Pressure = 1007.54 hPa
Humidity = 39.44 %
Gas = 29.29 KOhms
Approx. Altitude = 47.48 m

Temperature = 22.68 *C
Pressure = 1007.52 hPa
Humidity = 39.26 %
Gas = 0.00 KOhms
Approx. Altitude = 47.82 m

Related posts

Chipkit Max32 and ADXL335 accelerometer example

Chipkit Max32 and LSM303 Accelerometer example

Chipkit Max32 and LSM303 Magnetometer example

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Read More