Close Menu
    Facebook X (Twitter) Instagram Pinterest YouTube
    Trending
    • Disable SSH Password Login on Raspberry Pi
    • Elecrow Meteor IPS Touchscreen with RGB LEDs
    • Pi Pico Pinout Display on the Command Line
    • How to Add a Raspberry Pi Pico Reset Button
    • Pi Pico Onboard LED
    • Pi Pico W Pinout and Power Pins
    • CrowPi L Raspberry Pi Laptop and Learning Platform
    • Pi Pico W Launched
    Facebook X (Twitter) Instagram Pinterest YouTube RSS
    Raspberry Pi SpyRaspberry Pi Spy
    • Home
    • Categories
      • General
      • Hardware
      • Programming
      • Python
      • Software
      • Tutorials & Help
    • BerryClip
      • BerryClip Instructions
      • BerryClip Plus Instructions
      • Videos & Reviews
    • Buy
      • Buy Pi
      • Buy Pi Accessories
      • Buy Books
    • Tools
      • Ultimate Raspberry Pi Alexa Skill
      • Pi Power Estimator App
      • Pi-Lite 14×9 LED Matrix Sprite Editor
      • RPiREF Pin-out Reference App
      • Simple Ohm’s Law Calculator
      • Web Sites & Links
    • Tutorials & Help
        Featured
        November 9, 20200

        Raspberry Pi Temperature Monitoring

        Recent
        February 16, 2024

        Disable SSH Password Login on Raspberry Pi

        December 23, 2022

        How to Add a Raspberry Pi Pico Reset Button

        November 20, 2022

        Pi Pico Onboard LED

      1. Contact Us
      2. Site Map
      Raspberry Pi SpyRaspberry Pi Spy
      You are at:Home»Hardware»Interfaces»I2C»Using the BMP180 I2C Temperature and Pressure Sensor in Python
      BMP180 Pressure Temperature Module

      Using the BMP180 I2C Temperature and Pressure Sensor in Python

      10
      By Matt on April 21, 2015 I2C, Sensors, Tutorials & Help

      The BMP180 device is a digital barometric pressure sensor. This is available on a small module which provides access to the sensor via the I2C interface. This allows us to easily connect it to the Raspberry Pi with a minimum of wiring.

      My module is a small pcb measuring 15x13mm with a 5 pin header. The order of the pins may vary on other modules so keep an eye on the labels so you connect up the correct wires from the Pi.

      BMP180 Pressure Temperature Module

      The BMP180 is made by Bosch and the official BMP180 datasheet includes all the technical details.

      Configure I2C Interface

      In order to use this module you must enable the I2C interface on the Raspberry Pi as it is not enabled by default. This is a fairly easy process and is described in my Enabling The I2C Interface On The Raspberry Pi tutorial.

      Connecting Hardware

      The table below shows how the module is connected to the Raspberry Pi’s GPIO header (P1). Please refer to my GPIO header guide for a diagram.

      Module PCBDescGPIO Header Pins
      VCC3.3VP1-01
      GNDGroundP1-06
      SCLI2C SCLP1-05
      SDAI2C SDAP1-03
      3.3V––

      Here is a diagram of a breadboard setup. If you are connecting the module’s four pins directly to the Pi you only need four female-female wires.

      BMP180 Module Setup

      The breadboard diagram uses a custom part I defined in Fritzing. Other modules are available which have different pin arrangements so make sure you are connecting the correct pins to the Pi if yours is different to the one shown in this tutorial.

      With the device connected and the Pi powered up the “i2cdetect” command should show the device with address 0x77.

      Example Python Script

      My example script to read pressure and temperature data from the sensor can be downloaded directly to your Pi using the following command :

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

      or use this link in a browser.

      In order to run it you can use the following command :

      sudo python bmp180.py

      The output looks something like this :

      BMP180 Example Output

      The module is available from Amazon and many other online electronics shops. You can also find .

      Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
      Previous ArticleUsing the BH1750FVI I2C Digital Light Sensor
      Next Article SlushEngine Stepper Motor Controller For Raspberry Pi

      Related Posts

      Disable SSH Password Login on Raspberry Pi

      How to Add a Raspberry Pi Pico Reset Button

      Pi Pico Onboard LED

      10 Comments

      1. Simon on May 20, 2015 3:37 pm

        This looks really nice to make, I think I will give it a go at porting it to C as a afternoon project 🙂

        Reply
      2. Manuel on January 21, 2016 11:02 am

        Very interesting! And together with your other article
        https://www.raspberrypi-spy.co.uk/2015/06/basic-temperature-logging-to-the-internet-with-raspberry-pi/
        I think I have found *the* way to log temperature!

        By the way. the sensor specs link seems to have been moved to
        https://www.bosch-sensortec.com/en/homepage/products_3/environmental_sensors_1/bmp180_1/bmp180

        Reply
      3. Aidan on January 30, 2016 10:28 pm

        Great tutorial! Works a treat, though a couple of the Python lines have become concatonated while transferring to the webpage: 22 and 72.
        I’ve since discovered the Bosch BME280 that also includes a humidity sensor(!) and has both I2C + SPI interfaces. Can be obtained cheaply from a well-known auction site.

        Reply
        • Matt on February 2, 2016 6:56 pm

          Thanks Aidan. I’ve corrected those lines.

          Reply
      4. techsteer on May 29, 2016 10:44 pm

        Whats wrong with my sensor BME280 (not 180).
        I am trying it on Pi3. the SDA and SCL pins are connected to same pins on Pi as you have shown. But gound and Vcc are different and that shouldnt matter.

        when i run i2cdetect it shows at 76

        pi@raspberrypi:~/Desktop $ sudo i2cdetect -y 1
        0 1 2 3 4 5 6 7 8 9 a b c d e f
        00: — — — — — — — — — — — — —
        10: — — — — — — — — — — — — — — — —
        20: — — — — — — — — — — — — — — — —
        30: — — — — — — — — — — — — — — — —
        40: — — — — — — — — — — — — — — — —
        50: — — — — — — — — — — — — — — — —
        60: — — — — — — — — — — — — — — — —
        70: — — — — — — 76 —
        pi@raspberrypi:~/Desktop $

        So i changed line 6 of the code, like this
        DEVICE = 0x77 # Default device I2C address

        My output is like this

        pi@raspberrypi:~/Desktop $ sudo python pressureBMP280.py
        Chip ID : 88
        Version : 0

        Temperature : 82.7 C
        Pressure : -43958.91 mbar

        Reply
        • Matt on July 28, 2016 12:12 am

          The BME280 has different registers to the BMP180 so requires different code. I’ve just written a draft blog post for the BME280 which I will publish within the next few days. I just need to write a few more paragraphs. UPDATE: New BME280 post here > https://www.raspberrypi-spy.co.uk/2016/07/using-bme280-i2c-temperature-pressure-sensor-in-python

          Reply
      5. Matt on February 2, 2017 7:06 pm

        Did you follow the Enable I2C Interface on the Raspberry Pi guide as stated above? The i2c setup on the latest version of Raspbian is different to Wheezy so whatever process you are using for that is probably out of date.

        Reply
      6. Shashi on February 23, 2017 6:36 am

        Matt, Thanks for the code – works right out of the box.
        My question : How is the pressure being calculated:

        I live in Bangalore and current official “air pressure” is 1018 mbars, but the python code comes up with 913 mbars instead of something close to 1018.
        https://www.worldweatheronline.com/bangalore-weather/karnataka/in.aspx

        The ALTITUDE I’m in is 920 meters.

        There is something called “Absolute” pressure and “relative” Pressure.

        The absolute pressure I believe is 913 mbars and the relative pressure is “1018” approx and I think your code is represnting just the absolute pressure” If I am not mistaken.
        Appreciate if both can be displayed.

        But thanks for the ready made code. So much helpful for starters like me.

        Reply
      7. Benny on February 11, 2022 7:15 pm

        Dear,

        Where did you find the fritzing part for the bmp180 and is it posible to share with us?

        Thanks!

        Reply
        • Matt on February 13, 2022 3:30 pm

          Hello, it was back in 2015 but I think I drew the component from scratch. I’ve upload the Fritzing part to : https://bitbucket.org/MattHawkinsUK/rpispy-misc/src/master/misc/BMP180%20Module.fzpz

          Reply

      Leave A Reply Cancel Reply

      This site uses Akismet to reduce spam. Learn how your comment data is processed.

      Recent Posts
      February 16, 2024

      Disable SSH Password Login on Raspberry Pi

      March 13, 2023

      Elecrow Meteor IPS Touchscreen with RGB LEDs

      December 26, 2022

      Pi Pico Pinout Display on the Command Line

      December 23, 2022

      How to Add a Raspberry Pi Pico Reset Button

      November 20, 2022

      Pi Pico Onboard LED

      Categories
      • 1-wire
      • 3D Printing
      • Add-ons
      • BBC Micro:bit
      • BerryClip
      • Books
      • Camera Module
      • Cases
      • Events
      • General
      • Hardware
      • I2C
      • Infographics
      • Interfaces
      • Minecraft
      • Model A+
      • Model B+
      • News
      • Pi Models
      • Pi Pico
      • Pi Zero
      • Power
      • Programming
      • Python
      • Raspberry Pi OS
      • Raspbian
      • RetroGaming
      • Robotics
      • Sensors
      • Software
      • SPI
      • Tutorials & Help
      Tags
      Arduino audio battery berryclip Birthday bluetooth cambridge camera CamJam DigiMakers display games GPIO I2C interface Kickstarter Kodi LCD LED Linux media Minecraft Model A motionEyeOS PCB photography photos Pi-Lite Pi Pico power python Raspberry Jam Raspberry Pi Bootcamp raspbian Retrogaming retroPie screen SD card security sensor SPI SSH temperature ultrasonic video
      Raspberry PI Related
      • Adafruit Blog
      • Average Maker
      • Official RaspBerry Pi Site
      • Raspberry Pi Pod
      • RasPi.tv
      • RaspTut
      • Stuff About Code
      Tech Resources
      • MattsBits – Pi Resources
      • Microbit Spy
      • Technology Spy
      Archives

      Entries RSS | Comments RSS

      This site is not associated with the official Raspberrypi.org site or the Raspberry Pi Foundation. Raspberry Pi is a trademark of the Raspberry Pi Foundation.

      Copyright © 2022 - All Rights Reserved - Matt Hawkins

      About

      Unofficial site devoted to the Raspberry Pi credit card sized computer offering tutorials, guides, resources,scripts and downloads. We hope to help everyone get the most out of their Pi by providing clear, simple articles on configuring, programming and operating it.

      Popular Posts
      September 19, 2014

      Top 5 Reasons The Raspberry Pi Sucks

      July 27, 2012

      16×2 LCD Module Control Using Python

      October 20, 2013

      Analogue Sensors On The Raspberry Pi Using An MCP3008

      Latest Posts
      February 16, 2024

      Disable SSH Password Login on Raspberry Pi

      March 13, 2023

      Elecrow Meteor IPS Touchscreen with RGB LEDs

      December 26, 2022

      Pi Pico Pinout Display on the Command Line

      Facebook X (Twitter) Instagram Pinterest YouTube RSS

      Entries RSS | Comments RSS

      This site is not associated with the official Raspberrypi.org site or the Raspberry Pi Foundation. Raspberry Pi is a trademark of the Raspberry Pi Foundation.

      Copyright © 2024 - All Rights Reserved - Matt Hawkins

      mastodon.social@RPiSpy

      Type above and press Enter to search. Press Esc to cancel.