Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Arduino-based altitude meter using BMP180 sensor

By Nikhil Agnihotri July 23, 2023

BMP180 is a digital pressure sensor designed for low-power, low-voltage operation in mobile phones, navigation devices, and personal digital assistants. The sensor has an I2C interface to communicate sensor data. It can operate on 2.5~3.6V and consumes only 12 uA even in the ultra-high-resolution mode. The sensor can be used for several applications, including measuring altitude from sea level, measurement of altitude from ground, measuring vertical velocity, and detecting weather conditions.

In this project, we have developed an altitude meter using the BMP180 sensor and our favorite microcontroller board – Arduino. This altitude meter displays real-time altitude from sea level on a small OLED display. The OLED display used to current altitude is SSD1306.

Components required

  1. Arduino UNO/any Arduino board x1
  2. BMP180 pressure sensor x1
  3. SSD1306 OLED x1
  4. Connecting wires/jumper wires

Circuit connections
The altitude meter is designed by interfacing the SSD1306 OLED and BMP180 pressure sensor with the Arduino UNO. BMP180 sensor has four terminals – Vin, Gnd, SCL, and SDA. The Vin and Gnd pins of the sensor are connected to 3.3V out and a ground pin of Arduino UNO. The SCL and SDA pins of the sensor can be connected to any of the I2C ports on the Arduino board. The I2C ports on Arduino UNO are shown in the image below.

The SSD1306 OLED is connected to Arduino using a physical SPI port. For interfacing SSD1306 OLED via physical SPI port, connect the D0/SCK and D1/MOSI pins of SSD1306 OLED to pins D13 and D11 of Arduino, respectively. Connect pins DC, RESET, and CS of SSD1306 to pins D9, D10, and D8 of Arduino, respectively. The final circuit looks as follows.

Arduino sketch

How the circuit works
BMP180 is a piezoresistive sensor that is used to detect atmospheric pressure. The sensor measures both temperature and pressure as both of these factors affect air density. The temperature is measured to compensate for pressure readings according to the changes in air density. The sensor outputs the atmospheric pressure in Pascals over its I2C interface.

There are Arduino libraries available for BMP180 sensors from Adafruit and Sparkfun. In this project, we are using the library from Sparkfun, and this library converts the sensor output in Pascals to hectoPascals.

The sensor first reads uncompensated temperature reading, then uncompensated pressure reading. Finally, it does some complex calculations with both these readings involving a number of coefficients stored in its EEPROM to give accurate barometric pressure and temperature. The barometric pressure varies with the altitude, and the atmospheric pressure decreases with the increase in altitude and vice-versa. A change of 1 Hectopascal corresponds to around 8 meters in altitude. The BMP180 is a very sensitive sensor and responds to even minute changes in true atmospheric pressure. The following equation gives the altitude for sea level.

altitude = 44330 * (1 – (Pcurrent/Psealevel)^(1/5.255))

The sensor itself takes care to perform all these complex calculations and straightforwardly outputs the current true barometric pressure.

Arduino listens to the barometric pressure from the BMP180 sensor over its I2C interface. The Sparkfun library provides reading temperature, pressure, and altitude functions, and Arduino reads the altitude reading and displays the reading over SSD1306  OLED.

The OLED display is connected to the physical SPI port of the Arduino. So, the OLED communicates with the controller over the SPI interface while the BMP180 sensor relays the pressure readings over the I2C interface. Arduino reads altitude from BMP180 via I2c and displays it on the OLED display via SPI. The displayed output reading is in meters.

The code
First of all, the SPI and Wire libraries are imported for data communication over SPI and I2C interfaces. The Adafruit_GFX and Adafruit_SSD1306 libraries are imported to work with the SSD1306 OLED display. The Sparkfun BMP180 library is imported to work with the BMP180 sensor. Constants and pin assignments for the OLED display are defined. An object ‘display’ of class ‘Adafruit_SSD1306’ is instantiated to deal with the OLED display, and an object ‘pressure’ of class ‘ SFE_BMP180’ is instantiated to deal with the BMP180 sensor. A variable ‘baseline’ is defined to store the reference atmospheric pressure at sea level. Next, a bitmap array is defined to store EEWORLDONLINE logo.

In the setup() function, the baud rate for data communication is set to 9600 bps. The display is initialized using display.begin() method. If the pressure detects the BMP180 sensor.begin() method, the logo is flashed to the OLED display. Otherwise, the “Device not working” message flashes to the OLED.

In the loop() function, variables to store pressure and altitude readings are declared. The pressure is read by calling the user-defined function getPressure(). The baseline atmospheric pressure for the current location is defined. This is set to 1013 as the altitude is read with respect to sea level here. The altitude is measured by calling the altitude() method overpressure object with the given baseline. The OLED display is cleared using display.clearDisplay() method. The cursor is set to start the screen using display. setCursor() method. The text size is set to 2 using display. setTextSize() method. The text color is set to white using setTextColor() method. The read altitude is printed to OLED using display.print() and display.println() methods. The readings flash on OLED when the display.display(0 method is called. A delay of 1500 ms is provided by calling delay() function before the next iteration of the loop() function.

The getPressure() function reads the barometric pressure from BMP180 sensor. It uses the Sparkfun library’s startTemperature(), getTemperature()  and startPressure() methods.

Result

 

You may also like:

  • pollution monitoring
    Arduino-based portable pollution monitor with OLED display

  • Arduino-based walking steps and distance calculator

  • Arduino-based multicolour LED chaser

  • Arduino-based electronic leveling device

  • Arduino-based heartbeat monitor with graphical heartbeat display

  • Insight into Arduino: Beginner’s Guide

Filed Under: Arduino Projects, Electronic Projects, Sensors, Tutorials, Video
Tagged With: Arduino, Arduino altitude meter, Arduino based altitude indicator, Arduino based altitude meter, Arduino BMP180, Arduino pressure sensor, Arduino projects, Arduino SSD1306, Arduino SSD1306 OLED
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Reducing "shoot-through" in offline Full Bridge SMPS?
  • High Side current sensing
  • How to simulate power electronics converter in PSpice?
  • Voltage mode pushpull is a nonsense SMPS?
  • Layout IRN reduction in Comparator

RSS Electro-Tech-Online.com Discussions

  • Back to the old BASIC days
  • Parts required for a personal project
  • PIC KIT 3 not able to program dsPIC
  • Failure of polypropylene motor-run capacitors
  • Siemens large industrial PLC parts

Featured – RPi Python Programming (27 Part)

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol
  • RPi Python Programming 26 – Interfacing ADXL345 accelerometer sensor with Raspberry Pi

Recent Articles

  • What is AWS IoT Core and when should you use it?
  • AC-DC power supply extends voltage range to 800 V DC
  • Infineon’s inductive sensor integrates coil system driver, signal conditioning circuits and DSP
  • Arm Cortex-M23 MCU delivers 87.5 µA/MHz active mode
  • STMicroelectronics releases automotive amplifiers with in-play open-load detection

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe