Skip to content

I2CDemo.ino

Arnd edited this page Dec 12, 2020 · 3 revisions

Arduino sketch to read and display measurements from the Bosch BME680 sensor. The sensor is connected to the Arduino using the processor's I2C pins and the library uses the Arduino's standard I2C library.

Compatibility

No special processor-dependent calls are used and thus this sketch should run on any of the Arduino systems. The serial port speed defaults to 115200 baud. The 2 I2C wires/pins (SDA and SCL) are in different locations dependent upon the processor or Arduino board in use and the example board shown above is for an Arduino Micro. The library has been tested on an Arduino Micro, Arduino ATMega 2560 and an Arduino UNO.

Function

The BME680 is instantiated and initialised in the setup() method with the following explicit values:

  • All 4 sensors (temperature, humidity and pressure) are turned on with 16x oversampling
  • IIR filtering is turned on to 16x

After initialisation the program loops infinitely. It displays the temperature in degrees Celsius, the humidity in % and the pressure in hPa (hectopascal) and the gas sensor resistance. The altitude is computed using a standard atmosphere of 1013.25 and is displayed in meters. After displaying the measurements the program pauses 5 seconds and repeats.