Introduction

BME680 is a 4-in-1 multi-functional MEMS environmental sensor which integrates VOC (Volatile Organic Compounds) sensor, temperature sensor, humidity sensor and barometer. It is designed for air quality monitor, and due to the MEMS technology, BME680 has a small size and low power consumption. It can be widely used in environmental monitoring, home automation and control, Internet of Things (IoT) wearable device, GPS enhancement, etc.

This BME680 Sensor adopts more simplified breakout design and leads out pitch 2.54 pin/female header and SPI connector. And it has onboard voltage regulator IC and I2C level translator circuit, which makes this sensor more convenient to be integrated into various applications.

With the development of industrialization, air pollution is getting worse and worse. Toxic chemical odors are even common with new furniture. These invisible killers are destroying your health day by day. You do need to concern about your health as soon as possible and this DFRobot Breakout BME680 environmental sensor can help you make an air quality monitor so as to take good care of your health!

Specification

  • Input Voltage: 3.3V~5.5V
  • Operating Current: 5mA (25mA in VOC Measurement)
  • Communication Interface: I2C(3.3/5V Compatible)
  • Connector in Reserve: SPI(only support 3.3V)
  • Default I2C Address: 0x76
  • Temperature Measurement Range: -40℃~+85℃
  • Temperature Measurement Precision: ±1.0℃(0~65℃)
  • Humidity Measurement Range: 0-100%r.H.
  • Humidity Measurement Precision: ±3%r.H.(20-80% r.H.,25℃)
  • Atmospheric Pressure Measurement Range: 300-1100hPa
  • Atmospheric Pressure Measurement Precision: ±0.6hPa(300-1100hPa,0~65℃)
  • IAQ (Indoor Air Quality) Range: 0~500 (the larger, the worse)
  • Dimension: 18×15.6(mm) /0.71x0.61(inches)

IAQ(Indoor Air Quality)

IAQ

Board Overview

Board Overview

Silkscreen Name Function
+ VCC 3.3~5.5V
- GND GND
C SCL I2C-SCL
D SDA I2C-SDA

Dimension

Dimension

Tutorial

This tutorial will demonstrate how to use this sensor. Currently, only FireBeetle ESP8266 IOT Microcontroller can read IAQ values.

Requirements

Connection Diagram

  • This product supports both IIC and SPI wiring connector. Please select suitable connector according to the wiring. There is connection diagram below for your reference.
  • I2C wiring connector is recommended, since it is plug & play and easy to use.
  • When using SPI connector, then you should use 3.3V controller(Both Power and IO port should be 3.3V).

I2C Connection: please pay attention to wiring order, VCC to Power, GND to Ground.

Connection Diagram

Sample Code

Download and install the BME680 Library. This sample code is based on IIC connector. For SPI Sample code, Please check file: DFRobot_BME680_SPI.ino in the library file. Since same functions can be realized in both way, we only provide you with I2C sample code. Calibration is needed for more accurate altitude measurement. Please fill in the sample code with correct local altitude value: seaLevel = bme.readSeaLevel(your correct local altitude value).

Data Reading(without IAQ)

Function: read data from BME680 sensor and serial printing(without IAQ).

/*
       file DFRobot_BME680_I2C.ino

       @ https://github.com/DFRobot/DFRobot_BME680

       connect bme680 I2C interface with your board (please reference board compatibility)

       Temprature, Humidity, pressure, altitude, calibrate altitude and gas resistance data will print on serial window.

       Copyright   [DFRobot](http://www.dfrobot.com), 2016
       Copyright   GNU Lesser General Public License

       version  V1.0
       date  2017-12-7
*/

#include "DFRobot_BME680_I2C.h"
#include "Wire.h"

/*use an accurate altitude to calibrate sea level air pressure*/
#define CALIBRATE_PRESSURE

DFRobot_BME680_I2C bme(0x76);  //0x77 I2C address

float seaLevel;
void setup()
{
  uint8_t rslt = 1;
  Serial.begin(9600);
  while (!Serial);
  delay(1000);
  Serial.println();
  while (rslt != 0) {
    rslt = bme.begin();
    if (rslt != 0) {
      Serial.println("bme begin failure");
      delay(2000);
    }
  }
  Serial.println("bme begin successful");
#ifdef CALIBRATE_PRESSURE
  bme.startConvert();
  delay(1000);
  bme.update();
  /*You can use an accurate altitude to calibrate sea level air pressure.
    And then use this calibrated sea level pressure as a reference to obtain the calibrated altitude.
    In this case,525.0m is chendu accurate altitude.
  */
  seaLevel = bme.readSeaLevel(525.0);
  Serial.print("seaLevel :");
  Serial.println(seaLevel);
#endif
}

void loop()
{
  bme.startConvert();
  delay(1000);
  bme.update();
  Serial.println();
  Serial.print("temperature(C) :");
  Serial.println(bme.readTemperature() / 100, 2);
  Serial.print("pressure(Pa) :");
  Serial.println(bme.readPressure());
  Serial.print("humidity(%rh) :");
  Serial.println(bme.readHumidity() / 1000, 2);
  Serial.print("gas resistance(ohm) :");
  Serial.println(bme.readGasResistance());
  Serial.print("altitude(m) :");
  Serial.println(bme.readAltitude());
#ifdef CALIBRATE_PRESSURE
  Serial.print("calibrated altitude(m) :");
  Serial.println(bme.readCalibratedAltitude(seaLevel));
#endif
}

