Wednesday, February 5, 2014

Sensing Barometric Pressure

Adafruit makes a nice barometric pressure sensor (BMP180), but their tutorial is designed for the BMP085 and does not compile on Arduino 1.05

It has a built in temperature sensor, and we calculate our current altitude, which is not exact, and can fluctuate with the weather.

Here is how to make it work, and I've added a bunch of calculations for US units of measure. The 4 connections are in the code below. This is a 5v friendly board, and works with the UNO with no modifications.

You will need to download and install the BMP085 library that works with both the BMP085 and the BMP180 at

I will be merging this sensor with our weather project at that serves up temp, humidity, dew point and heat index calculations.

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

float Tc=0;
float Tf=0;
float Pa=0;
float InHg=0;
float Am=0;
float Af=0;

  This is an example for the BMP085 Barometric Pressure & Temp Sensor

  Designed specifically to work with the Adafruit BMP085 Breakout

  These displays use I2C to communicate, 2 pins are required to
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.
  BSD license, all text above must be included in any redistribution
//Modified by Steve Spence of

// Connect VIN of the BMP180 sensor to 5.0V //Make sure you have a 5v sensor, otherwise use the 3.3v power pin on the Arduino

// Connect GND to Ground
// Connect SCL to A5 on Arduino Uno (pin 21 on the 2560)
// Connect SDA to A4 on Arduino Uno (pin 20 on the 2560)

Adafruit_BMP085 bmp;

void setup() {
  if (!bmp.begin()) {
Serial.println("Could not find a valid BMP085/180 sensor, check wiring!");
while (1) {}

void loop() {
    Serial.print("Temperature = ");
    Serial.println(" *F");
    Serial.print("Pressure = ");
    Serial.println(" In Hg");
    // Calculate altitude assuming 'standard' barometric
    // pressure of 1013.25 millibar = 101325 Pascal
    Serial.print("Altitude = ");
    Am=bmp.readAltitude(101550); //adjusted for local altitude
    Serial.println(" feet");

  // 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");