Learn ESP32, ESP8266, Arduino, and Raspberry Pi

Arduino Guide for BMP180 Barometric Pressure & Temperature Sensor

We will learn about the BMP180 sensor module and how to use it with Arduino board.

Tag: Project 123a BMP180 Barometric Pressure & Temperature Sensor.

Project resources

Sketch: sketch and sketch;


  • SFE_BMP180 Library. You can download it here;
  • Adafruit BMP085 Library. You can download it here or install it directly in Arduino IDE. Go to Sketch->Include Library->Manage libraries…->search for Adafruit BMP085 and click on Install.

Other attachments: None.

Parts required

In this project, you needed these parts (Dear visitors. You can support our project buy clicking on the links of parts and buying them or donate us to keep this website alive. Thank you):

1. BMP180 sensor module 1 pc


2. Jumper cables  F-F 4 pcs

jumper cables

3. Arduino Nano and Mini-B USB cable 1 pc



The BMP180 is a basic sensor that is designed specifically for measuring atmospheric pressure, which is really useful for two things.

  • As we travel from sea level to a mountain peak, the air pressure gets lower. That means by measuring the pressure we can determine the altitude. So, we can use this sensor as an Altimeter.
  • Because the atmospheric pressure changes with the weather, we can use it to monitor changes in the weather.
Measuring Weather and Altitude

The BMP180 was designed to accurately measure atmospheric pressure. Atmospheric pressure varies with both weather and altitude; you can measure both of these using this sensor. Here’s how:

What is Atmospheric Pressure?

The definition of pressure is a force “pressing” on an area. A common unit of pressure is pounds per square inch (psi). One pound, pressing on one square inch, equals one psi. The SI unit is newtons per square meter, which are called pascals (Pa).

There are lots of situations in which pressure can be measured (gravity, pull, etc.), but right now we’re interested in atmospheric pressure, which is the force that the air around you is exerting on everything. The weight of the gasses in the atmosphere creates atmospheric pressure. One doesn’t normally notice that air weighs anything, but if you took a one inch wide column of air from sea level to the top of the atmosphere, it would weigh about 14.7 pounds. (A 1 cm wide column of air would weigh about 1 kg.) This weight, pressing down on the footprint of that column, creates the atmospheric pressure that we can measure with sensors like the BMP180.

Because that inch-wide column of air weighs about 14.7 pounds, and is pressing on one square inch, it follows that the average sea level pressure is about 14.7 pounds per square inch (psi), or 101325 pascals. This will drop about 4% for each 1000 feet (or 300 meters) you ascend. The higher you get, the less pressure you’ll see, because the column to the top of the atmosphere is that much shorter and therefore weighs less. This is useful to know, because by measuring the pressure and doing some math, you can determine your altitude.

Fun fact: The air pressure at 12,500 feet (3810 meters) is only half of that at sea level. In other words, half of the mass of the atmosphere is below 12,500 feet, and the air at 12,500 feet is half as dense as that at sea level. No wonder you have a harder time breathing up there.

The BMP180 outputs absolute pressure in pascals (Pa). One pascal is a very small amount of pressure, approximately the amount that a sheet of paper will exert resting on a table. You will more often see measurements in hectopascals (1 hPa = 100 Pa) or kilopascals (1 kPa = 1000 Pa). The Arduino library we’ve provided outputs floating-point values in hPa, which also happens to equal one millibar (mbar).

Here are some conversions to other pressure units:

1 hPa = 100 Pa = 1 mbar = 0.001 bar

1 hPa = 0.75006168 Torr

1 hPa = 0.01450377 psi (pounds per square inch)

1 hPa = 0.02953337 inHg (inches of mercury)

1 hpa = 0.00098692 atm (standard atmospheres)

Temperature Effects

Because temperature affects the density of a gas, and density affects the mass of a gas, and mass affects the pressure (whew), atmospheric pressure will change dramatically with temperature. Pilots know this as “density altitude”, which makes it easier to take off on a cold day than a hot one because the air is more dense and has a greater aerodynamic effect.

To compensate for temperature, the BMP180 includes a rather good temperature sensor as well as a pressure sensor. To perform a pressure reading, you first take a temperature reading, then combine that with a raw pressure reading to come up with a final temperature-compensated pressure measurement.

Measuring Absolute Pressure

As we just mentioned, if your application requires measuring absolute pressure, all you have to do is get a temperature reading, then perform a pressure reading. The final pressure reading will be in hPa = mbar. If you wish, you can convert this to a different unit using the above conversion factors.

Note that the absolute pressure of the atmosphere will vary with both your altitude and the current weather patterns, both of which are useful things to measure.

Weather Observations

The atmospheric pressure at any given location on earth (or anywhere with an atmosphere) isn’t constant. The complex interaction between the earth’s spin, axis tilt, and many other factors result in moving areas of higher and lower pressure, which in turn cause the variations in weather we see every day. By watching for changes in pressure, you can predict short-term changes in the weather. For example, dropping pressure usually means wet weather or a storm is approaching (a low-pressure system is moving in). Rising pressure usually means that clear weather is approaching (a high-pressure system is moving through).

