BMP085 Barometric Pressure Sensor Quickstart


BMP085 Quickstart Guide

Bosch's BMP085 is a rock-solid barometric pressure sensor. It features a measuring range of anywhere between 30,000 and 110,000 Pa. 'Pa' meaning the Pascal unit, which you'll probably more often see converted to hPa (hectoPascal), equal to 100 Pa, or kPa (kiloPascal), which is 1000 Pa. As a bonus the BMP085 also provides a temperature measurement, anywhere from 0 to 65 °C.

The BMP085 has a digital interface, I2C to be specific. This means there may is a bit more overhead to get it talking to your microcontroller, but in return you get data that is much less susceptible to noise and other factors that may hamper an analog signal. I2C is a synchronous two-wire interface, the first wire, SDA, transmits data, while a second wire, SCL, transmits a clock, which is used to keep track of the data. If you're using an Arduino to talk to the BMP085, the Wire library will conveniently take care of most of the work in communicating with the sensor.

As with most SparkFun products, before you start toying around with something, it's always best to RTFM...err...read the fancy datasheet. The BMP085 datasheet covers everything you'd ever need to know about that little sensor on your breakout board.

Why do we care about barometric pressure?

There are a lot of projects that can make use of barometric pressure data. Here's at least a couple reasons to care about pressure. You've probably heard weather reporters going on about low pressure systems and high pressure systems, that's because atmospheric pressure can be directly related to changes in weather. Low pressure typically means cloudier, rainier, snowier, and just generally uglier weather. While high pressure generally means clearer, sunnier weather. This means the BMP085 would be a perfect component for your Weather Prophet robot.

A second, widely applied use for pressure sensors is in altimetry. Barometric pressure has a measurable relationship with altitude, meaning you can use the BMP085 to deduce how high you (or maybe one of your robots) have climbed. At sea level air pressure is on average 1013 hPa, while here in Boulder, CO, at 5184 ft above sea level, average air pressure is about 831.4 hPa. The measuring limits of the BMP085 should allow you to measure pressure at elevations anywhere between -1640 to about 29,000 ft above sea level.

Pressure and Altitude Relationship

Hardware Explanation and Assembly

When you receive the BMP085 Breakout board, you're presented with a tiny 0.65 x 0.65” board with just 4 components, and six un-soldered holes. Your first task will be to solder something into those holes to get a good, solid electrical connection. What you solder into those holes is up to you. If I'm using a breadboard I like to stick some male headers in there, but simple wires are also a good option. However, if you do choose to go with wire, make sure to keep it short, I2C is really only reliable at short distances (a few meters max).

Now, if you take a gander at the bottom side of the BMP085 Breakout you'll notice the labels of all six pins: 'SDA', 'SCL', 'XCLR', 'EOC', 'GND, and 'VCC.' VCC and GND are obviously the power pins. SDA and SCL are the I2C communication lines. SDA being where the data is transmitted, and SCL is the clock that keeps track of that data. The last two pins, XCLR and EOC, are a couple extra functions of the BMP085. XCLR acts as a master reset. It's active-low, so if it's pulled to GND it will reset the BMP085 and set its registers to their default state. EOC, standing for "end of conversion", is a signal generated by the BMP085 that's triggered whenever a pressure or temperature conversion has finished. These last two pins are optional, and if you don't need to use them you can just leave them unconnected.

BMP085 Pin Pin Function
VCC Power (1.8V-3.6V)
GND Ground
EOC End of conversion output
XCLR Master Clear (low-active)
SCL Serial Clock I/O
SDA Serial Data I/O

Pay special attention to how you power the BMP085. Its maximum supply voltage is 3.6V. So don't go feeding it 5V! If you've got a regular Arduino Uno, use the 3.3V header to supply power to the chip.

Getting pressure and temperature readings

Now that you've got the gist of the sensor, let's play! In this example we'll use an Arduino to initialize the BMP085, collect its pressure and temperature data, and display it on the serial output. First off, you'll need to connect it to the Arduino like so:

Example wiring

BMP085 Pin Arduino Pin
VCC 3.3V
GND GND
SCL A5
SDA A4

For now, we're going to ignore XCLR and EOC, it's safe to just leave them unconnected.

Now let's get to the nitty-gritty Arduino code. You can download the code here, or get ready to do some copy-pasta.

The first thing I like to do with digital sensors like this is make sure I can actually communicate with it. For many sensors this is half the battle. Let's first look at the functions used to read 8- and 16-bit values from the BMP085.

// Put this line at the top of your program
#define BMP085_ADDRESS 0x77  // I2C address of BMP085

// Read 1 byte from the BMP085 at 'address'
char bmp085Read(unsigned char address)
{
  unsigned char data;
  
  Wire.beginTransmission(BMP085_ADDRESS);
  Wire.write(address);
  Wire.endTransmission();
  
  Wire.requestFrom(BMP085_ADDRESS, 1);
    
  return Wire.read();
}

// Read 2 bytes from the BMP085
// First byte will be from 'address'
// Second byte will be from 'address'+1
int bmp085ReadInt(unsigned char address)
{
  unsigned char msb, lsb;
  
  Wire.beginTransmission(BMP085_ADDRESS);
  Wire.write(address);
  Wire.endTransmission();
  
  Wire.requestFrom(BMP085_ADDRESS, 2);
  
  msb = Wire.read();
  lsb = Wire.read();
  
  return (int) msb<<8 | lsb;
}

Now, if you've glanced through the BMP085 datasheet, you may have noticed some very cryptic variables, and a lot of ugly math involving them. The BMP085 is calibrated in the factory, and left with a series of eleven 16-bit calibration coefficients stored in the device's EEPROM. These variables all play a small role in calculating the absolute pressure. They need to be read just once, at the start of the program, and stored for later use. We can use the I2C functions above to read and store each of the calibration coefficients. We'll stick all of this in the setup() function, so it'll be called just once at the start of the program.

// This is the top of the program
#include <Wire.h>

#define BMP085_ADDRESS 0x77  // I2C address of BMP085

const unsigned char OSS = 0;  // Oversampling Setting

// Calibration values
int ac1;
int ac2; 
int ac3; 
unsigned int ac4;
unsigned int ac5;
unsigned int ac6;
int b1; 
int b2;
int mb;
int mc;
int md;

// b5 is calculated in bmp085GetTemperature(...), this variable is also used in bmp085GetPressure(...)
// so ...Temperature(...) must be called before ...Pressure(...).
long b5; 

short temperature;
long pressure;

// Use these for altitude conversions
const float p0 = 101325;     // Pressure at sea level (Pa)
float altitude;

void setup()
{
  Serial.begin(9600);
  Wire.begin();
  bmp085Calibration();
}

// Stores all of the bmp085's calibration values into global variables
// Calibration values are required to calculate temp and pressure
// This function should be called at the beginning of the program
void bmp085Calibration()
{
  ac1 = bmp085ReadInt(0xAA);
  ac2 = bmp085ReadInt(0xAC);
  ac3 = bmp085ReadInt(0xAE);
  ac4 = bmp085ReadInt(0xB0);
  ac5 = bmp085ReadInt(0xB2);
  ac6 = bmp085ReadInt(0xB4);
  b1 = bmp085ReadInt(0xB6);
  b2 = bmp085ReadInt(0xB8);
  mb = bmp085ReadInt(0xBA);
  mc = bmp085ReadInt(0xBC);
  md = bmp085ReadInt(0xBE);
}

Once we've read the calibration values, we just need two more variables in order to calculate temperature and pressure. 'ut' and 'up' are the uncompensated temperature and pressure values, they're our starting point for finding the actual temperature and pressure. Every time we want to measure temperature or pressure, we need to first find out what these values are. The uncompensated temperature value is an unsigned 16-bit (int) number while 'up' is an unsigned 32-bit number (long).

// Read the uncompensated temperature value
unsigned int bmp085ReadUT()
{
  unsigned int ut;
  
  // Write 0x2E into Register 0xF4
  // This requests a temperature reading
  Wire.beginTransmission(BMP085_ADDRESS);
  Wire.write(0xF4);
  Wire.write(0x2E);
  Wire.endTransmission();
  
  // Wait at least 4.5ms
  delay(5);
  
  // Read two bytes from registers 0xF6 and 0xF7
  ut = bmp085ReadInt(0xF6);
  return ut;
}

