Using the BMP180 to record air pressure and temperature

Lead Image © Elena Kozlova, 123RF.com

Blue Skies

The kernel module simplifies access to the BMP180 sensor, allowing you to record the temperature and air pressure with shell commands.

The BMP180 digital sensor is designed for a wide range of applications, including measuring air pressure and ambient temperatures, which makes it useful for predicting the weather as a supplement to navigation systems. It has been customized to output data in blocks of plain text. The block output logs on the I2C bus at address 0x77h. Because you have no way to modify the address, you can only operate one such block per device. The sensor range of the BMP180 is 300-200hPa (hectopascals), within a margin of 0.03hPa or around 17cm in height.

Physics and Meteorology

With a few special exceptions, air pressure is the amount of force exerted by the air above us. Because air is extremely light, you generally are unaware of changes in pressure. However, you may be familiar with the sensation in your ears as you drive up a mountain or go up in an elevator – air pressure decreases simply because there's less air as you go up. The amount of air in a certain area can be measured to help you work out your current altitude. Measurements are taken from MSLP (mean sea level pressure).

The average air pressure at mean sea level is 1013.25hPa. As your altitude increases, the air pressure decreases exponentially. Table 1 shows the corresponding pressure for certain landmarks around the world. These should be sufficient to help you understand whether the sensor correctly measures the air pressure.

Table 1

Air Pressure by Height

Height

Air Pressure (%)

Air Pressure (hPa)

Location

- 425

105.60

1,070.10

The Dead Sea

0

100.00

1,013.25

Mean sea level

529

93.81

-950.53

Star Lake, Wisconsin

1,433

84.89

-860.20

Sun Valley, Nevada

1,609

82.98

-840.80

Denver, Colorado

2,000

78.05

-790.92

Flagstaff, Arizona

2,987

71.13

-720.76

Brian Head, Utah

4,810

43.70

-480.24

Denali (Mount McKinley)

8,848

32.10

-325.40

Mount Everest

20,000

7.70

-77.80

Stratosphere

100,000

0.00027

-0.27

K·rm·n Line

Source: https://en.wikipedia.org/wiki/List_of_highest_United_States_cities_by_state

The BMP180 measures the current air pressure at your location. If you use a household barometer or online weather map, you might see a slightly different value because they both show air pressure relative to sea level. The formula used,

Air pressure=(BMP180 measurement)+(height above MSLP/8.5)

assumes that air pressure falls by 1hPa per 8.5m of altitude, which is a rough approximation of the real value.

In meteorology, air pressure is used for forecasts. In areas with rising air pressure, cloud formation is curtailed, and the sun most likely comes out. Conversely, low-pressure areas are likely to produce bad weather. As such, it's possible to predict weather several hours ahead of time. However to make an accurate forecast, you need to take measurements from a number of locations.

Hardware

Up to this point, I've discussed what the sensor can do in theory. If you're ready to get started with a hands-on project, it's best to find a ready-made module. Although Bosch has discontinued the BMP180, you can still find it on Amazon and eBay [1].

Figure 1 shows the simple structure of the BMP180: You simply connect the sensor as shown in the accompanying instructions. Make sure, though, to use the correct operating voltage of 1.6-3.6V. This marries up nicely with the Raspberry Pi's GPIO pins, which use 3.3V.

Figure 1: The layout of the air pressure sensor is extremely clear.

Buy this article as PDF

Express-Checkout as PDF

Pages: 6

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content