Data Reading(with IAQ)

Function: read data from BME680 sensor and serial printing(with IAQ). At present, only FireBeetle ESP8266 IOT Microcontroller can read IAQ. For FireBeetle ESP8266 IOT Microcontroller,please use Arduino IDE 1.8.x. Then update the SDK to 2.3.1 or above. Refer to the FireBeetle ESP8266 Wiki.

/*
       file DFRobot_BME680_I2C.ino

       @ https://github.com/DFRobot/DFRobot_BME680

       connect bme680 I2C interface with your board (please reference board compatibility)

       Temprature, Humidity, pressure, altitude, calibrated altitude, gas resistance and IAQ data will be printed via serial.

       Copyright   [DFRobot](http://www.dfrobot.com), 2016
       Copyright   GNU Lesser General Public License

       version  V1.0
       date  2017-12-7
*/

#include "DFRobot_BME680_I2C.h"
#include "Wire.h"

/*use an accurate altitude to calibrate sea level air pressure*/
#define CALIBRATE_PRESSURE

DFRobot_BME680_I2C bme(0x76);  //0x77 I2C address


float seaLevel;
void setup()
{
  uint8_t       rslt = 1;
  Serial.begin(115200);
  while (!Serial);
  delay(1000);
  Serial.println();
  while (rslt != 0) {
    rslt = bme.begin();
    if (rslt != 0) {
      Serial.println("bme begin failure");
      delay(2000);
    }
  }
  Serial.println("bme begin successful");
  bme.supportIAQ();
}

void loop()
{
  static uint8_t       calibrated = 0;

#ifdef CALIBRATE_PRESSURE
  if (calibrated == 0) {
    if (bme.iaqUpdate() == 0) {
      /*You can use an accurate altitude to calibrate sea level air pressure.
        And then use this calibrated sea level pressure as a reference to obtain the calibrated altitude.
        In this case,525.0m is chendu accurate altitude.
      */
      seaLevel = bme.readSeaLevel(525.0);
      Serial.print("seaLevel :");
      Serial.println(seaLevel);
      calibrated = 1;
    }
  }
#else
  calibrated = 1;
#endif

  if (calibrated) {
    uint8_t rslt = bme.iaqUpdate();
    if (rslt == 0) {
      Serial.println();
      Serial.print("timestamp(ms) :");
      Serial.println(millis());
      Serial.print("temperature(C) :");
      Serial.println(bme.readTemperature(), 2);
      Serial.print("pressure(Pa) :");
      Serial.println(bme.readPressure());
      Serial.print("humidity(%rh) :");
      Serial.println(bme.readHumidity(), 2);
      Serial.print("altitude(m) :");
      Serial.println(bme.readAltitude());
#ifdef CALIBRATE_PRESSURE
      Serial.print("calibrated altitude(m) :");
      Serial.println(bme.readCalibratedAltitude(seaLevel));
#endif
      Serial.print("gas resistance :");
      Serial.println(bme.readGasResistance());
      if (bme.isIAQReady()) {
        Serial.print("IAQ :");
        float iaq = bme.readIAQ();
        Serial.print(iaq);
        if (iaq < 50) Serial.println(" good");
        else if (iaq < 100) Serial.println(" average");
        else if (iaq < 150) Serial.println(" little bad");
        else if (iaq < 200) Serial.println(" bad");
        else if (iaq < 300) Serial.println(" worse");
        else Serial.println(" very bad");
      } else {
        Serial.print("IAQ not ready, please wait about ");
        Serial.print((int)(305000 - millis()) / 1000);
        Serial.println(" seconds");
      }
    }
  }
}

Expected Results

  • Without IAQ

Result 1

  • With IAQ

Result 2

Arduino Library Function List

  • Create a bme object and write to IIC address.
DFRobot_BME680_I2C bme(0x77);
  • Initialize BME680 and library
begin();
  • Start data converting
startConvert();
  • Read converted data
update();
  • support reading the IAQ
supportIAQ();
  • Start data converting with IAQ
iaqUpdate();
  • Query whether the IAQ conversion is complete. If Completed return 1, else return 0.
isIAQReady();
  • Get temperature data, unit of ℃, precision of 0.01℃
readTemperature();
  • Get atmosphere pressure, unit of pa, precision of 0.01pa
readPressure();
  • Get humidity, unit of %rh, precision of 0.01%rh
readHumidity();
  • Get resistance value of gas-resistance, unit of ohm, precision of 0.01ohm
readGasResistance();
  • Get altitude, unit of m, precision of 0.01m
readAltitude();
  • Get sea level atmosphere pressure reference value and send altitude data
readSeaLevel(float altitude);
  • Get calibrated altitude value and send atmosphere pressure reference value
readCalibratedAltitude(float seaLevel);

Compatibility Test

MCU Pass Fail Untested Note
FireBeetle-Board328P Do Not Support IAQ
FireBeetle-ESP32 Do Not Support IAQ
FireBeetle-ESP8266 Support IAQ
Leonardo Do Not Support IAQ

FAQ

For any questions, advice or cool ideas to share, please visit the DFRobot Forum.

More Documents