Give your next Arduino project the ability to sense the world around it with BMP180.

It’s 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.

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.

Hardware Overview

At the heart of the module is the next-generation digital pressure and temperature sensor manufactured by Bosch – BMP180.

BMP180 Chip

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.

bmp180 chip on the module

The pressure measurements are so precise (low altitude noise of 0.25m), you can even use it as an altimeter with ±1 meter accuracy.

bmp180 sensor specifications

Power Requirement

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.

bmp180 module 3v3 regulator

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.

I2C Interface

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 address and is set to 0x77HEX.

BMP180 Module Pinout

The BMP180 module has only 4 pins that interface it to the outside world. The connections are as follows:

bmp180 module pinout

VCC is the power supply for the module which can be anywhere between 3.3V to 5V.

GND should be connected to the ground of Arduino.

SCL is a serial clock pin for I2C interface.

SDA is a serial data pin for I2C interface.

Wiring BMP180 Module to Arduino

Let’s hook the BMP180 module up to the Arduino.

Connections are fairly simple. Start by connecting VIN pin to the 5V output on the Arduino and connect GND to ground.

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. They are also known as A5 (SCL) and A4 (SDA).

If you have a Mega, the pins are different! You’ll want to use digital 21 (SCL) and 20 (SDA). Refer below table for quick understanding.

SCLSDA
Arduino UnoA5A4
Arduino NanoA5A4
Arduino Mega2120
Leonardo/Micro32

The following diagram shows you how to wire everything.

wiring bmp180 module with arduino

Installing Necessary libraries

Calculating the altitude and barometric pressure with BMP180 module needs a lot of math. Fortunately, Adafruit BMP180 Library was written to hide away all the complexities so that we can issue simple commands to read the temperature, barometric pressure and altitude data.

To install the library navigate to the Sketch > Include Library > Manage Libraries… Wait for Library Manager to download libraries index and update list of installed libraries.

manage libraries

Filter your search by typing ‘bmp180’. There should be a couple entries. Look for Adafruit BMP085 Library by Adafruit. Click on that entry, and then select Install.

bmp180 arduino library installation

Arduino Code – Reading Temperature and Barometric Pressure

The following sketch will give you complete understanding on how to read temperature and barometric pressure from BMP180 module and can serve as the basis for more practical experiments and projects.

#include <Wire.h>
#include <Adafruit_BMP085.h>
#define seaLevelPressure_hPa 1013.25

Adafruit_BMP085 bmp;
  
void setup() {
  Serial.begin(9600);
  if (!bmp.begin()) {
	Serial.println("Could not find a valid BMP085 sensor, check wiring!");
	while (1) {}
  }
}
  
void loop() {
    Serial.print("Temperature = ");
    Serial.print(bmp.readTemperature());
    Serial.println(" *C");
    
    Serial.print("Pressure = ");
    Serial.print(bmp.readPressure());
    Serial.println(" Pa");

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

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

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

Here’s how the output looks like in the serial monitor.

bmp180 temperature pressure altitude output

Every 1hPa off on the sea level pressure results in about 8.5 m of error in the altitude calculations. So, the altitude we are getting is close enough but not accurate.

You can get a more accurate altitude measurement, if you know the current sea level pressure which will vary with weather.

This code assumes that current sea level pressure is 1013.25 millibars that is equal to 101325 Pascals. That’s why seaLevelPressure_hPa variable is set to 1013.25

Code Explanation:

The sketch starts with including four libraries viz. Wire.h and Adafruit_BMP085.h.

#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.

Serial.begin(9600);

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.print(bmp.readTemperature());
Serial.println(" *C");

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

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

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

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

Login
ADS CODE