SparkFun BME280 Breakout Hookup Guide

Pages
Contributors: MTaylor
Favorited Favorite 1

Example Sketches

The examples are selectable from the drop-down menu in the Arduino IDE, or they will run stand-alone if you put the contents of the libraries /src dirctory in with the example.ino file.

Note, the library has been updated to v2.0.0 since this guide was written. Nearly all of the examples now default to 9600 Baud.

I2C_and_SPI_Multisensor.ino

This example configures one BME280 on the SPI bus and another on the I2C bus. Then it gets the data and outputs from both sensors every second. If you only have 1 sensor connected the other channel reports garbage, so this can be a good troubleshooting and starting place.

alt text

Example output -- shown is the configuration plus the first 3 sample readings

CSVOutput.ino

If you want to use the BME280 to record data as a function of time, this example is for you! It outputs text as CSV (comma separated vales) that can be copy-pasted into a textfile or spreadsheet app for graphing.

A note on accuracy: This sketch use "delay(50);" to wait 50ms between reads. The units of the 'sample' column are in (50ms + time-to-read) periods.

alt text

Example output -- Shows the first few lines of the generated CSV.

In order to demonstrate the operation, the BME280 is connected with fine hookup wires that are then placed in a bottle and pressurized with breath.

alt text

alt text

The environmental test chamber! IT'S SCIENCE!

Data is collected from the event, and then a graph is made. To do this, the un-needed columns were deleted, and the pressure was scaled to kPa.


alt text

Example graph of pressure and humidity - shown after the data was loaded into OpenOffice Calc

ReadAllRegisters.ino

Here's an example that prints out the registers as well as the internally concatenated calibration words. It can be used to check the state of the BME280 after a particular configuration or can be implanted in your own sketch where you need to debug.

alt text

Example output -- shows the full contents of memory, even those not specified in the datasheet

RelativeAltitudeChange.ino

This example allows you to take measurements of change in altitude. It configures the BME280 with a lot of oversampling and also uses a software filter giving accurate but slow performance.

The sketch uses an additional button to zero the altitude. Push and hold until the average reaches zero.

alt text

After the sensor was zeroed out on the floor and moved to a desk hight, the output displays the rough height of the desk!

Product Video Sketches

The library also has a subfolder titled "More_Advanced" in the examples folder that contains the sketches used in the product video. They're modifications of the basic examples with a LCD added on. They are not covered by this tutorial.