Interfacing BMP180 Barometer with ESP32

What is BMP180?

The BMP180 is a barometric pressure sensor capable of measuring atmospheric pressure and temperature. It is often used in weather stations and altitude measurement devices.

Working Principle of BMP180

The BMP180 sensor uses a piezo-resistive element to measure pressure. It communicates with ESP32 using I2C protocol to send pressure and temperature data.

  • The sensor measures atmospheric pressure and temperature.
  • Data is sent to ESP32 via I2C communication.
  • ESP32 processes and displays or logs the data.

Formula: Pressure = Function of Sensor Output

Components Required

  • ESP32 board
  • BMP180 Barometer
  • Jumper wires
  • Breadboard

Pin Configuration of BMP180

  • VCC: Connects to 3.3V on ESP32
  • GND: Connects to GND on ESP32
  • SCL: Connects to GPIO 22 (I2C Clock)
  • SDA: Connects to GPIO 21 (I2C Data)

BMP180 communicates using I2C protocol, which requires proper addressing and initialization.

Wiring BMP180 to ESP32

  • VCC -> 3.3V
  • GND -> GND
  • SCL -> GPIO 22
  • SDA -> GPIO 21

Arduino Code for ESP32 + BMP180

1#include <Wire.h>
2#include <Adafruit_Sensor.h>
3#include <Adafruit_BMP085_U.h>
4Adafruit_BMP085_Unified bmp;
5void setup() {
6  Serial.begin(115200);
7  if (!bmp.begin()) {
8    Serial.println("Couldn't find the sensor");
9    while (1);
10  }
11}
12void loop() {
13  sensors_event_t event;
14  bmp.getEvent(&event);
15  if (event.pressure) {
16    Serial.print("Pressure: ");
17    Serial.print(event.pressure);
18    Serial.println(" hPa");
19  }
20  delay(1000);
21}

Code Explanation (Line-by-Line)

  • #include <Adafruit_BMP085_U.h>: Includes the Adafruit BMP180 library for easy integration.
  • bmp.getEvent(&event);: Fetches the sensor's event data (pressure and temperature).

Applications

  • Weather stations
  • Altitude measurement
  • Environmental monitoring

Conclusion

The BMP180 is a versatile barometer sensor that can be easily integrated with ESP32 for various atmospheric and altitude-based applications.