But remember that atmospheric pressure also varies with altitude. The absolute pressure in Denver (altitude 5280′) will always be lower than the absolute pressure in San Francisco (altitude 52′). If weather stations just reported their absolute pressure, it would be difficult to directly compare pressure measurements from one location to another (and large-scale weather predictions depend on measurements from as many stations as possible).

To solve this problem, weather stations always remove the effects of altitude from their reported pressure readings by mathematically adding the equivalent fixed pressure to make it appear as if the reading was taken at sea level. When you do this, a higher reading in San Francisco than Denver will always be because of weather patterns, and not because of altitude.

To do this, there is a function in the library called seaLevel(P,A). This takes absolute pressure (P) in hPa, and the station’s current altitude (A) in meters, and removes the effects of the altitude from the pressure. You can use the output of this function to directly compare your weather readings to other stations around the world.

For more information, here is a good Wikipedia article on mean sea level pressure.

Determining Altitude

Since pressure varies with altitude, you can use a pressure sensor to measure altitude (with a few caveats).

The average pressure of the atmosphere at sea level is 1013.25 hPa (or mbar). This drops off to zero as you climb towards the vacuum of space. Because the curve of this drop-off is well understood, you can compute the altitude difference between two pressure measurements (p and p0) by using this equation:

formula BMP180

There are two ways you can take advantage of this.

  1. If you use sea level pressure (1013.25 hPa) as the baseline pressure (p0), the output of the equation will be your current altitude above sea level.
  2. Or, if you take a single pressure reading at your current location, and use that as your baseline (p0), all subsequent pressure readings will result in relative altitude changes from the baseline. Climb the stairs and you should see the altitude go from zero to 3 or 4 meters. Go down to the basement, and you’ll see -3 or -4 meters. There’s an example sketch included with the Sparkfun library called BMP180_altitude_example.ino that shows how to do this.

There’s a function in the library called altitude(P,P0) that lets you accomplish both of these things. If you give it the sea level pressure (1013.25 hPa) for p0, and your local pressure for p, it will give you your altitude above sea level. If you use a local pressure measurement for p0, subsequent p pressure readings will give you your change in altitude from the baseline.

Now for the caveats:

Accuracy: How accurate is this? The theoretical noise level at the BMP180s highest resolution is 0.25m (about 10 inches), though in practice we see noise on the order of 1m (40 inches). You can improve the accuracy by taking a large number of readings and averaging them, although this will slow down your sample rate and response time.

Weather: You should also remember that pressure changes due to weather will affect your altitude readings. The best accuracy will be obtained if you take a “fresh” p0 when you need it and don’t rely on it to be accurate for extended periods due to changes in the weather.

Maximum altitude: The BMP180 can’t measure all the way down to vacuum (or up to space). It’s advertised lower limit is about 300 hPa (or mbar), which corresponds to an altitude of about 3000m or 30,000 feet. People have flown these to higher altitudes and gotten useful results, but this isn’t guaranteed or likely to be accurate. (You might consider using GPS for high-altitude measurements).

Minimum altitude: Similarly, this sensor isn’t suited for large pressures either. The advertised upper limit is 1100 hPa=mbar (or 16 psi), which is about 500 feet below sea level (that’s in air – the BMP180 isn’t submersible in water). This sensor isn’t a good choice for submersible or compressed-gas measurements.

Understanding the BMP180 sensor module

The BMP180 is the next-generation of sensors from Bosch, and replaces the BMP085. The good news is that it is completely identical to the BMP085 in terms of firmware/software – you can use our BMP085 tutorial and any example code/libraries as a drop-in replacement. The XCLR pin is not physically present on the BMP180 so if you need to know that data is ready you will need to query the I2C bus.

The module comes with an on-board LM6206 3.3V regulator, so you can use it with a 5V logic microcontroller like Arduino without worry.

These sensors are fairly simple to use, pre-calibrated and don’t require extra components so you can start measuring barometric pressure, altitude and temperature in no time.

BMP180 can measure barometric pressure from 300 to 1100 hPa (9000m to -500m above sea level), and temperature from -40°C to 85°C with ±1.0°C accuracy.

The BMP180 consumes less than 1mA during measurements and only 5μA during idle. This low power consumption allows the implementation in battery driven devices.

The module features a simple two-wire I2C interface which can be easily interfaced with any microcontroller of your choice. This module has a hardwired I2C 7-bit address and is set to 0x77 HEX.


  • Vin: 3 to 5VDC
  • Logic: 3 to 5V compliant
  • Pressure sensing range: 300-1100 hPa (9000m to -500m above sea level)
  • Up to 0.03hPa / 0.25m resolution
  • -40 to +85°C operational range, +-2°C temperature accuracy

