Random Nerd Tutorials

ESP32 with BMP180 Barometric Sensor – Guide


This guide shows you how to use the BMP180 barometric sensor with the ESP32 to read pressure and temperature. We’ll show you how to wire the sensor to the ESP32, install the needed library, and how to write the sketch in the Arduino IDE.

Introducing the BMP180 Barometric Sensor

The BMP180 barometric sensor is shown in the following figure.

This sensor measures the absolute pressure of the air around it, and it has a measuring range from 300 to 1100hPa with an accuracy down to 0.02 hPa. The sensor also measures temperature, and altitude (because pressure changes with altitude, you can calculate the altitude based on the pressure at the sealevel).

Wiring BMP180 Sensor to the ESP32

The BMP180 barometric sensor uses I2C communication protocol. So, you need to use the SDA and SCL pins of your ESP32.

BMP180 Wiring to ESP32
Vin 3.3V

Reading Temperature, Pressure, And Altitude

In this section we’ll show you how to read pressure and temperature from the BMP180 barometric sensor using the ESP32. We’ll also show you how to estimate altitude.

Parts required

For this example, you need the following parts:

You can use the preceding links or go directly to MakerAdvisor.com/tools to find all the parts for your projects at the best price!


Wire the BMP180 barometric sensor to the ESP32 as shown in the following schematic diagram.

Important note: this schematic was made using the ESP32 DEVKIT DOIT board. The SCL (GPIO22) and SDA (GPIO 21) pins of your ESP32 may be located on a different place. Always check the pinout for the ESP32 version you are using.

Preparing the ESP32 board in Arduino IDE

In order to upload code to your ESP32 using Arduino IDE, you should install an add-on for the Arduino IDE that allows you to program the ESP32 using the Arduino IDE and its programming language. Follow the next tutorial to prepare your Arduino IDE:

Installing the BMP_085 Library

One of the easiest ways to read pressure, temperature and altitude with the BMP180 sensor is using the BMP_085 library by Adafruit. Follow the next steps to install the library in your Arduino IDE:

  1. Click here to download the Adafruit-BMP085 library. You should have a .zip folder in your Downloads folder
  2. Unzip the .zip folder and you should get Adafruit-BMP085-Library-master folder
  3. Rename your folder from Adafruit-BMP085-Library-master to Adafruit_BMP085_Library
  4. Move the Adafruit_BMP085_Library folder to your Arduino IDE installation libraries folder
  5. Finally, re-open your Arduino IDE


The library provides an example showing how to get temperature, pressure, and altitude. Go to File > Examples > Adafruit BMP085 Library > BMP085test.

Note: you can display the BMP180 sensor readings in an ESP32 web server.

The code starts by importing the needed libraries:

#include <Wire.h>
#include <Adafruit_BMP085.h>

You create an Adafruit_BMP085 object called bmp.

Adafruit_BMP085 bmp;

In the setup() the sensor is initialized:

void setup() {
  if (!bmp.begin()) {
  Serial.println("Could not find a valid BMP085/BMP180 sensor, check wiring!");
  while (1) {}

Reading Temperature

To read the temperature you just need to use:


Reading Pressure

Reading the pressure is also straighforward:


The pressure readings are given in Pascal units.

Reading Altitude

Because the pressure changes with altitude, you can estimate the altitude based on your location’s pressure when compared with the sea level pressure. The example gives you two different ways to estimate altitude.

1. The first assumes a standard barometric pressure of 10132 Pascal at the sea level.  You get the altitude as follows:


2. The second method assumes the current pressure at the sea level. For example, if at the moment the pressure at the sea level is 101500 Pa, you get the altitude as follows:



Upload the code to your ESP32. Make sure you have the right board and COM port selected.

Then, open the Serial Monitor at a baud rate of 9600. You should get the sensor readings, as shown in the following figure.

Wrapping Up

In this guide we’ve shown you how to use the BMP180 barometric sensor to read temperature, pressure, and estimate altitude using the ESP32.

We hope you’ve found this guide useful. If you liked this post, you may also like other content related with ESP32:

Thanks for reading.

20 Easy Raspberry Pi Projects

Our new book is a beginner-friendly collection of electronics projects, perfectly suited for hobbyists, parents, kids, parents, and educators looking to level up their hardware skills - GET THE BOOK »

Recommended Resources

Home Automation using ESP8266 »
Build IoT projects and home automation gadgets with the ESP8266 Wi-Fi module.

Build a Home Automation System »
Learn how to build a automation system using open-source hardware and software from scratch.

Arduino Step-by-Step Projects »
Build 25 cool Arduino projects with our couse even with no prior experience!

Leave a Comment: