Product | Sensors | Environment Sensor | BMP085 Temperature&Barometric Sensor
BMP085 Temperature&Barometric Sensor
BMP085 Temperature&Barometric Sensor
42283
More than 100
 
US$7.98 Loading ...
 
Share/Save/Bookmark


BMP085 Temperature&Barometric Sensor




Introduction

The BMP085 is a basic sensor that is designed specifically for measuring barometric pressure (it also does temperature measurement on the side to help). It's one of the few sensors that does this measurement, and its fairly low cost so you'll see it used a lot. You may be wondering why someone would want to measure atmospheric pressure, but its actually really useful for two things. One is to measure altitude. As we travel from below sea level to a high mountain, the air pressure decreases. That means that if we measure the pressure we can determine our altitude - handy when we don't want the expense or size of a GPS unit. Secondly, atmospheric pressure can be used as a predictor of weather which is why weathercasters often talk about "pressure systems".

Specification

1、Pressure sensing range: 300-1100 hPa (9000m to -500m above sea level)

2、Up to 0.03hPa / 0.25m resolution

3、-40 to +85°C operational range, +/-2°C temperature accuracy

4、I2C interface on chip

5、3.3V/5V power

Wiring

Since the BMP085 is an I2C sensor, its very easy to wire up. We'll be using an Arduino as an example but any microcontroller with i2c can be used.

Connect this module with Arduino:

Arduino GND -> HMC5883L GND
Arduino 3.3V -> HMC5883L VCC
Arduino A4 (SDA) -> HMC5883L SDA
Arduino A5 (SCL) -> HMC5883L SCL

You don't need to connect the XCLR (reset) or EOC (end-of-conversion) pins. If you need to speed up your conversion time, you can use the EOC as a indicator - in our code we just hang out and wait the maximum time possible.

If you have Arduino Sensor Shield, connection will be very easy.

 


Example Code

To use this sensor and calculate the altitude and barometric pressure, there's a lot of very hairy and unpleasant math. You can check out the math in the datasheet but really, its not intuitive or educational - it's just how the sensor works. So we took care of all the icky math and wrapped it up into a nice Arduino library. You can download the library here.

Place the BMP085 library folder your <arduinosketchfolder>/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE.

Now you can run this first example sketch.

#include <Wire.h>
#include <Adafruit_BMP085.h>

Adafruit_BMP085 bmp;

void setup() {
Serial.begin(9600);
bmp.begin();
}

void loop() {
Serial.print("Temperature = ");
Serial.print(bmp.readTemperature());
Serial.println(" *C");

Serial.print("Pressure = ");
Serial.print(bmp.readPressure());
Serial.println(" Pa");

// Calculate altitude assuming 'standard' barometric
// pressure of 1013.25 millibar = 101325 Pascal
Serial.print("Altitude = ");
Serial.print(bmp.readAltitude());
Serial.println(" meters");

// you can get a more precise measurement of altitude
// if you know the current sea level pressure which will
// vary with weather and such. If it is 1015 millibars
// that is equal to 101500 Pascals.
Serial.print("Real altitude = ");
Serial.print(bmp.readAltitude(101500));
Serial.println(" meters");

Serial.println();
delay(500);
}

Then open up the serial monitor at 9600 baud. The sketch will continuously print out the temperature in °C and pressure in Pa (Pascals). You can test that the sensor is measuring variations in temperature and pressure by placing your fingertip over the open port hole in the top of the sensor. The temperature and pressure will increase as you can see here :
 



Altitude Measurements

Since we know that pressure drops as we gain altitude (that's why air is so thin on mountain-tops) we can compute the current altitude knowing the pressure and temperature. Again, there's a bit of hairy math involved, you can read about the calculations on wikipedia (where this graph is from).


 


 


 With the Arduino library, we take care of that for you! Simply run this sketch which will return the current altitude based on the pressure.

#include "Wire.h"
#include "Adafruit_BMP085.h"

Adafruit_BMP085 bmp;

void setup() {
Serial.begin(9600);
bmp.begin();
}

void loop() {
Serial.print("Temperature = ");
Serial.print(bmp.readTemperature());
Serial.println(" *C");

Serial.print("Pressure = ");
Serial.print(bmp.readPressure());
Serial.println(" Pa");

// Calculate altitude assuming 'standard' barometric
// pressure of 1013.25 millibar = 101325 Pascal
Serial.print("Altitude = ");
Serial.print(bmp.readAltitude());
Serial.println(" meters");

Serial.println();
delay(500);
}

Run the sketch to see the calculated altitude.


For example, according to the sensor we are 21.5m below sea level. Only problem is, I know for a fact that our current location is not below sea level! So what's wrong with the sensor? Turns out the sensor is just fine. The problem is that the pressure at sea level changes with the weather. So we need to 'normalize' the sensor, and let it know what the sea-level pressure is. You can look up the current sea level pressure on any weather site.
 


Unfortunately there are half-dozen different units of pressure. here we see it in inches, that's technically "Mercury Inches" or "Hg Inches We need it in Pascals, so we'll convert it!

 


OK so that's 101,964 Pascals. Open up the Examples->BMP085 test example from the Arduino IDE menubar and edit the line where you pass in the 'corrected' altitude.
 


Now it will print out the correct altitude! 30 meters which is a lot better.



Download

Bmp085 library for Arduino

Write a review
*Review title
Please enter subject.
*Your review
Please enter review.
*Rating
(Click star icon to comment)
 
Display name
*Enter security code

CAPTCHA

Please enter code
Loading ...

Best Sellers