// Read the uncompensated pressure value
unsigned long bmp085ReadUP()
{
  unsigned char msb, lsb, xlsb;
  unsigned long up = 0;
  
  // Write 0x34+(OSS<<6) into register 0xF4
  // Request a pressure reading w/ oversampling setting
  Wire.beginTransmission(BMP085_ADDRESS);
  Wire.write(0xF4);
  Wire.write(0x34 + (OSS<<6));
  Wire.endTransmission();
  
  // Wait for conversion, delay time dependent on OSS
  delay(2 + (3<<OSS));
  
  // Read register 0xF6 (MSB), 0xF7 (LSB), and 0xF8 (XLSB)
  Wire.beginTransmission(BMP085_ADDRESS);
  Wire.write(0xF6);
  Wire.endTransmission();
  Wire.requestFrom(BMP085_ADDRESS, 3);
  
  msb = Wire.read();
  lsb = Wire.read();
  xlsb = Wire.read();
  
  up = (((unsigned long) msb << 16) | ((unsigned long) lsb << 8) | (unsigned long) xlsb) >> (8-OSS);
  
  return up;
}

In those two functions, we're delaying to give the BMP085 enough time to finish its readings. The time for the delay is specified as the maximum conversion time in the datasheet. If you wanted to make it a bit more robust, you could read the EOC pin. While the conversion is still running, EOC will read LOW. Once finished it will go HIGH.

Now that we have all the variables we need, we need one last function that takes care of the following for us:

Necessary calculations to find temperature and pressure

Ugh. Calculating the temperature isn't so bad, but, just...ugh, those pressure calculations. A couple quick notes: dividing by 2N is the same thing as shifting a byte N bits to the right. Likewise, multiplying by 2N, is the same thing as shifting it N bits to the left. We also have to be careful not to overflow any of the variables, which means paying close attention to the order of operations, and doing a little typecasting.

Here's the two functions we need to calculate temperature and pressure. Note that the variable b5, which is calculated in the bmp085GetTemperature() function, is also required to calculate pressure. This means you'll have to call bmp085GetTemperature(), before calling bmp085GetPressure().

// Calculate temperature given ut.
// Value returned will be in units of 0.1 deg C
short bmp085GetTemperature(unsigned int ut)
{
  long x1, x2;
  
  x1 = (((long)ut - (long)ac6)*(long)ac5) >> 15;
  x2 = ((long)mc << 11)/(x1 + md);
  b5 = x1 + x2;

  return ((b5 + 8)>>4);  
}

// Calculate pressure given up
// calibration values must be known
// b5 is also required so bmp085GetTemperature(...) must be called first.
// Value returned will be pressure in units of Pa.
long bmp085GetPressure(unsigned long up)
{
  long x1, x2, x3, b3, b6, p;
  unsigned long b4, b7;
  
  b6 = b5 - 4000;
  // Calculate B3
  x1 = (b2 * (b6 * b6)>>12)>>11;
  x2 = (ac2 * b6)>>11;
  x3 = x1 + x2;
  b3 = (((((long)ac1)*4 + x3)<<OSS) + 2)>>2;
  
  // Calculate B4
  x1 = (ac3 * b6)>>13;
  x2 = (b1 * ((b6 * b6)>>12))>>16;
  x3 = ((x1 + x2) + 2)>>2;
  b4 = (ac4 * (unsigned long)(x3 + 32768))>>15;
  
  b7 = ((unsigned long)(up - b3) * (50000>>OSS));
  if (b7 < 0x80000000)
    p = (b7<<1)/b4;
  else
    p = (b7/b4)<<1;
    
  x1 = (p>>8) * (p>>8);
  x1 = (x1 * 3038)>>16;
  x2 = (-7357 * p)>>16;
  p += (x1 + x2 + 3791)>>4;
  
  return p;
}

And finally, we need to write something into the main loop() function so that our program actually does something. Let's just calculate the temperature and pressure, and spit it out over a serial line.

void loop()
{
  temperature = bmp085GetTemperature(bmp085ReadUT());
  pressure = bmp085GetPressure(bmp085ReadUP());
  
  Serial.print("Temperature: ");
  Serial.print(temperature, DEC);
  Serial.println(" *0.1 deg C");
  Serial.print("Pressure: ");
  Serial.print(pressure, DEC);
  Serial.println(" Pa");
  Serial.println();
  
  delay(1000);
}

Send that over to your Arduino. Open up the serial monitor and check that the baud rate is set to 9600. Are you getting something reasonable? The data should be in units of 0.1°C for the temperature, and Pa for pressure. Here in my office I'm reading a comfy 258 (25.8°C) for temperature, and a pressure of 83523 Pa. If your elevation is lower than Boulder's ~5200ft, the measured pressure should read higher. Average pressure for those of you at sea level should be about 101325 Pa.

