Industrial manufacturing
Industrial Internet of Things | Industrial materials | Equipment Maintenance and Repair | Industrial programming |
home  MfgRobots >> Industrial manufacturing >  >> Manufacturing Technology >> Manufacturing process

BMP180 I2C Barometric Pressure Sensor – Raspberry Pi Integration Guide

Introduction

The Bosch BMP180 is a high‑accuracy digital barometric pressure sensor that communicates over I2C. In this guide you’ll learn how to wire it to a Raspberry Pi, enable the I2C bus, and read temperature and pressure with a ready‑to‑run Python script.

Module Overview

The module is a compact 15 × 13 mm PCB featuring a 5‑pin header. While most modules follow the same pin order, double‑check the labels on your board before connecting.

Pinout & Wiring

Connect the module to the Pi’s GPIO header (P1) as shown below. A simple diagram for a breadboard setup is also included.

Module PCB Description GPIO Header Pin
VCC 3.3 V P1‑01
GND Ground P1‑06
SCL I2C clock P1‑05
SDA I2C data P1‑03

With the device powered, running i2cdetect -y 1 should reveal an address of 0x77.

Enabling the I2C Bus

Enable I2C on your Pi (it is disabled by default) by running sudo raspi-config and selecting Interface Options → I2C → Yes, then reboot.

Python Example

The following script demonstrates how to read temperature (°C) and pressure (mbar) from the BMP180. It incorporates the calibration data stored on the sensor to deliver accurate results.

#!/usr/bin/python
import smbus
import time
from ctypes import c_short

DEVICE = 0x77  # Default I2C address
bus = smbus.SMBus(1)  # Pi 2 and later use bus 1

def convertToString(data):
    return str((data[1] + (256 * data[0])) / 1.2)

def getShort(data, index):
    return c_short((data[index] << 8) + data[index + 1]).value

def getUshort(data, index):
    return (data[index] << 8) + data[index + 1]

def readBmp180Id(addr=DEVICE):
    REG_ID = 0xD0
    chip_id, chip_version = bus.read_i2c_block_data(addr, REG_ID, 2)
    return chip_id, chip_version

def readBmp180(addr=DEVICE):
    REG_CALIB = 0xAA
    REG_MEAS = 0xF4
    REG_MSB = 0xF6
    REG_LSB = 0xF7
    CRV_TEMP = 0x2E
    CRV_PRES = 0x34
    OVERSAMPLE = 3

    cal = bus.read_i2c_block_data(addr, REG_CALIB, 22)
    AC1 = getShort(cal, 0)
    AC2 = getShort(cal, 2)
    AC3 = getShort(cal, 4)
    AC4 = getUshort(cal, 6)
    AC5 = getUshort(cal, 8)
    AC6 = getUshort(cal, 10)
    B1 = getShort(cal, 12)
    B2 = getShort(cal, 14)
    MB = getShort(cal, 16)
    MC = getShort(cal, 18)
    MD = getShort(cal, 20)

    bus.write_byte_data(addr, REG_MEAS, CRV_TEMP)
    time.sleep(0.005)
    msb, lsb = bus.read_i2c_block_data(addr, REG_MSB, 2)
    UT = (msb << 8) + lsb

    bus.write_byte_data(addr, REG_MEAS, CRV_PRES + (OVERSAMPLE << 6))
    time.sleep(0.04)
    msb, lsb, xsb = bus.read_i2c_block_data(addr, REG_MSB, 3)
    UP = ((msb << 16) + (lsb << 8) + xsb) >> (8 - OVERSAMPLE)

    X1 = ((UT - AC6) * AC5) >> 15
    X2 = (MC << 11) / (X1 + MD)
    B5 = X1 + X2
    temperature = (B5 + 8) >> 4

    B6 = B5 - 4000
    B62 = (B6 * B6) >> 12
    X1 = (B2 * B62) >> 11
    X2 = (AC2 * B6) >> 11
    X3 = X1 + X2
    B3 = (((AC1 * 4 + X3) << OVERSAMPLE) + 2) >> 2
    X1 = AC3 * B6 >> 13
    X2 = (B1 * B62) >> 16
    X3 = X1 + X2
    B4 = (AC4 * (X3 + 32768)) >> 15
    B7 = (UP - B3) * (50000 >> OVERSAMPLE)
    P = (B7 * 2) / B4
    X1 = (P >> 8) * (P >> 8)
    X1 = (X1 * 3038) >> 16
    X2 = (-7357 * P) >> 16
    pressure = P + ((X1 + X2 + 3791) >> 4)

    return temperature / 10.0, pressure / 100.0

def main():
    chip_id, chip_version = readBmp180Id()
    print("Chip ID     :", chip_id)
    print("Version     :", chip_version)
    temperature, pressure = readBmp180()
    print("Temperature :", temperature, "C")
    print("Pressure    :", pressure, "mbar")

if __name__ == "__main__":
    main()

Download & Run

Save the script directly to your Pi:

wget https://bitbucket.org/MattHawkinsUK/rpispy-misc/raw/master/python/bmp180.py

Make it executable and run:

chmod +x bmp180.py
./bmp180.py

Further Resources

Official BMP180 Datasheet
GPIO Reference Guide

Manufacturing process

  1. Alps Alpine Unveils HSPPAD143A: Advanced Waterproof Digital Pressure Sensor for IoT & Wearables
  2. Infineon Unveils XENSIV DPS368: Ultra‑Compact, High‑Precision Barometric Pressure Sensor
  3. Infineon Introduces the KP276: Industry‑Leading Digital Turbo MAP Sensor for Superior Engine Efficiency
  4. Digital Magnetic Hall Sensors: Fundamentals, Design, and Automotive Applications
  5. Bosch BMP390: 50% More Accurate Altitude Sensor for Smartphones, Wearables, and Indoor Navigation
  6. Build a Raspberry Pi Temperature Logger with a $5 I2C Sensor
  7. Reading a Linear Hall Sensor with Raspberry Pi: Java Guide & ADC0832 Insights
  8. Digital Light Sensor – Power an LED with Ambient Light Using Windows 10 IoT Core
  9. Advanced Liquid Metal Wearable Pressure Sensor for Precise Health Monitoring
  10. Barometric Pressure Sensors Explained: Key Features & Applications