You are on page 1of 11

BMP180 based digital altimeter

Introduction:
In this project am going to Interface BMP180 Sensor with Arduino to measure Altitude, Pressure
& Temperature using Arduino. The project is about the barometric sensor BMP180 for Altitude,
Pressure & Temperature Measurement using Arduino. The BMP180 Sensor is a barometric
sensor capable of measuring pressure, temperature & altitude as well.

With Arduino, a Barometric condition is one of the criteria used to predict coming change in
weather and deduce altitude above sea level. Here is a demo to show you how to read the
barometric data from this Grove – Barometer Sensor (BMP180).

Bill of Materials
S.N. Components Name Quantity Purchase Links
1 Arduino UNO Board 1 Nerokas solutions
2 BMP180 Sensor 1 Nerokas solutions
4 16X2 LCD Display 1 Nerokas solutions
5 Connecting Wires 8 Nerokas solutions
6 Breadboard 1 Nerokas solutions

BMP180 Barometric Sensor:


Introduction:
This precision sensor from Bosch is the best solution for measuring barometric pressure and
temperature. It is an ultra-low-power digital temperature and pressure sensor with high accuracy
and stability. Because pressure changes with altitude I can also use it as an altimeter. It measures
the absolute pressure of the air around it. It has a measuring range from 300 to 1100hPa with an
accuracy down to 0.02 hPa. It can also measure altitude and temperature.
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 have to be compensated for temperature effects and other parameters using
the calibration data saved into the EEPROM.

Here I will Interface BMP180 Sensor with Arduino. I will use an Arduino board to read the
temperature and barometric pressure measurements from the BMP180 sensor and display the
data on the 16*2 LCD.

BMP180 Features & Specifications:


11. Supply Voltage:1.8V to 3.6V
22. Low power consumption:0.5uA at 1Hz
33. I2C interface
44. Max I2C Speed: 3.5Mhz
55. Very low noise: up to 0.02hPa (17cm)
66. Pressure Range: 300hPa to 1100hPa (+9000m to -500m)

Pin Details:

1. Vin – +5V DC
2. GND – GND
3. SCL – I2C Interface
4. SDA – I2C Interface

Working of BMP180:
The BMP180 consists of a piezo-resistive sensor, an analog to digital converter and a control unit
with E2PROM and a serial I2C interface. The BMP180 delivers the uncompensated value of
pressure and temperature. The microcontroller sends a start sequence to start a pressure or
temperature measurement. After converting time, the result value (pressure or temperature
respectively) can be read via the I2C interface.

This project BMP180 for Altitude, Pressure & Temperature Measurement using Arduino can be
explained via program functions and variables.

Like most pressure sensors, the BMP180 measures absolute pressure. This is the actual ambient
pressure seen by the device, which will vary with both altitude and weather. Before taking a
pressure reading you must take a temperature reading. This is done with startTemperature() and
getTemperature(). The result is in degrees C. Once you have a temperature reading, you can take
a pressure reading. This is done with startPressure() and getPressure(). The result is in millibar
(mb) aka hectopascals (hPa).
If you’ll be monitoring weather patterns, you will probably want to remove the effects of
altitude. This will produce readings that can be compared to the published pressure readings
from other locations. To do this, use the sealevel() function. You will need to provide the known
altitude at which the pressure was measured.

If you want to measure altitude, you will need to know the pressure at a baseline altitude. This
can be average sealevel pressure, or a previous pressure reading at your altitude, in which case
subsequent altitude readings will be + or – the initial baseline. This is done with the altitude()
function.
For calculating temperature in °C and pressure in hPa (hecto Pascal), the calibration data has to
be used. These constants can be read out from the BMP180 E2PROM via the I2C interface at
software initialization. The sampling rate can be increased up to 128 samples per second
(standard mode) for dynamic measurement. In this case, it is sufficient to measure the
temperature only once per second and to use this value for all pressure measurements during the
same period.

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:

Program/Source Code:
#include <SFE_BMP180.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Initialize the BMP180 Pressure Sensor
SFE_BMP180 pressure;

// Initialize the LCD. Assuming the I2C address of the LCD is 0x27.
// If your LCD has a different address, change it accordingly.
LiquidCrystal_I2C lcd(0x27, 16, 2);

#define ALTITUDE 1649.0 // Altitude of The Technical University of Kenya in


meters

void setup() {
Serial.begin(9600);
Serial.println("REBOOT");

// Initialize the LCD


lcd.init();
lcd.backlight();

// Initialize the BMP180 sensor


if (pressure.begin())
Serial.println("BMP180 init success");
else {
Serial.println("BMP180 init fail\n\n");
while(1); // Pause forever if sensor initialization fails
}
}

