Package com.diozero.devices
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 devicefloat
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
-
Constructor Details
-
BMP180
Constructor- Parameters:
mode
- BMP180 operating mode (low power .. ultra-high resolution)- Throws:
RuntimeIOException
- if an I/O error occurs
-
BMP180
- Throws:
RuntimeIOException
-
-
Method Details
-
readCalibrationData
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
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 interfaceThermometerInterface
- Returns:
- Temperature in Celsius as a double
- Throws:
RuntimeIOException
- If there is an IO error reading the sensor
-
getPressure
Read the barometric pressure (in hPa) from the device.- Specified by:
getPressure
in interfaceBarometerInterface
- 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 interfaceAutoCloseable
- Specified by:
close
in interfaceDeviceInterface
-