Skip to main content
ESPBoards

ESP32 BMP180 Barometric Pressure Sensor

The BMP180 is a high-precision digital barometric pressure and temperature sensor, designed for applications such as weather monitoring, altitude measurement, and GPS enhancement. It operates via the I²C protocol, ensuring seamless integration with embedded systems.

⬇️ Jump to Code Examples

Arduino Core Image
ESP-IDF Image
ESPHome Image
PlatformIO Image

🔗 Quick Links

BMP180 Barometric Pressure Sensor Datasheet ButtonBMP180 Barometric Pressure Sensor Specs ButtonBMP180 Barometric Pressure Sensor Specs ButtonBMP180 Barometric Pressure Sensor Specs Button

ℹ️ About BMP180 Barometric Pressure Sensor

The BMP180, developed by Bosch Sensortec, is an enhanced version of the BMP085, offering improved accuracy and lower power consumption. Designed for weather monitoring, altimetry, and navigation, it provides precise barometric pressure and temperature readings.

Key Features #

  • Upgraded Accuracy & Efficiency – More precise and power-efficient than the BMP085.
  • Wide Pressure Range – Measures atmospheric pressure for altitude tracking.
  • Integrated Temperature Sensor – Enables accurate weather and altitude calculations.
  • I²C Communication – Seamless integration with ESP32, Arduino, and other microcontrollers.

With its compact design and improved performance, the BMP180 is a reliable choice for weather stations, drones, and GPS-enhanced applications. 🚀

⚙️ BMP180 Sensor Technical Specifications

Below you can see the BMP180 Barometric Pressure Sensor Technical Specifications. The sensor is compatible with the ESP32, operating within a voltage range suitable for microcontrollers. For precise details about its features, specifications, and usage, refer to the sensor’s datasheet.

  • Type: environment
  • Protocol: I2C
  • Interface: I²C
  • Pressure Range: 300 hPa to 1100 hPa
  • Temperature Range: -40°C to +85°C
  • Operating Voltage: 1.8V to 3.6V
  • Resolution: 0.01 hPa
  • Accuracy: ±0.12 hPa
  • Power Consumption: 3 µA in sleep mode
  • Output: Temperature and Pressure (Digital)
  • Package Dimensions: 3.6 mm × 3.8 mm × 0.93 mm
  • Weight: 1.0 g

🔌 BMP180 Sensor Pinout

Below you can see the pinout for the BMP180 Barometric Pressure Sensor. The VCC pin is used to supply power to the sensor, and it typically requires 3.3V or 5V (refer to the datasheet for specific voltage requirements). The GND pin is the ground connection and must be connected to the ground of your ESP32!

The BMP180 module includes the following pins: VIN: Power input (3.3V or 5V compatible). GND: Ground pin. SDA: Serial Data pin for I²C communication. SCL: Serial Clock pin for I²C communication.

🧵 BMP180 Wiring with ESP32

Below you can see the wiring for the BMP180 Barometric Pressure Sensor with the ESP32. Connect the VCC pin of the sensor to the 3.3V pin on the ESP32 or external power supply for power and the GND pin of the sensor to the GND pin of the ESP32. Depending on the communication protocol of the sensor (e.g., I2C, SPI, UART, or analog), connect the appropriate data and clock or signal pins to compatible GPIO pins on the ESP32, as shown below in the wiring diagram.

To interface the BMP180 module with an ESP32 (I²C mode): VIN: Connect to 3.3V pin on ESP32. GND: Connect to GND pin on ESP32. SDA: Connect to GPIO21 (default SDA). SCL: Connect to GPIO22 (default SCL).

🛠️ BMP180 Barometric Pressure Sensor Troubleshooting

This guide outlines a systematic approach to troubleshoot and resolve common problems with the . Start by confirming that the hardware connections are correct, as wiring mistakes are the most frequent cause of issues. If you are sure the connections are correct, follow the below steps to debug common issues.

💻 Library Not Found Error

Issue: The Arduino IDE cannot find the required BMP180 library.

Solution: Ensure that you have installed the Adafruit BMP180 library from the Arduino Library Manager. Restart the Arduino IDE after installation.

❌ Sensor Initialization Failure

Issue: The BMP180 sensor fails to initialize, and the error message Could not find a valid BMP180 sensor appears.

Solution: Verify the wiring connections and ensure the sensor is receiving power. Use an I²C scanner to detect the sensor's address.

⚠️ Incorrect Readings

Issue: The sensor outputs incorrect temperature or pressure readings.

Solution: Check the reference sea-level pressure value and recalibrate the sensor if necessary.

💻 Code Examples

