Using BMP180 for temperature, pressure and altitude measurements

The BMP180 is a new generation digital barometric pressure and temperature sensor from Bosch Sensortec. In this tutorial, we will briefly review this device and describe how to interface it with an Arduino Uno board for measuring the surrounding temperature and pressure. We will also discuss about retrieving the sensor altitude from its pressure readings.


Temperature, pressure and altitude measurements using BMP180

Experiment setup

Bosch Sensortag’s BMP180 is an ultra low-power digital temperature and pressure sensor with high accuracy and stability. It consists of a piezo-resistive sensor, an analog to digital converter and a control unit with EEPROM and a serial I2C interface. The raw measurements of pressure and temperature from the BMP180 sensor has to be compensated for temperature effects and other parameters using the calibration data saved into the EEPROM. In this tutorial, we will use an Arduino board to read the temperature and barometric pressure measurements from the BMP180 sensor and display the data on an 1.44″ ILI9163-based TFT display. If you would like to repeat this experiment, you will need the following things.

1. Any Arduino board running at 3.3V. I am using Crowduino Uno board from Elecrow, which has an onboard slide switch to select the operating voltage between 3.3V and 5.0V. If you want to use this board, make sure the switch is slided to 3.3V position.

Crowduino Uno board from Elecrow

2. BMP180 sensor module

BMP180 sensor breakout module

BMP180 sensor breakout module

3. ILI9163-based TFT display (I am using one with 1.44″ size display from Elecrow).

1.44" TFT display (ILI9163 driver)

1.44″ TFT display (ILI9163 driver)

4. A breadboard and few jumper wires for hooking up the sensor and the display to the Arduino board.

The following diagram describes the experimental setup for this tutorial. The BMP180 and the TFT display are both powered by 3.3V. The BMP180 supports I2C interface and therefore the SDA and SCL pins go to A4 and A5 pins of the Arduino board. The ILI9163 TFT driver supports SPI interface. The table shown on the right side of the diagram below describes the wiring between the display and Arduino. The I2C and SPI pin names are printed on the bottom layer silkscreen of the BMP180 and the TFT display modules.

Sensor and display setup

Sensor and display setup

Here is the actual setup for this experiment made on a breadboard.

BMP180 sensor hookup with Arduino

BMP180 sensor hookup with Arduino

Arduino firmware

For sensor readings, I am using the BMP180 Arduino Library from Love Electronics Ltd (I am not sure if this company exists now or not bu that’s what it says in the library). You need to download it (link provided below) and install this library into your Arduino/libraries/ location.

Download BMP180 Library

For the ILI9163 TFT LCD, I am using another free and open source Arduino Library called TFT_ILI9163C, which you can download from the following link.

Download TFT_ILI9163C Arduino Library

The TFT library uses Adafruit_GFX libraries for fonts, so you need to download and install it too.

Download Adafruit_GFX_Library

After installing both of these libraries, it’s time to write firmware for the Arduino. The firmware I have written and shared below displays temperature in Celsius and Fahrenheit scales and barometric pressure in millibar and inHg. In order to compute the sensor altitude, we need to know the reference surface pressure value as discussed in the following section.

Important Note about retrieving sensor altitude

Please note that the BMP180 sensor provides absolute measurements for temperature and pressure, but do not give a direct output for the altitude. Since the atmospheric pressure reduces with altitude, you can find out the vertical displacement of the sensor by knowing the reference pressure value at the ground. For example, in order to compute the sensor altitude, say from the sea level, you need to know the current mean sea level pressure at your local place. The mean sea-level pressure is not a constant and varies diurnally with ambient temperature and weather patterns. An easiest way to find out the current sea-level pressure would be to check the website of your nearest airport or the national weather service. They usually update it on their website hourly or so. I live in Williamsburg, VA and I checked the mean sea-level pressure from website. At the time I was doing this experiment, the mean sea level pressure was 1027.7 millibars or 102770 Pascal. In the Arduino code below (float seaLevelPressure = 102770;), I used this value for the mean sea level pressure and used the difference in the sensor read pressure and this value to compute the altitude of the sensor location, which was the second floor of my house in Williamsburg, VA. Therefore, in order to compute the altitude of your sensor location, you have to replace this value with your current local sea-level pressure value in Pascal (1 millibar = 100 Pascal). With the knowledge of the local sea-level pressure, the Arduino firmware below also displays the altitude above the sea level in feet and meters. 
Mean sea-level pressure data