You can read more about it here.


  • The BMP180 needs access to ambient air to measure its pressure, so don’t put it in a sealed case. Providing a small vent hole should be adequate.
  • On the other hand, exposure to fast-moving air or wind can cause momentary pressure variations that will affect your readings. Shield the device from strong air currents.
  • Because an accurate temperature reading is needed to measure the pressure, try not to expose the device to rapid temperature changes, and keep it away from nearby hot parts and other heat sources.
  • The BMP180 is sensitive to moisture. Don’t submerge it or allow it to contact liquid water.
  • Surprisingly, the silicon within the BMP180 is sensitive to light, which can enter the device through the hole on the top of the chip. For maximum accuracy, shield the chip from ambient light.

Understanding the Arduino Nano

You can read more about it here.

Signals and connections of the BMP180 sensor module

BMP180 pinout
  • VCC, Vin – power supply pin. Supplies power for the module. Connect it to 5V pin of your Arduino board.
  • GND, – ground pin. Connected to GND pin on Arduino board.
  • IO – allows you to alter the I/O voltage for very low voltage processors (e.g. 1.8V). This pin is disabled by default, and you can normally leave that pin disconnected
  • SDA , DA – serial data pin for I2C interface (SDA pin or Analog input pin A4 of Arduino board).
  • SCL, CL -serial clock pin for I2C interface (SCL pin or Analog input pin A5 of Arduino board)
  • 3Vo, 3.3, (+) – power supply pin. Supplies power for the module. You can use it instead of VCC pin of BMP180 sensor module. Connect it to 3.3V pin of your Arduino board.

Signals and connections of the Arduino Nano

You can read more about it here.


Connections are fairly simple. Start by connecting VIN pin to the 5V pin on the Arduino board and connect GND to ground pin on the Arduino board. Now we are remaining with the pins that are used for I2C communication. Note that each Arduino Board has different I2C pins which should be connected accordingly. On the Arduino boards with the R3 layout, the SDA (data line) and SCL (clock line) are on the pin headers close to the AREF pin. Refer below table for quick understanding.

Arduino UnoA5A4
Arduino NanoA5A4
Arduino Mega2120
BMP180 wiring
BMP180 wiring

Step by Step instruction

  1. Do wiring.
  2. Open Arduino IDE.
  3. Plug your Arduino Nano board into your PC and select the correct board and com port.
  4. Install the SFE_BMP180 Library. First, download the latest BMP180 library from this link. From the menu of Arduino IDE, choose Sketch ->Include library ->Add .ZIP Library. A file requester will open. Navigate to the “” file you just downloaded, and click on Open button. The library will be installed and ready for you to use. You can also use Adafruit BMP085 Library. See the note how to install it in Libraries section below.
  5. After installing the libraries, restart your Arduino IDE.
  6. Verify and upload sketch for SFE_BMP180 Library or sketch for Adafruit BMP085 Library to your Arduino Nano.
  7. Open up Arduino IDE Serial monitor and set your baud to 9600 baud and select Newline.
  8. You should see below output on serial monitor:
Serial monitor BMP180

8.Or if you are using sketch for Adafruit BMP085 Library, you should see this output in Serial Monitor:

serial monitor BMP180


1.SFE_BMP180_example sketch

This example is very well commented and explained on how the sensor reads the pressure, temperature and computes the altitude.

Before uploading the code, you need to set up your current altitude. Go to, insert your address and check your altitude’s location. Set your altitude in the code. The place where you should write your altitude is commented.

#define ALTITUDE 1655.0 // Altitude of SparkFun's HQ in Boulder, CO. in meters

2. BMP180_adafruit sketch

The sketch starts with including of libraries.

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

Next, we define seaLevelPressure_hPa variable needed to calculate the altitude. Change it to current sea level pressure at your location.

We also create a bmp object so that we can access functions related to it.

#define seaLevelPressure_hPa 1013.25

Adafruit_BMP085 bmp;

In setup function of code we initialize the serial communication with PC and call the begin() function.

The begin() function initializes I2C interface and checks if the chip ID is correct. It then resets the chip using soft-reset & waits for the sensor for calibration after wake-up.


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

In loop function, we use following functions to read temperature barometric pressure and altitude from the BMP180 module.

  • readTemperature() function returns the temperature from the sensor.
  • readPressure() function returns the barometric pressure from the sensor.
  • readAltitude(seaLevelPressure_hPa * 100) function calculates the altitude (in meters) from the specified atmospheric pressure (in hPa).
  • readSealevelPressure() function calculates the sea-level pressure (in hPa).
Serial.print("Temperature = ");
Serial.println(" *C");

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

Serial.print("Altitude = ");
Serial.println(" meters");

Serial.print("Pressure at sealevel (calculated) = ");
Serial.println(" Pa");

Serial.print("Real altitude = ");
Serial.print(bmp.readAltitude(seaLevelPressure_hPa * 100));
Serial.println(" meters");

Wrapping up

We have learnt about the BMP180 sensor module and how to use it with Arduino Nano. The BMP180 can be used in your own weather station. As the pressure changes with the altitude, this sensor is able to compute a altitude too.

Check for more DIY projects here.

Thank you for reading and supporting us.

Check for more DIY projects on and!

If you are looking for high quality PCBs PCBWay is the best choice: