Gravity__I2C_BME680_Environmental_Sensor__VOC,_Temperature,_Humidity,_Barometer__SKU__SEN0248-DFRobot

Introduction

DFRobot's BME680 Environmental Sensor is a low power gas, pressure, temperature & humidity sensor based on BOSCH BME680 sensor. It is a 4-in-1 multi-functional MEMS environmental sensor which integrates VOC (Volatile Organic Compounds) sensor, temperature sensor, humidity sensor and barometer.

With DFRobot Gravity BME680 Environmental Sensor, you can monitor 4 environmental parameters simultaneously. It is designed for air quality monitor systems, and due to the MEMS technology the 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.

DFRobot Gravity BME680 environmental sensor provides a Gravity I2C connector, plug & play feature, and is easy to connect. With onboard voltage regulator IC and level translator IC, DFRobot Gravity BME680 environmental sensor has flexible compatibility. It can be directly connected to 3.3V and 5V systems. Moreover, there is also a SPI connector for further expansion projects.

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 DFRobot Gravity BME680 environmental sensor can help make an air quality monitor for this purpose. DFRobot Gravity BME680 can help you take care of your health!

Specification

IAQ (Indoor Air Quality) Sheet

IAQ (Indoor Air Quality) Sheet

Board Overview

Num Label Description
+ VCC Power Input(3.3~5.0V)
- GND Power Ground(0V)
C SCL I2C Clock Signal
D SDA I2C Data Signal

Tutorial

This tutorial will demonstrate how to use this sensor. Currently, only FireBeetle ESP8266 IOT Microcontroller can read IAQ values, other main controllers are not supported at this time.

Requirements

Connection Diagram

This product supports both IIC and SPI wiring connector. Please select suitable connector according to the wiring. Below is the connection diagram for your reference.
IIC wiring connector is recommended, since it is plug & play and easy to use.

IIC Connection Diagram

You must pay attention to the wiring order, VCC to Power Supply, GND to Ground.

IIC Connection Diagram

SPI Connection Diagram

You must pay attention to the wiring order, VCC to Power Supply, GND to Ground.

SPI Connection Diagram

Sample Code

Download and install the BME680 Library. [https://www.arduino.cc/en/Guide/Libraries#.UxU8mdzF9H0| How to install Libraries in Arduino IDE] This sample code is based on IIC connector. Please check file: DFRobot_BME680_SPI.ino for sample code for SPI connector in the library file. Because SPI sample code realizes the same function, it will not be shown at here. Calibration is needed to monitor altitude value exactly. So that please fill in the sample code with correct local altitude value:

seaLevel = bme.readSeaLevel (your correct local altitude value)

Without IAQ

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

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

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

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

float seaLevel;
void setup()
{
  Serial.begin(115200);
  while(!Serial);
  delay(1000);
  Serial.println();
  Serial.print(bme.begin());
  #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(), 2);
  Serial.print("pressure(Pa) :");
  Serial.println(bme.readPressure());
  Serial.print("humidity(%rh) :");
  Serial.println(bme.readHumidity(), 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
}

With IAQ

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

#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(0x77);  //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 faild");
      delay(2000);
    }
  }
  Serial.println("bme begin successful");
  bme.supportIAQ();
}

void loop()
{
  static uint8_t       firstCalibrate = 0;

  #ifdef CALIBRATE_PRESSURE
  if(firstCalibrate == 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);
      firstCalibrate = 1;
    }
  }
  #else
    firstCalibrate = 1;
  #endif

  if(firstCalibrate) {
    uint8_t rslt = bme.iaqUpdate();
    if(rslt == 0) {
      Serial.println();
      Serial.print("time(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.println("IAQ not ready, please wait about 5 minutes");
    }
  }
}

Without IAQ

BME680_result.png

With IAQ

BME680_result_iaq.png

Arduino Library Functions List

DFRobot_BME680_I2C bme(0x77);
begin();
startConvert();
update();
supportIAQ();
iaqUpdate();
isIAQReady();
readTemperature();
readPressure();
readHumidity();
readGasResistance();
readAltitude();
readSeaLevel(float altitude);
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

DFshopping_car1.png Get Gravity: I2C BME680 Environmental Sensor from DFRobot Store or DFRobot Distributor.

Turn to the Top