Below you can find code examples of BMP180 Barometric Pressure Sensor with ESP32 in several frameworks:

If you encounter issues while using the BMP180 Barometric Pressure Sensor, check the Common Issues Troubleshooting Guide.

Arduino Core Image

ESP32 BMP180 Arduino IDE Code Example

Example in Arduino IDE

Fill in your main Arduino IDE sketch file with the following code to use the BMP180 Barometric Pressure Sensor:

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP085_U.h>

Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085);

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

void loop() {
sensors_event_t event;
bmp.getEvent(&event);
if (event.pressure) {
Serial.print("Pressure: ");
Serial.print(event.pressure);
Serial.println(" hPa");
}
float temperature;
bmp.getTemperature(&temperature);
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" *C");
delay(2000);
}

This Arduino code initializes the BMP180 sensor using the Adafruit BMP180 library. It reads and prints atmospheric pressure and temperature values every two seconds.

Connect your ESP32 to your computer via a USB cable, Ensure the correct Board and Port are selected under Tools, Click the "Upload" button in the Arduino IDE to compile and upload the code to your ESP32.

ESP-IDF Image

ESP32 BMP180 ESP-IDF Code Example
Example in Espressif IoT Framework (ESP-IDF)

If you're using ESP-IDF to work with the BMP180 Barometric Pressure Sensor, here's how you can set it up and read data from the sensor. Fill in this code in the main ESP-IDF file:

#include "bmp180.h"
#include "esp_log.h"

#define I2C_MASTER_SCL_IO 22
#define I2C_MASTER_SDA_IO 21
#define I2C_MASTER_FREQ_HZ 100000
#define BMP180_ADDR 0x77

static const char *TAG = "BMP180";

void app_main() {
ESP_LOGI(TAG, "Initializing BMP180...");
bmp180_dev dev;
bmp180_init(&dev, I2C_MASTER_SCL_IO, I2C_MASTER_SDA_IO, I2C_MASTER_FREQ_HZ, BMP180_ADDR);

while (1) {
bmp180_data data;
bmp180_read(&dev, &data);
ESP_LOGI(TAG, "Temperature: %.2f°C", data.temperature);
ESP_LOGI(TAG, "Pressure: %.2f hPa", data.pressure);
vTaskDelay(2000 / portTICK_PERIOD_MS);
}
}

This ESP-IDF code configures the ESP32 to interface with the BMP180 sensor over I²C. The bmp180_init function initializes the sensor, and bmp180_read fetches pressure and temperature readings.

Update the I2C pins (I2C_MASTER_SDA_IO and I2C_MASTER_SCL_IO) to match your ESP32 hardware setup, Use idf.py build to compile the project, Use idf.py flash to upload the code to your ESP32.

ESPHome Image

ESP32 BMP180 ESPHome Code Example

Example in ESPHome (Home Assistant)

Fill in this configuration in your ESPHome YAML configuration file (example.yml) to integrate the BMP180 Barometric Pressure Sensor

sensor:
- platform: bmp180
temperature:
name: "BMP180 Temperature"
pressure:
name: "BMP180 Pressure"
address: 0x77

This ESPHome configuration allows the BMP180 sensor to provide temperature and pressure readings over I²C, using the default address 0x77.

Upload this code to your ESP32 using the ESPHome dashboard or the esphome run command.

PlatformIO Image

ESP32 BMP180 PlatformIO Code Example

Example in PlatformIO Framework

For PlatformIO, make sure to configure the platformio.ini file with the appropriate environment and libraries, and then proceed with the code.

Configure platformio.ini

First, your platformio.ini should look like below. You might need to include some libraries as shown. Make sure to change the board to your ESP32:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
adafruit/Adafruit BMP180 Library
wire
monitor_speed = 115200

ESP32 BMP180 PlatformIO Example Code

Write this code in your PlatformIO project under the src/main.cpp file to use the BMP180 Barometric Pressure Sensor:

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

Adafruit_BMP085 bmp;

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

void loop() {
Serial.print("Temperature: ");
Serial.print(bmp.readTemperature());
Serial.println(" *C");

Serial.print("Pressure: ");
Serial.print(bmp.readPressure() / 100.0);
Serial.println(" hPa");
delay(2000);
}

This PlatformIO code integrates the BMP180 sensor to read temperature and pressure values, printing them every two seconds.

Upload the code to your ESP32 using the PlatformIO "Upload" button in your IDE or the pio run --target upload command.

Conclusion

We went through technical specifications of BMP180 Barometric Pressure Sensor, its pinout, connection with ESP32 and BMP180 Barometric Pressure Sensor code examples with Arduino IDE, ESP-IDF, ESPHome and PlatformIO.