Home / Projects / Arduino Projects / Arduino Altimeter Project Using BMP085

Arduino Altimeter Project Using BMP085

pcbway

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:

BMP085 Arduino
SDA A4
SCL A5
VCC 5V
GND GND

 

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

Nokia 3310/5110 LCD Arduino
RST D3
CE D4
DC D5
DIN D11
CLK D13
VCC 3.3V
LIGHT 5V
GND GND

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:


Check Also

Arduino clap switch for RGB

Clap Switch for RGB LEDs using Arduino

Introduction This week’s Arduino project is a classic one and ideal for beginners. Here I …

One comment

Leave a Reply

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