void loop() {
char status;
double T, P, p0, a;

// Start a temperature measurement


status = pressure.startTemperature();
if (status != 0) {
delay(status);
status = pressure.getTemperature(T);
if (status != 0) {
// Start a pressure measurement
status = pressure.startPressure(3);
if (status != 0) {
delay(status);
status = pressure.getPressure(P, T);
if (status != 0) {
// Calculate sea-level compensated pressure
p0 = pressure.sealevel(P, ALTITUDE);
// Calculate altitude
a = pressure.altitude(P, p0);

// Display data on LCD


lcd.clear();
lcd.setCursor(0, 0); // Start at character 0 on line 0
lcd.print("T:");
lcd.print(T, 1);
lcd.print("C P:");
lcd.print(P, 0);

lcd.setCursor(0, 1); // Start at character 0 on line 1


lcd.print("A:");
lcd.print(a, 0);
lcd.print("m p0:");
lcd.print(p0, 0);

// Since we're limited by the 16 characters per line on the LCD,


// the information is abbreviated. ex to implement).
} else {
Serial.println("error retrieving pressure measurement\n");
}
} else {
Serial.println("error starting pressure measurement\n");
}
} else {
Serial.println("error retrieving temperature measurement\n");
}
} else {
Serial.println("error starting temperature measurement\n");
}

delay(5000); // Pause for 5 seconds before the next read.


}

BMP180 Sensor Accuracy & Limitations:


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

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

3. 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).

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

Code for displaying data on computer serial monitor


#include <SFE_BMP180.h>
#include <Wire.h>

// You will need to create an SFE_BMP180 object, here called "pressure":

SFE_BMP180 pressure;

#define ALTITUDE 1649.0 // Altitude of Technical University of Kenya, Nairobi in


meters

void setup()
{
Serial.begin(9600);
Serial.println("REBOOT");

// Initialize the sensor (it is important to get calibration values stored on


the device).

if (pressure.begin())
Serial.println("BMP180 init success");
else
{
// Oops, something went wrong, this is usually a connection problem,
// see the comments at the top of this sketch for the proper connections.

Serial.println("BMP180 init fail\n\n");


while(1); // Pause forever.
}
}

void loop()
{
char status;
double T,P,p0,a;

// Loop here getting pressure readings every 10 seconds.

// If you want sea-level-compensated pressure, as used in weather reports,


// you will need to know the altitude at which your measurements are taken.
// We're using a constant called ALTITUDE in this sketch:

Serial.println();
Serial.print("provided altitude: ");
Serial.print(ALTITUDE,0);
Serial.print(" meters, ");
Serial.print(ALTITUDE*3.28084,0);
Serial.println(" feet");

// If you want to measure altitude, and not pressure, you will instead need
// to provide a known baseline pressure. This is shown at the end of the
sketch.

// You must first get a temperature measurement to perform a pressure reading.

// Start a temperature measurement:


// If request is successful, the number of ms to wait is returned.
// If request is unsuccessful, 0 is returned.

status = pressure.startTemperature();
if (status != 0)
{
// Wait for the measurement to complete:
delay(status);

// Retrieve the completed temperature measurement:


// Note that the measurement is stored in the variable T.
// Function returns 1 if successful, 0 if failure.

status = pressure.getTemperature(T);
if (status != 0)
{
// Print out the measurement:
Serial.print("temperature: ");
Serial.print(T,2);
Serial.print(" deg C, ");
Serial.print((9.0/5.0)*T+32.0,2);
Serial.println(" deg F");

// Start a pressure measurement:


// The parameter is the oversampling setting, from 0 to 3 (highest res,
longest wait).
// If request is successful, the number of ms to wait is returned.
// If request is unsuccessful, 0 is returned.

status = pressure.startPressure(3);
if (status != 0)
{
// Wait for the measurement to complete:
delay(status);

// Retrieve the completed pressure measurement:


// Note that the measurement is stored in the variable P.
// Note also that the function requires the previous temperature
measurement (T).
// (If temperature is stable, you can do one temperature measurement for
a number of pressure measurements.)
// Function returns 1 if successful, 0 if failure.

status = pressure.getPressure(P,T);
if (status != 0)
{
// Print out the measurement:
Serial.print("absolute pressure: ");
Serial.print(P,2);
Serial.print(" mb, ");
Serial.print(P*0.0295333727,2);
Serial.println(" inHg");

// The pressure sensor returns abolute pressure, which varies with


altitude.
// To remove the effects of altitude, use the sealevel function and
your current altitude.
// This number is commonly used in weather reports.
// Parameters: P = absolute pressure in mb, ALTITUDE = current altitude
in m.
// Result: p0 = sea-level compensated pressure in mb
p0 = pressure.sealevel(P,ALTITUDE); // we're at 1655 meters (Boulder,
CO)
Serial.print("relative (sea-level) pressure: ");
Serial.print(p0,2);
Serial.print(" mb, ");
Serial.print(p0*0.0295333727,2);
Serial.println(" inHg");

// On the other hand, if you want to determine your altitude from the
pressure reading,
// use the altitude function along with a baseline pressure (sea-level
or other).
// Parameters: P = absolute pressure in mb, p0 = baseline pressure in
mb.
// Result: a = altitude in m.

a = pressure.altitude(P,p0);
Serial.print("computed altitude: ");
Serial.print(a,0);
Serial.print(" meters, ");
Serial.print(a*3.28084,0);
Serial.println(" feet");
}
else Serial.println("error retrieving pressure measurement\n");
}
else Serial.println("error starting pressure measurement\n");
}
else Serial.println("error retrieving temperature measurement\n");
}
else Serial.println("error starting temperature measurement\n");

delay(5000); // Pause for 5 seconds.


}

You might also like