Skip to content

Project 3: Temperature, Pressure & Altitude Logger

Daniel J. Breton edited this page Jan 13, 2020 · 12 revisions

Hardware

We are using the BMP280 pressure and temperature sensor, purchased from Adafruit for $10, and connecting it to the Circuit Playground Express (CPX). The wiring is straightforward, as we are using the I2C wiring setup described here.

CPX SENSOR WIRE COLOR PURPOSE
3.3V VIN red power
GND GND black ground
SCL SCK green serial clock
SDA SDI white serial data

We fabricated a wiring harness to connect the sensor to a 1 m long section of wire so that the sensor could be held away from our body heat, and thus give a more accurate reading.

Software

The code for this project is 'tpalogger.py' and is fairly similar to the on-board temperature logger developed earlier. The only significant difference is that we are now recording four different types of data (time, temperature, pressure, altitude) instead of just two (time, temperature).

Initial field testing

When we were outside, we could not see red LED which indicated that the system was working... and so we concluded (wrongly) that something was wrong. We returned home and added an audible "beep" to the code, indicating when measurement & storage were happening. This was much more satisfactory.

Methods

To test the operation of the sensor, we decided to take it on a hike from the Connecticut River to the summit of Lyme Hill, and record data both ways, making a measurement every minute. We attached the sensor to one end of a yardstick, attached the CPX and battery case near the other end, leaving some space for a handle. We made the trip on 11 Jan 2020 (very warm!) kept notes on timing in a small notebook. A photo of the setup follows.

image

In hindsight, we should have included more stationary measurements to get a better sense of how much variability the sensor and the environment contribute to a given measurement. We did stationary measurements for 10 min at the summit, and 5 minutes upon returning to the river, but an initial stationary measurement at the river would have tied things together much better, since we started and ended at the same place/elevation. A map of the area with our (very approximate) route in red.

image

Atmospheric pressure dropped by about 3 hPa during the course of the work, so the summit elevations are a little exaggerated, but overall these numbers seem reasonable. The actual height of Lyme Hill is 320 m, and our sensor reported a value of 330 m, so about 3% error. Not too bad for ten bucks.

Results

The results are actually pretty good, with the added bonus of capturing a sort of rare meteorological phenomenon called a temperature inversion. More on this in a bit.

The most straightforward way we can visualize our data is to plot is versus elapsed time, as we do in the two following plots of altitude and temperature versus time.

image

Plot of altitude vs. time for River to Summit and Summit to River trips. The latter is much shorter because (a) it is downhill and (b) my assistant was springing, gazelle-like down the side of the mountain, and the CPX and battery case both fell off, interrupting the measurements. We eventually got it restarted about 5 minutes later, but we had descended a bit by then.

image

Plot of temperature vs. time for River to Summit and Summit to River trips. Same loss of first 5 min of data on the downward trip.

image

Plot of temperature vs. elevation. Note that temperature increases as we climb. This is contrary to the normal state of affairs, and is proof of a temperature inversion in the Connecticut River valley on the day of the measurements.

Visualization

The plots above were made in gnuplot, an interactive graphing program.

But we can make plots in Python too, and I've sketched out what that might look like in 'tpa-plot.py'. If you point that program at uphill-data.csv, the plot below results.

image

Here is a plot of temperature versus altitude for the trip up, again, using Python.

image

Discussion

So here is where the science would come in:

  • discussing the barometric law (pressure being directly proportional to the density, acceleration due to gravity, and the depth of the ocean/atmosphere)
  • how this law allows us to deduce altitude from measured pressure
  • the normal adiabatic lapse rate (the notion that air temperature goes down as we climb higher in the atmosphere)
  • what a temperature inversion is, and what it looks like in data form
  • potentially negative impacts of temperature inversions (trapping of pollution in valleys), and how systems like ours might detect them as they are forming.

Further work

  • if we repeated this measurement under different (i.e. non-inversion) conditions, what do we think the data might look like? how closely does it match the rate predicted by the adiabatic lapse rate?
  • if we set up two loggers, one at the river and one at the summit and recorded over a few days, what differences might we expect?
  • if we set up two loggers, one in Thetford and one in Lyme and recorded over a few days, what differences might we expect?