Mean sea-level pressure data

Here is a complete Arduino code for this project. I would recommend to use the download file below instead of copying and pasting the code from here, which does not work sometime.

#include <Wire.h>
#include <BMP180.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <TFT_ILI9163C.h>
// Define pins for ILI9163 SPI display
#define __CS 10
#define __DC 9 // Labeled as A0 in some modules
#define __RST 8
// Connect SDA to Arduino pin 11 (MOSI), and SCK to 13 (SCK)
// Color definitions
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0 
#define WHITE 0xFFFF
#define TRANSPARENT -1
TFT_ILI9163C display = TFT_ILI9163C(__CS, __DC, __RST);
// Store an instance of the BMP180 sensor.
BMP180 barometer;
// Store the current sea level pressure at your location in Pascals.
float seaLevelPressure = 102770; // Williamsburg, VA on Dec 31, 2014, 14:54 Eastern Time
void setup()
 // We start the serial library to output our messages.
 // We start the I2C on the Arduino for communication with the BMP180 sensor.
 // We create an instance of our BMP180 sensor.
 barometer = BMP180();
 // We check to see if we can connect to the sensor.
 Serial.println("Connected to BMP180."); // Output we are connected to the computer.
 // When we have connected, we reset the device to ensure a clean start.
 // Now we initialize the sensor and pull the calibration data.
 Serial.println("No sensor found.");
void loop()
 // Retrive the current pressure in Pascals.
 long currentPressureP = barometer.GetPressure();
 float currentPressuremb = currentPressureP/100.0;
 float currentPressureinHg = currentPressuremb*0.02953;

 // Print out the Pressure.
 Serial.print("Pressure: ");
 Serial.println(" Pa");
 Serial.print("Pressure: ");
 Serial.println(" mbar");
 Serial.print("Pressure: ");
 Serial.println(" inHg");
 // Retrive the current altitude (in meters). Current Sea Level Pressure is required for this.
 float altitudem = barometer.GetAltitude(seaLevelPressure);
 float altitudeft = altitudem*3.2808;
 // Print out the Altitude.
 Serial.print("\tAltitude: ");
 Serial.print(" m");
 Serial.print("\tAltitude: ");
 Serial.print(" ft");

 // Retrive the current temperature in degrees celcius.
 float currentTemperatureC = barometer.GetTemperature();
 float currentTemperatureF = (9.0/5.0)*currentTemperatureC+32.0;
 // Print out the Temperature
 Serial.print("\tTemperature: ");
 Serial.println(); // Start a new line.

 // Now display results on LCD

 display.setCursor(0, 0);
 display.print("BMP180 Sensor Demo");

 // Display temperature in F 
 display.setCursor(0, 16);
 display.print(" o");
 // Display temperature in C
 display.setCursor(24, 32);
 display.print(" o");

 //Now display pressure in mbar
 display.setCursor(0, 48);
 // Display pressure in inHg
 display.setCursor(24, 64);

 //Now display pressure in mbar
 display.setCursor(0, 80);
 // Display pressure in inHg
 display.setCursor(24, 96);

 delay(5000); // Show new results every second.

Download the Arduino sketch here


The sensor altitude shown was about 88 feet above the sea level, which seems to be right as compared to the city data published here:,_Virginia


Second floor measurements

The sensor is very sensitive to altitude. The following measurement was taken by placing the sensor on my dining table in the first floor. The altitude was reduced by ~8 feet, which seems to be reasonable.


First floor measurements

Related Posts


Leave a Reply

Your email address will not be published. Required fields are marked *