BME680 is a multifunctional digital sensor, developed by Bosch after years of research, which can measure temperature, humidity, gases and barometric pressure. Communication with this sensor is possible via the Serial Peripheral Interface (SPI) and I2C protocols.
The accuracy of temperature and barometric pressure is +-1 and humidity is +-3. Gases are measured as volatile organic compounds (VOCs) in the air. VOCs provide a single resistance value for the output. This means that we can predict that the gas is present in the air, but we cannot distinguish whether it is ethanol, carbon monoxide or alcohol, etc.
For this project, we will interface the BME680 sensor with Arduino . The main sensor is small and compact, and external resistors and capacitors are required for proper configuration. For example, both an I2C pull-up and a VOC resistor are required when a voltage divider is required. The BME680 sensor can work at 3.3 and 5V.
Circuit Diagram
The circuit diagram for this project is quite simple. We decided to interface the sensor with the Arduino Nano using the SPI protocol. Arduino SPI pins are available on digital pins 10 to 13. The sensor is powered by the Arduino's 3.3V output.
Here is a diagram…
The code
Adafruit offers a predefined library that has almost all of the functions of this sensor available. However, the Adafruit BME sensor library first requires the Adafruit sensor as well as the Arduino SPI and I2C wire library to properly configure and start the BME680.
After importing the library, the SPI pins are declared. Pins must be passed to the BME builder for initialization.
Furthermore, to measure barometric pressure, it is necessary to specify a reference pressure. Therefore, we used typical sea level pressure as a reference for calculating barometric pressure for this project.
How it works
In the setup function, the Arduino serial monitor starts at 9600 bps. The sensor must then be probed to verify that the connection has been established successfully.
In the loop function, readings are received continuously from the sensor. If the data request is successful, the individual parameter values will be displayed on the Arduino IDE's serial monitor.
Note: Gas and pressure values are divided by 1000 and 100, respectively, to assign them units in kOhm and hpa.
To get more stable values for the individual parameters, simply increase the sampling rate for them.
Instructions
1. bme.setTemperatureOversampling(BME680_OS_8X);
2. bme.setHumidityOversampling(BME680_OS_2X);
3. bme.setPressureOversampling(BME680_OS_4X);
4. bme.setIIRFilterSize(BME680_FILTER_SIZE_3);
5. bme.setGasHeater(320, 150); // 320*C for 150 ms
To view the results, open the Arduino IDE serial monitor at 9600 bps. During initial startup, the sensor will take a few seconds. After a few readings, the sensor will stabilize and produce accurate values.
Where to buy the parts?
- ArduinoNano: mouse
- BME680 Sensor: Digi-Key