Arduino Altimeter Project Using BMP085

This Arduino Altimeter project features the BMP085 atmospheric pressure sensor by Bosch. Because atmospheric pressure is directly related to altitude above sea level, we can use this sensor to determine current height with respect to the height of the oceans. The height is given in meters and is displayed on a Nokia 3310/5110 LCD.

Materials

Concept

The height with respect to sea level and atmospheric pressure is related through the formula:

{\displaystyle p\approx p_{0}\cdot \exp \left(-{\frac {g\cdot M\cdot h}{R_{0}\cdot T_{0}}}\right)}

Where

p0 = sea level standard atmospheric pressure = 101325 Pa
T0 = sea level standard temperature = 288.15 K
g = Earth-surface gravitational acceleration = 9.80665 m/s2
M = molar mass of dry air = 0.0289644 kg/mol
R0 = universal gas constant = 8.31447 J/(mol•K)

Since most of these values are constants, we can create a simple formula to convert pressure to height. The Adafruit BMP085 library has done that for us and reading the altitude is simply:

bmp.readAltitude()

This function, however, always assumes that sea level pressure (SLP) is always 101325 Pa which is not the case. The actual SLP can be the parameter for this function for a more accurate altitude reading. For example, this is what Accuweather tells me about my city:

That’s 29.80 inches of Mercury (another unit of pressure). A quick google reveals that this is equivalent to 100.9144 kiloPascals. I then used this value to adjust the altitude readings.

Wiring Diagram

 

The wiring between the BMP085 and Arduino Nano is simple:

BMP085Arduino
SDAA4
SCLA5
VCC5V
GNDGND

 

Here’s the connection between the Arduino Nano and the Nokia 3310/5110 LCD:

Nokia 3310/5110 LCDArduino
RSTD3
CED4
DCD5
DIND11
CLKD13
VCC3.3V
LIGHT5V
GNDGND

Arduino Sketch

#include <Wire.h>
#include <Adafruit_BMP085.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>

Adafruit_BMP085 bmp;
Adafruit_PCD8544 display = Adafruit_PCD8544(5, 4, 3);
  
void setup() {
  Serial.begin(9600);
  display.begin();
  display.setContrast(50);
  
  display.setTextSize(1);
  display.setTextColor(BLACK);
  display.setCursor(0,0);
  display.println("BMP085 Altimeter");
  delay(2000);
  display.clearDisplay();
  if (!bmp.begin()) {
	Serial.println("Could not find a valid BMP085 sensor, check wiring!");
	while (1) {}
  }
}
  
void loop() {
    display.setTextSize(1);
    display.println("Altitude: ");
    display.println();
    display.setTextSize(2);
    display.print(bmp.readAltitude(100914));
    display.println(" m");
    display.display();
    display.clearDisplay();
    delay(500);
}

For using the Nokia 3310/5110 LCD with the Arduino, I used Adafruit’s PCD8544 library and GFX library . More information about this library can be read on my Arduino Nokia 3310 interfacing article.

As for the sensor, I wrote an Arduino BMP085 tutorial on how to use it with Adafruit’s BMP085 library .

These libraries made the project fairly simple. All it needs to read altitude is this function:

bmp.readAltitude(100914)

The 100914 parameter is the SLP in my area according to Accuweather.

Writing to the LCD is simply,

display.print(bmp.readAltitude(100914));

The rest of the sketch are just for setting up the display (text color, size and contrast).

Project Images

Here’s some images for this project:

    Leave a Reply

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