BME280 Field Notes: Taking sensor on a bike ride

RPi Zero with battery pack (left), BME280 sensor (right)

BME280 sensor is a pressure, humidity and temperature sensor from Bosche and wonderfully packaged with I²C interface by Adafruit Industries, which makes it very easy to use with devices such as Raspberry Pi.

I have written about monitoring temperature and humidity in the past and this post is about evaluating its barometric pressure measurement capabilities. In particular, I took this sensor on a bike ride and correlated data captured using this sensor against what was reported by GPS sensing Strava app running on my phone. Let’s dig into details…

GPX Data from Strava

Strava is a very popular ride tracking app that can be used for a variety of activities such as running, biking, swimming etc. We can download the so-called GPX (GPS Extended) formatted data that was captured by the app. This file captures the GPS coordinates along with elevation and we will use it as a reference to evaluate how well BME280 senses barometric pressure changes.

GPX formatted output showing latitude, longitude and elevation

As you can see GPX data is an XML formatted data, which we will parse later in a Go code to correlate against BME280 data.

BME280 Data

I wrote a simple Go code which leveraged open source drivers to capture data over I²C bus using an open source library. Eventually I am printed output as JSON strings in a logfile bme.json.

└─ $ ▶ cat bme.json | head -n 1 | jq '.'
"level": "info",
"time": "2021-05-23T10:28:00.200-0700",
"name": "",
"msg": "data",
"temperature": 19.82,
"pressure": 1010.69,
"humidity": 43.36,
"altitude": 21

Now these two data sets can be merged based on the timestamp and analyzed for correlation.

Data Analysis

I followed a very simple approach to merge the two data sets by first reading in BME280 data and building a hashmap (in Go) with timestamp (in seconds) as keys. I then iterated over GPX data entries and looked up corresponding timestamps in the hashmap with a tolerance of +/- 2 seconds. If a match was found, combined data was printed in a new CSV file.

Below is elevation profile over time as recorded by GPX and BME280. I was amazed to see a stunning correlation between these two data sets. The barometric pressure was converted to altitude and offset was removed from both data sets. In other words, BME280 measures the “change” in altitude very well but I have not yet figured out how to calibrate the offset for it.

Correlation of BME280 data with GPX data from Strava

And here is the scatter plot of the same data showing an excellent R² value:

Scatter plot of BME280 data against GPX data from Strava


I am impressed by the capabilities of BME280 sensor and plan to use it for several IoT projects. It integrates very well with Raspberry Pi (including RPi Zero) and there are excellent libraries for capturing data from it. Stay tuned for further updates on it as I tinker with it more…




Software engineer and entrepreneur currently building Kubernetes infrastructure and cloud native stack for edge/IoT and ML workflows.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Single Point of Failure in Hadoop (Godown Analogy Part 2)

Applying Process in Financial Workflow

Experience at LetsGrowMore

The Complete Reference to Data Science (ML/AI) and Related Concepts

How to find similarity between two sentance : NLP Part 1

Not by Data Alone

T-SNE: t-Stochastic neighborhood embedding

The 3 (types of) tables your dbt pipeline needs

tables of all shapes and sizes

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Saurabh Deoras

Saurabh Deoras

Software engineer and entrepreneur currently building Kubernetes infrastructure and cloud native stack for edge/IoT and ML workflows.

More from Medium

The Sixth Sense: A not so technical guide to sensors

Oracle PeopleSoft Human Capital Management review

Local and Global variables

Introduction to Dockstore