Class BMP180

java.lang.Object
com.diozero.devices.BMP180
All Implemented Interfaces:
DeviceInterface, BarometerInterface, SensorInterface, ThermometerInterface, AutoCloseable

public class BMP180
extends Object
implements ThermometerInterface, BarometerInterface
Bosch BMP180 I2C temperature and pressure sensor
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static class  BMP180.BMPMode
    Relationship between sampling mode and conversion delay (in ms) for each sampling mode Ultra low power: 4.5 ms minimum conversion delay Standard: 7.5 ms High Resolution: 13.5 ms Ultra high Resolution: 25.5 ms
  • Constructor Summary

    Constructors
    Constructor Description
    BMP180​(int controller, BMP180.BMPMode mode)  
    BMP180​(BMP180.BMPMode mode)
    Constructor
  • Method Summary

    Modifier and Type Method Description
    void close()
    Close this device
    float getPressure()
    Read the barometric pressure (in hPa) from the device.
    float getTemperature()
    Method for reading the temperature.
    void readCalibrationData()
    This method reads the calibration data common for the Temperature sensor and Barometer sensor included in the BMP180

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • readCalibrationData

      public void readCalibrationData() throws RuntimeIOException
      This method reads the calibration data common for the Temperature sensor and Barometer sensor included in the BMP180
      Throws:
      RuntimeIOException - if an I/O error occurs
    • getTemperature

      public float getTemperature() throws RuntimeIOException
      Method for reading the temperature. Remember the sensor will provide us with raw data, and we need to transform in some analysed value to make sense. All the calculations are normally provided by the manufacturer. In our case we use the calibration data collected at construction time.
      Specified by:
      getTemperature in interface ThermometerInterface
      Returns:
      Temperature in Celsius as a double
      Throws:
      RuntimeIOException - If there is an IO error reading the sensor
    • getPressure

      public float getPressure() throws RuntimeIOException
      Read the barometric pressure (in hPa) from the device.
      Specified by:
      getPressure in interface BarometerInterface
      Returns:
      Pressure measurement in hPa
      Throws:
      RuntimeIOException - if an IO error occurs
    • close

      public void close()
      Description copied from interface: DeviceInterface
      Close this device
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface DeviceInterface