If the program slows to a halt before printing any readings, that usually means something's hooked up incorrectly. Make sure you didn't swap SDA and SCL!

You may have noticed a few of the calculations take into account an oversampling setting, OSS. OSS selects which mode the BMP085 operates in, and can be set to either 0, 1, 2, or 3. OSS determines how many samples the BMP085 will take before it sends over its uncompensated pressure reading. With OSS set to 0, the BMP085 will consume the least current. Setting OSS to 3 increases resolution, as it samples pressure eight times before producing a reading, this comes at a cost of more power usage. If you want to change OSS, just set it accordingly at the top of the program. Try changing OSS to 3, does the data become more stable?

OSS setting meanings

Applying the data: Altimetry and Meteorology

Knowing the pressure is all good fun, but what really matters is what we do with this shiny knowledge. As I mentioned above, pressure is most often used to either calculate altitude, or as an indicator of what the weather might be planning on doing. Let's make a altitude tracking weather forecaster!

We're really just one step away from calculating the altitude, all we need is the non-linear equation that converts pressure to altitude. This equation is conveniently in the BMP085's datasheet:

Equation to find altitude at a given pressure

p0 is the average pressure at sea level 101325 Pa, and p is the pressure that we measured. Note that this equation gives you altitude in units of meters. So, after we calculate pressure in our code, we just need to add these lines to calculate and print out the altitude:

// Add these to the top of your program
const float p0 = 101325;     // Pressure at sea level (Pa)
float altitude;

  // Add this into loop(), after you've calculated the pressure
  altitude = (float)44330 * (1 - pow(((float) pressure/p0), 0.190295));
  Serial.print("Altitude: ");
  Serial.print(altitude, 2);
  Serial.println(" m");

The altitude that you calculate might be off a tad, as the pressure will vary depending on the weather. Google Earth says the altitude here at SparkFun is about 1580 m (5183 ft), while at the pressure I'm measuring altitude calculates out to about 1600m (5249 ft). Close enough for government SparkFun work.

Now, let's add a little code to turn our Arduino into a simple weather forecaster. If our altitude is known, we can turn the above formula around to calculate expected pressure at a specific altitude.

Formula to find expected pressure at a given altitude

You can use Google Earth, this website, or even a GPS module to find your altitude.

If your measured pressure is about equal to the expected pressure at your altitude, weather will probably be fair, if somewhat cloudy. Typically anything over about 250 Pa of the expected pressure will result in awesome, sunny weather, while anything 250 Pa below means rainy/snowy weather. Knowing all of that, here's some quick code to implement a simple weather forecaster:

// Add these to the top of your program
const float currentAltitude = 1580.08; // current altitude in METERS
const float ePressure = p0 * pow((1-currentAltitude/44330), 5.255);  // expected pressure (in Pa) at altitude
float weatherDiff;

  // Add this into loop(), after you've calculated the pressure
  weatherDiff = pressure - ePressure;
  if(weatherDiff > 250)
    Serial.println("Sunny!");
  else if ((weatherDiff <= 250) || (weatherDiff >= -250))
    Serial.println("Partly Cloudy");
  else if (weatherDiff > -250)
    Serial.println("Rain :-(");
  Serial.println();

I'll stress that this is very simple. To get a better idea of what the weather's going to do, you need to look at how pressure is changing over time. Measuring the rate of change of pressure, you can get a much better idea of what the weather is going to do. For example, pressure changes of more than about -250 Pa per hour (Pa/h), result in unstable weather patterns like thunderstorms, while lower rates, between -50 and -250 Pa/h produce stable, though still rainy weather. Now that you know how to use the BMP085, maybe you can program your Arduino to out-forecast your local weatherman!

