The BMP-180 Pressure Sensor

For detecting small altitude changes, reading the barometric altitude, or for just detecting changes in pressure, you may want to use a pressure sensor. The Bosch BMP-180 is a very reasonably priced one, which is accessed over I2C. There are several nice breakout boards available from Adafruit.featuring the BMP-180. There is, for example, one featuring only the BMP-180, and another one featuring gyros and accelerometers as well.


No matter which, you would access it in a similar fashion.

As usual, before you start, you need to install PI4J and set up the Rasberry for i2c communication.

Next decide in which mode you want the device to run. Check out the OperatingMode for details. The higher resolution, the longer time it takes to read values, and the higher the current draw.

If you are using the standard address and i2c bus, next create a BMPDevice:

BMPDevice bmp = new BMPDevice(OperatingMode.STANDARD);

Next, reading the pressure, altitude and temperature is done like this:

System.out.println(String.format(“Temperature: %.1fC, Pressure: %dhPa, Altitude: %.1fm”,
        bmp.readPressure() / 100,

To run the standard example, which will print the above every two seconds:

sudo java -classpath .:classes:/opt/pi4j/lib/*:./bmp.jar se.hirt.pi.adafruit.bmp.test.BMPTest


The Bosh BMP-180 is an easy way to measure the barometric altitude and/or changes in pressure.

3 Responses to "The BMP-180 Pressure Sensor"

  1. Jonas says:

    Where can I find documentation about the class “BMPDevice” ?

  2. Marcus says:

    Hi there!

    I haven’t really had time to blog about it yet, but I am working on the open source framework Robo4J together with a friend. Much of my code has been donated to that project, so you could start using this class instead:

    For more information, see:

    Hope this helps!

    Kind regards,

  3. Miro Wengner says:

    The one of framework main goals is to help Robotics/IoT communicty enabling rapid development of also advanced systems. We have already available some simple examples.


    We are systematically working hard on updates and improvements

    Kind Regards,
    Robo4J Team

Leave a Reply

Your email address will not be published. Required fields are marked *