Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Arduino
50 min
Share

Measure atmospheric pressure and altitude using BMP180

You may have asked yourself before how aircraft know their height above sea level while flying, in fact, planes know the height from the value of atmospheric pressure, In this tutorial we will explain the use of the BMP180 sensor for measuring atmospheric pressure and temperature.

Project Video

Overview

In this tutorial, we will learn how to work the BMP 180 pressure sensor with Arduino code to measure atmospheric pressure and temperature and altitude. This sensor has a very small shape through which the atmospheric pressure can be measured. Also, as this pressure decreases as it rises above sea level, it can also be used to get altitude.

Getting the Items

Arduino Uno R3 (Voltaat Version)
Get Item
Barometric Pressure Sensor (BMP180)
Get Item
Jumper Wires – Male to Female (40 Pack)
Get Item

Steps

Wiring it Up

Connect the wires between the BMP180  and the Arduino, as shown in the image below.


Connections from the BMP180 to arduino :

     • Vin → Arduino 5V pin


     • GND →  Arduino GND pin


     • SCL →  Arduino pin A5


    • SDA → Arduino pin A4

Coding


/*
Voltaat learn (http://learn.voltaat.com)
Link for full tutorial: put the link of the tutorial here

Tutorial: Measure_altitude_using_Bmp180!

The function of this sketch is to obtain the altitude from the BMP180 sensor and display it on your computer

Connections from the BMP180 to arduino :

• Vin → Arduino 5V pin
• GND →  Arduino GND pin
• SCL →  Arduino pin A5
• SDA → Arduino pin A4

*/

// First, add the BMP180 sensor library and the (wire) library to the code
#include "Wire.h"
#include "SFE_BMP180.h"

SFE_BMP180 bmp180;
/* Set here the value of the Po variable equal to the atmospheric pressure at sea level*/
float Po = 1005.0;

void setup() {
 Serial.begin(9600);
 bool success = bmp180.begin();

 if (success) {
   Serial.println("BMP180 init success");
 }
}

void loop() {
 char status;
 double T, P, alt;
 bool success = false;

 status = bmp180.startTemperature();

 if (status != 0) {
   delay(1000);
   status = bmp180.getTemperature(T);

   if (status != 0) {
     status = bmp180.startPressure(3);

     if (status != 0) {
       delay(status);
       status = bmp180.getPressure(P, T);

       if (status != 0) {
/* In this part of the code, we will only display the temperature and pressure values on the screen */

         Serial.print("Pressure: ");
         Serial.print(P);
         Serial.println(" hPa");

         Serial.print("Temperature: ");
         Serial.print(T);
         Serial.println(" C");

         alt = bmp180.altitude(P, Po);
         Serial.print("Altitude: ");
         Serial.print(alt);
         Serial.println(" Meters");
       }
     }
   }
 }
}

   
   

Testing it Out

You should also make sure you have chosen the right baud rate (9600) as specified in the code.

Now access the serial monitor on your Arduino IDE by clicking on the magnifying glass icon at the top right corner.

know when your plant needs watering

Now, as shown in the image below, the serial monitor displays temperature and pressure and altitude.

know when your plant needs watering

Resources

No items found.