Comments 30 comments

  • Avi8tor857 / about 13 years ago * / 3

    For those that want to do an altimeter that closely mimics a real aircraft here is the steps to go along with what is provided here.
    First we are getting the barometric pressure in pascals, and in Aviation most measurements are in inHG.
    float pressInHG = pressure/3386.389; //convert pa to inHG
    Secondly this measures very minute changes and when flying you don't want you altemeter jumping around that much so we limit the accuracy some.
    pressInHG = ((int)(pressInHG100))/100.0; //round to two dec places
    Now we look up the current altememter setting for our area. The easiest and most current is the METAR data from the closest airport. The trouble you have there is getting the ICAO for the airport. For example the closest airport to me is Peachtree Dekab Airport or kpdk.
    This will help you find the ICAO.
    http://www.airlinecodes.co.uk/aptcodesearch.asp
    This will get you the METAR
    http://weather.noaa.gov/weather/metar.shtml
    This will teach you to decode the METAR
    http://www.wunderground.com/metarFAQ.asp
    but basically look for something like "A2995" which gives you the altimeter setting of 29.95 inHG
    float AS = 20.95;//this will need to be updated regularly to get accurate readings.
    Then we calculate the altitude.
    float altitude = (pow(AS,0.1903) - pow(pressInHG,(1/5.255)))/(1.212
    (pow(10,-5))); //calculate altitude
    Here is my reference
    http://wahiduddin.net/calc/density_altitude.htm
    I get readings within 50ft of my GPS, usually within 15ft.

    • Member #368771 / about 12 years ago / 1

      Where do I rewrite the Float pressInHG code at. I don't know which lines to change?

  • Member #38079 / about 12 years ago / 2

    How do I read sensor data in linux?

  • Member #233570 / about 8 years ago / 1

    Hello there, The datasheet at https://www.sparkfun.com/datasheets/Components/General/BST-BMP085-DS000-05.pdf states that uncompensated temperature and pressure are long, not unsigned long. Long is supposed to be 2s' complement. Why do we use unsigned variables in this code even though still saying it's long in this tutorial? Thanks

  • Member #785095 / about 9 years ago / 1

    I am one of those dumb Americans from South Dakota, I have sort of modified it for we who are challenged by the measurements used by the rest of the world, so I have made an attempt to change this so it reads out in F temp and Feet for altitude, that way I can use it when traveling across this wonder filled nation where I reside.

    // I2Cdev library collection - BMP085 basic Arduino example sketch // Based on register information stored in the I2Cdevlib internal database // 2012-06-28 by Jeff Rowberg jeff@rowberg.net // Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib // // Changelog: // 2012-06-28 - initial release, dynamically built

    /* ============================================ I2Cdev device library code is placed under the MIT license Copyright (c) 2012 Jeff Rowberg

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN

    THE SOFTWARE.

    */

    // Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation // is used in I2Cdev.h

    include "Wire.h"

    // I2Cdev and BMP085 must be installed as libraries, or else the .cpp/.h files // for both classes must be in the include path of your project

    include "I2Cdev.h"

    include "BMP085.h"

    // class default I2C address is 0x77 // specific I2C addresses may be passed as a parameter here // (though the BMP085 supports only one address) BMP085 barometer;

    float temperature; float pressure; float altitude; int32_t lastMicros;

    define LED_PIN 13 // (Arduino is 13, Teensy is 11, Teensy++ is 6)

    bool blinkState = false;

    void setup() { // join I2C bus (I2Cdev library doesn't do this automatically) Wire.begin();

    // initialize serial communication
    // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but
    // it's really up to you depending on your project)
    Serial.begin(38400);
    
    // initialize device
    Serial.println("Initializing I2C devices...");
    barometer.initialize();
    
    // verify connection
    Serial.println("Testing device connections...");
    Serial.println(barometer.testConnection() ? "BMP085 connection successful" : "BMP085 connection failed");
    
    // configure LED pin for activity indication
    pinMode(LED_PIN, OUTPUT);
    

    }

    void loop() { // request temperature barometer.setControl(BMP085_MODE_TEMPERATURE);

    // wait appropriate time for conversion (4.5ms delay)
    lastMicros = micros();
    while (micros() - lastMicros < barometer.getMeasureDelayMicroseconds());
    
    // read calibrated temperature value in degrees Celsius
    temperature = barometer.getTemperatureF();
    
    // request pressure (3x oversampling mode, high detail, 23.5ms delay)
    barometer.setControl(BMP085_MODE_PRESSURE_3);
    while (micros() - lastMicros < barometer.getMeasureDelayMicroseconds());
    
    // read calibrated pressure value in Pascals (Pa)
    pressure = barometer.getPressure();
    
    // calculate absolute altitude in meters based on known pressure
    // (may pass a second "sea level pressure" parameter here,
    // otherwise uses the standard value of 101325 Pa)
    altitude = barometer.getAltitude(pressure)* 3.2808 - 275;
    
    // display measured values if appropriate
    Serial.print("T/P/A\t");
    Serial.print(temperature); Serial.print("\t");
    Serial.print(pressure); Serial.print("\t");
    Serial.print(altitude);
    Serial.println("");
    
    // blink LED to indicate activity
    blinkState = !blinkState;
    digitalWrite(LED_PIN, blinkState);
    
    // delay 100 msec to allow visually parsing blink and any serial output
    delay(100);
    

    }

  • renedlc / about 10 years ago / 1

    I tested this code with my Arduino Micro and it works just fine. My pressure readings are in the 101100 Pa.

    Now, what do I have to add to the code in order to make an actuator operate based off of my pressure readings? My goal is: I want to be able to make an actuator operate when a specific range of pressure readings (acquired from the code provided in this page) are measured.

    Any suggestions?

  • Member #460744 / about 11 years ago / 1

    How can I connect two of these sensors on my Arduino, I can only use A5 and A4?

    • M-Short / about 11 years ago / 1

      Because these do not have configurable addresses you can't really connect 2 to one Arduino.

      • Member #235716 / about 11 years ago / 1

        wrong, as the datasheet says:

        "There is an easy way to connect two BMP085 to the same i2c bus: You can use the XCLR input of BMP085 to set one BMP085 part silent while you communicate with the other BMP085 part via i2c and vice versa. The signals can be provided by two digital outputs of the microcontroller, or one digital output and one inverter."

        That being said, one can connect as many BMP085 sensors to the single arduino, as there are available digital pins that can be connected to xclr.

  • Member #421939 / about 12 years ago / 1

    Hi,

    When I start the example sketch (where I just add an output of the raw values) I receive this : (I'm using it with an Arduino Uno)

    Raw Temperature : 65535 Raw Pressure : 0 Temperature: 1918 *0.1 deg C Pressure: 314124 Pa Altitude: -10650.13 m

    There is obviously a problem but I can't figure out where...

    Does anybody have an idea ?

  • DAG144 / about 12 years ago * / 1

    Recording barometer: I combined this sensor with a ProMicro 3.3V Arduino and a PCD8544 LCD display to keep a history of atmospheric pressure for the previous 84 hours. Go to the following instagram link to see it: http://distilleryimage7.instagram.com/3c317112778b11e28d6622000a1fbc43_6.jpg

  • rxe3936 / about 12 years ago / 1

    ok, i've just done testing this unit, and i have some concerns. first, the temperature is off by about 7C i can compensate for that, but i am unsure if this error is constant over temperature, linear or what? obviously some of the calibration coefficients in the registers from 0xAA to 0xBE are messed up.

    can someone shed some light on how to perform an error correction on these units?

    tx.

  • Member #407140 / about 12 years ago / 1

    Hi all, great resources here. I am looking on information to use the BMP 085 as a sensor for vertical airspeed. Has anyone an idea how to realize pressure difference/altitude change over sampling period? Example code would be highly appreciated, as I am new to arduino programming. Thanks. Martin

    • Member #427454 / about 12 years ago / 1

      I'm trying to do just the same. So far my code looks like this:

      float altitude;
      float prevAltitude = 0;
      float verticalSpeed = 0;
      
      void loop()
      {
      
        float pressure = bmp085GetPressure(bmp085ReadUP());
      
        altitude = calcAltitude(pressure); //Uncompensated caculation - in Meters 
        verticalSpeed = prevAltitude - altitude;
        prevAltitude = altitude;
        Serial.print("Altitude: "); //this will go to a display later
        Serial.print(altitude, 2); //display 2 decimal places
        Serial.println(" M");
      
        Serial.print("Vertical Speed:" );//dito
        Serial.print(verticalSpeed, 1);
        Serial.println("m/s");
      
        if (verticalSpeed > 0.3) 
          {playTone(verticalSpeed); //I have added a dc beeper to my circuit, I'm currently tweaking the beeps. My ears bleed.
      
      
      
      delay(1000); //I'll probably change this value to 250 or so. I need it for paragliding where even small lifts count.
      }
      

  • Red / about 12 years ago / 1

    I have used this code and everything is fine, except reading the temperature register is reading back 0xffff ! The pressure and calibration values read back fine.
    Thus I have found a forum wher ethay say it was problem in batch of chips. Only change of the chip solved the problem.

  • LouwH / about 12 years ago / 1

    Where in the code can you change or set the pins used? (A4 & A5)

    • By using the Wire library, it automatically sets the pins on the Arduino to A4 and A5, in order to use the I2C interface.

  • Immense gratitude to the makers of the world who take the time to explore and share their findings. After 13 hours of searching/dissecting/migrating posted snippets of code, I discovered that NOT ONE functional demo of the BMP085 for Arduino 1.0+ exists. Dysfunctional findings include:

    • this tutorial
    • http://mitat.tuu.fi/?p=78
    • http://interactive-matter.eu/blog/2009/12/05/arduino-barometric-pressure-sensor-bmp085/
    • http://bildr.org/2011/06/bmp085-arduino/

    I was finally able to successfully debug the last article (@ bildr.org), mostly by fiddling with argument types. So if you replace the code in this otherwise awesome quickstart guide with this code ... http://ilabbali.com/code/Arduino_BMP085.cpp ... the BMP085 works great with Arduino 1.0+.

    I tried posting the code here, but the sparkfun WYSIWYG parser totally mangles it.

  • pvb / about 13 years ago / 1

    I'm a beginner, can anyone help on the last part please? I had to make some changes to get the prog. running, but I don't know how to get this done:

    "Measuring the rate of change of pressure, you can get a much better idea of what the weather is going to do. For example, pressure changes of more than about -250 Pa per hour (Pa/h), result in unstable weather patterns like thunderstorms, while lower rates, between -50 and -250 Pa/h produce stable, though still rainy weather."

    I want to make led's changing colours when the weather is unstable.

    thx

  • Member #271280 / about 13 years ago / 1

    I'm having a problem using this BMP085 together with a DS3231 (in the form of a ChronoDot). So far it fails. Individually, the DS3231 and BMP085 run fine in the i2c bus but as soon as I add the second device the sketch locks up. Using debug statements - it appears to lock up as it tries to read the 3231.

    I'm basically running the sketch presented here with some additional code to read the time just before reading the temp and pressure.

    Both the 3231 and 85 are running on the 3.3v line.

  • Member #313477 / about 13 years ago * / 1

    This line still makes no sense to me

    b3 = (((((long)ac1)*4 + x3)(lesser and greater symbols)2;

    • jimblom / about 13 years ago / 1

      Shoot, it looks like our WYSIWYG was interpreting some of those lt and gt symbols as HTML tags. The line should read:

      b3 = (((((long)ac1)*4 + x3)(less than)(less than)OSS) + 2)(greater than)(greater than)2;

  • Member #245390 / about 13 years ago / 1

    Would it be possible to set up two of these pressure sensors to read into the arduino, and then compare the results to measure gauge pressure inside something? If so, how might that be done?

  • jamesotron / about 13 years ago / 1

    What happens to the I2C address of the sensor if you want to have two (say one on the inside and one on the outside of a vacuum chamber)? I guess I could simply isolate them and only read one at a time? Bit nasty though.

  • Avi8tor857 / about 13 years ago / 1

    One other thing with the altitude calculation it is using standard pressure p0. So you are getting standard altitude, not true altitude. Pilots use standard altitude at high altitudes as a standard, but small airplanes flying lower use true altitude with the altimeter adjusted to the pressure as reported by the closes station.

  • Avi8tor857 / about 13 years ago / 1

    The instructions says to use pins A4 and A5 but on the Ardunio mega 2560 you have to use pins 20 (SDA) and 21 (SCL).

  • Avi8tor857 / about 13 years ago * / 1

    Has anyone gotten this to work with the mega 2560, if so which pins are you using I tried mapping it with SDA-A4 and SCL-A5, but I can't get the code to get past while(Wire.available() and available() is always empty.

  • Keebler / about 14 years ago / 1

    Great tutorial... I'm concerned that the diagram has 5v SDA and SCL lines going to a 3.3v part without a logic level shifter. I don't doubt it will work but won't reduce the life of the part and could this affect accuracy?
    Also, is there a way to disable the code "scroll view" windows? They don't print well (at all)... anyone know a workaround? Thanks!

  • bloater / about 14 years ago / 1

    Excellent tutorial Jimbo - thanks ;)
    What's your opinion on using i2c pullups connected to 5V with a 3V3 part such as the BMP085? Presumably this is out of spec and may stress the part. I went to the trouble of tweaking the Arduino 'Wire' library to avoid enabling the AVR pullups (it's a shame this is not an option in the library).
    - Bernard ;)

  • Microzoul / about 14 years ago / 1

    what this line means
    b3 = (((((long)ac1)*4 + x3)2;
    is it possible way to calculate altitude directly from UP value without calibration overhead
    thank you